2018-05-07 16:47:29 -07:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
2017-04-24 15:39:39 +05:30
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
|
|
describe Admin::EventsController do
|
|
|
|
|
let(:conference) { create(:conference) }
|
2019-03-13 10:31:42 +01:00
|
|
|
let!(:organizer) { create(:organizer, resource: conference) }
|
Fix broken test in Admin::EventsController
We are using `paper_trail` gem, which saves data in database table
versions. It has a native way to search in the versions records,
using `where_object()` and `where_object_changes()`. They are broken,
under certain conditions. We changed them to a manual `where()`.
To test this case we need: an Event with ID 1, an Event with ID 2, and
a commercial with ID 1, for event with ID 2 - obviously the numbers
could be different as long as there is this matching of IDs. Before
this was made wit ha expect, which would make the test fail if this is
not the case. But this is actually the test case, not what we want to
test, so I moved to the `let`.
This was also the case why one of the test was broken after we change
how the database is cleaned in:
https://github.com/openSUSE/osem/pull/1541
I also remove the feature test, as this should be tested in a
controller test.
2017-06-17 20:32:57 +02:00
|
|
|
# The where_object() and where_object_changes() methods of paper_trail gem are broken when having:
|
|
|
|
|
# an Event with ID 1, an Event with ID 2, and a commercial with ID 1, for event with ID 2
|
|
|
|
|
# (the numbers could be different as long as there is this matching of IDs).
|
|
|
|
|
# We implemented or own where method to solve this and those ids are for testing this case.
|
|
|
|
|
let!(:event_without_commercial) { create(:event, id: 1, program: conference.program) }
|
|
|
|
|
let!(:event_with_commercial) { create(:event, id: 2, program: conference.program) }
|
|
|
|
|
let!(:event_commercial) { create(:event_commercial, id: 1, commercialable: event_with_commercial, url: 'https://www.youtube.com/watch?v=M9bq_alk-sw') }
|
2017-04-24 15:39:39 +05:30
|
|
|
|
|
|
|
|
with_versioning do
|
|
|
|
|
describe 'GET #show' do
|
|
|
|
|
before :each do
|
|
|
|
|
sign_in(organizer)
|
2019-05-13 17:42:09 +02:00
|
|
|
get :show, params: { id: event_without_commercial.id, conference_id: conference.short_title }
|
2017-04-24 15:39:39 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it 'assigns versions' do
|
|
|
|
|
versions = event_without_commercial.versions
|
|
|
|
|
expect(assigns(:versions)).to eq versions
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|