Skip to content

Commit

Permalink
Add information about fixture users and how to create them (with a ne…
Browse files Browse the repository at this point in the history
…w handy rake task; fixes #364
  • Loading branch information
cbeer committed Jul 31, 2019
1 parent 37013e9 commit ea9fb31
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
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

0 comments on commit ea9fb31

Please sign in to comment.