Fixed paper trail inconsistent results for numeric values

There is a known issue in paper_trail that whenever we Query the
'versions.object' column it evaluates inconsistent results for numeric
values due to limitations of SQL wildcard matchers against the
serialized objects. So to fix this issue I have manually formed the where
query instead of using where_object and where_object_changes. I have
also added test for the same.
Fixes #1307
This commit is contained in:
Siddhant Bajaj 2017-04-24 15:39:39 +05:30 committed by Stella Rouzi
parent 3ae97eb889
commit 1c12200003
3 changed files with 48 additions and 7 deletions

View file

@ -4,6 +4,8 @@ feature 'Version' do
let!(:conference) { create(:conference) }
let!(:organizer_role) { Role.find_by(name: 'organizer', resource: conference) }
let!(:organizer) { create(:user, role_ids: [organizer_role.id]) }
let(:event_with_commercial) { create(:event, program: conference.program) }
let(:event_commercial) { create(:event_commercial, commercialable: event_with_commercial, url: 'https://www.youtube.com/watch?v=M9bq_alk-sw') }
before(:each) do
sign_in organizer
@ -265,15 +267,28 @@ feature 'Version' do
end
scenario 'display changes in event commercials', feature: true, versioning: true, js: true do
event = create(:event, program: conference.program)
event_commercial = create(:event_commercial, commercialable: event, url: 'https://www.youtube.com/watch?v=M9bq_alk-sw')
event_commercial
event_commercial.update_attributes(url: 'https://www.youtube.com/watch?v=VNkDJk5_9eU')
event_commercial.destroy
visit admin_revision_history_path
expect(page).to have_text("Someone (probably via the console) created new commercial in event #{event.title} in conference #{conference.short_title}")
expect(page).to have_text("Someone (probably via the console) updated url of commercial in event #{event.title} in conference #{conference.short_title}")
expect(page).to have_text("Someone (probably via the console) deleted commercial in event #{event.title} in conference #{conference.short_title}")
expect(page).to have_text("Someone (probably via the console) created new commercial in event #{event_with_commercial.title} in conference #{conference.short_title}")
expect(page).to have_text("Someone (probably via the console) updated url of commercial in event #{event_with_commercial.title} in conference #{conference.short_title}")
expect(page).to have_text("Someone (probably via the console) deleted commercial in event #{event_with_commercial.title} in conference #{conference.short_title}")
end
scenario 'display changes in event commercials in event history', feature: true, versioning: true, js: true do
event_without_commercial = create(:event, program: conference.program)
event_commercial
visit admin_conference_program_event_path(conference.short_title, event_with_commercial)
click_link 'History'
expect(page).to have_text('Someone (probably via the console) created new commercial')
visit admin_conference_program_event_path(conference.short_title, event_without_commercial)
click_link 'History'
expect(event_commercial.id).not_to eq event_commercial.commercialable_id
expect(event_without_commercial.id).to eq event_commercial.id
expect(page).to have_no_text('Someone (probably via the console) created new commercial')
end
scenario 'display changes in users_role', feature: true, versioning: true, js: true do