Advertisement
4tolexx

users csv export feature test and implementation

Apr 1st, 2025 (edited)
746
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Feature: Export Users as CSV
  2.  
  3.   Background:
  4.     Given a user "User 1" with:
  5.       | id   | 1             |
  6.       | name | Alex Barnsley |
  7.     And a user "User 2" with:
  8.       | id   | 2             |
  9.       | name | Phil Thompson |
  10.     And a role "Authorized" with permissions:
  11.       | User    | read |
  12.     And user "User 1" belongs to role "Authorized"
  13.  
  14.   Scenario: Export users list as csv
  15.     When I sign in as user "User 1"
  16.     And I browse to users list
  17.     Then I see "User 1"
  18.     And I see "User 2"
  19.     When I click "CSV"
  20.     Then I download a CSV with content:
  21.       | Id | Name          | Username | Sign in count | Failed attempts | Last sign in at | Password changed at | Locked at  | Created at | Updated at |
  22.       | 1  | Alex Barnsley | User 1   | <INT>         | <INT>           | <ISO_DATE>      | <ISO_DATE>          | <EMPTY>    | <ISO_DATE> | <ISO_DATE> |
  23.       | 2  | Phil Thompson | User 2   | <INT>         | <INT>           | <EMPTY>         | <ISO_DATE>          | <EMPTY>    | <ISO_DATE> | <ISO_DATE> |
  24.  
  25.  
  26. csv do
  27.     column :id
  28.     column(:name) { |user| user.object.name }
  29.     column(:username) { |user| user.object.username }
  30.     column :sign_in_count
  31.     column :last_sign_in_at
  32.     column :failed_attempts
  33.     column :password_changed_at
  34.     column :locked_at
  35.     column :updated_at
  36.     column :created_at
  37.   end
  38.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement