Skip to content

Commit

Permalink
FeedVersion controller specs
Browse files Browse the repository at this point in the history
  • Loading branch information
irees committed Dec 2, 2016
1 parent 34e4f24 commit 7d4910c
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions spec/controllers/api/v1/feed_versions_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,33 @@
})
end

it 'calendar_coverage_begins_at_or_before' do
fv1 = create(:feed_version, earliest_calendar_date: '2016-01-01', latest_calendar_date: '2017-01-01')
fv2 = create(:feed_version, earliest_calendar_date: '2016-02-01', latest_calendar_date: '2017-02-01')
get :index, calendar_coverage_begins_at_or_before: '2016-01-01'
expect_json({feed_versions: -> (feed_versions) {
expect(feed_versions.map { |fv| fv[:sha1]}).to match_array([fv1.sha1])
}})
end

it 'calendar_coverage_begins_at_or_after' do
fv1 = create(:feed_version, earliest_calendar_date: '2016-01-01', latest_calendar_date: '2017-01-01')
fv2 = create(:feed_version, earliest_calendar_date: '2016-02-01', latest_calendar_date: '2017-02-01')
get :index, calendar_coverage_begins_at_or_after: '2016-02-01'
expect_json({feed_versions: -> (feed_versions) {
expect(feed_versions.map { |fv| fv[:sha1]}).to match_array([fv2.sha1])
}})
end

it 'calendar_coverage_includes' do
fv1 = create(:feed_version, earliest_calendar_date: '2016-01-01', latest_calendar_date: '2017-01-01')
fv2 = create(:feed_version, earliest_calendar_date: '2016-02-01', latest_calendar_date: '2017-02-01')
get :index, calendar_coverage_includes: '2017-01-15'
expect_json({feed_versions: -> (feed_versions) {
expect(feed_versions.map { |fv| fv[:sha1]}).to match_array([fv2.sha1])
}})
end

it 'filters by SHA1 hash' do
create_list(:feed_version, 2)
sha1 = FeedVersion.first.sha1
Expand Down

0 comments on commit 7d4910c

Please sign in to comment.