Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add information about fixture users and how to create them #374

Merged
merged 1 commit into from
Jul 31, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,24 @@ $ uid=someuser rails s

Note, again, that the user must exist in symphony web services as well; this is only a bypass for the shibboleth authentication.

## Fixture users

Some integration tests use fixture users (stored in `spec/support/fixtures`) using some webmock magic to route
API requests to the appropriate fixture (see `spec/support/fake_symphony.rb`). These fixtures can be created
using the supplied rake task if you have the patron key:

```
$ rake fixtures:create[521183]
```

Note: these fixture objects are a snapshot of Symphony data frozen in time, and almost certainly do not reflect
the current data. This makes them useful for integration tests, but confusing to try to compare test output
with what you may see if you poke around the application in development.

Additional note: some fixture users have even been modified from their original form for ease of testing, perhaps
in ways that would be impossible to achieve by manipulating data in Symphony (e.g. `521181` has some fines, but
the patron standing is marked as 'OK' so we can reuse the patron for many different types of tests)

## Testing

The test suite (with RuboCop style enforcement) will be run with the default rake task (also run on travis)
Expand Down
12 changes: 12 additions & 0 deletions lib/tasks/fixtures.rake
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# frozen_string_literal: true

namespace :fixtures do
desc 'create a patron fixture by pulling the patron information from Symphony'
task :create, [:patron_key] => :environment do |_t, args|
patron_key = args[:patron_key]

File.open(Rails.root + "./spec/support/fixtures/patron/#{patron_key}.json", 'w') do |f|
f.write JSON.pretty_generate(SymphonyClient.new.patron_info(patron_key))
end
end
end