Show conference changelog

Use load_and_authorize_resource in versions controlller
Add conference specifc route to revision history page
Users with role can view revision_history only for the versions they have access to
Handle versions where conference_id is not set (records before papertrail was introduced)
This commit is contained in:
Nishanth Vijayan 2016-08-06 17:22:53 +05:30 committed by Shlok Srivastava
parent 5985daf677
commit 68788ce9fc
13 changed files with 240 additions and 141 deletions

View file

@ -97,5 +97,14 @@ describe Admin::VersionsController do
expect(flash[:error]).to match('Revert failed. Attribute missing or invalid')
end
end
describe 'GET #index' do
it 'raises error if user is not an organizer of specified conference' do
user = create(:user)
sign_in user
get :index, conference_id: conference.short_title
expect(flash[:alert]).to match('You are not authorized to access this area.')
end
end
end
end

View file

@ -35,23 +35,25 @@ feature 'Version' do
scenario 'display changes in cfp', feature: true, versioning: true, js: true do
cfp = create(:cfp, program: conference.program)
cfp.update_attributes(start_date: (Date.today + 1).strftime('%d/%m/%Y'), end_date: (Date.today + 3).strftime('%d/%m/%Y'))
cfp_id = cfp.id
cfp.destroy
visit admin_revision_history_path
expect(page).to have_text("Someone (probably via the console) created new cfp for events in conference #{conference.short_title}")
expect(page).to have_text("Someone (probably via the console) updated start date and end date of cfp for events in conference #{conference.short_title}")
expect(page).to have_text("Someone (probably via the console) deleted cfp for events in conference #{conference.short_title}")
expect(page).to have_text("Someone (probably via the console) created new cfp for events with ID #{cfp_id} in conference #{conference.short_title}")
expect(page).to have_text("Someone (probably via the console) updated start date and end date of cfp for events with ID #{cfp_id} in conference #{conference.short_title}")
expect(page).to have_text("Someone (probably via the console) deleted cfp for events with ID #{cfp_id} in conference #{conference.short_title}")
end
scenario 'display changes in registration_period', feature: true, versioning: true, js: true do
registration_period = create(:registration_period, conference: conference)
registration_period.update_attributes(start_date: (Date.today + 1).strftime('%d/%m/%Y'), end_date: (Date.today + 3).strftime('%d/%m/%Y'))
registration_period_id = registration_period.id
registration_period.destroy
visit admin_revision_history_path
expect(page).to have_text("Someone (probably via the console) created new registration period in conference #{conference.short_title}")
expect(page).to have_text("Someone (probably via the console) updated start date and end date of registration period in conference #{conference.short_title}")
expect(page).to have_text("Someone (probably via the console) deleted registration period in conference #{conference.short_title}")
expect(page).to have_text("Someone (probably via the console) created new registration period with ID #{registration_period_id} in conference #{conference.short_title}")
expect(page).to have_text("Someone (probably via the console) updated start date and end date of registration period with ID #{registration_period_id} in conference #{conference.short_title}")
expect(page).to have_text("Someone (probably via the console) deleted registration period with ID #{registration_period_id} in conference #{conference.short_title}")
end
scenario 'display changes in conference', feature: true, versioning: true, js: true do
@ -61,32 +63,34 @@ feature 'Version' do
visit admin_revision_history_path
select '100', from: 'versionstable_length'
expect(page).to have_text('Someone (probably via the console) created new conference New Con')
expect(page).to have_text('Someone (probably via the console) created new conference NewCon')
expect(page).to have_text('Someone (probably via the console) created new event type Talk in conference NewCon')
expect(page).to have_text('Someone (probably via the console) created new event type Workshop in conference NewCon')
expect(page).to have_text('Someone (probably via the console) updated title and short title of conference New Con')
expect(page).to have_text('Someone (probably via the console) updated title and short title of conference NewCon')
end
scenario 'display changes in event_type', feature: true, versioning: true, js: true do
event_type = create(:event_type, program: conference.program, name: 'Discussion')
event_type.update_attributes(length: 90, maximum_abstract_length: 10000)
event_type_id = event_type.id
event_type.destroy
visit admin_revision_history_path
expect(page).to have_text("Someone (probably via the console) created new event type Discussion in conference #{conference.short_title}")
expect(page).to have_text("Someone (probably via the console) updated length and maximum abstract length of event type Discussion in conference #{conference.short_title}")
expect(page).to have_text("Someone (probably via the console) deleted event type Discussion in conference #{conference.short_title}")
expect(page).to have_text("Someone (probably via the console) created new event type Discussion with ID #{event_type_id} in conference #{conference.short_title}")
expect(page).to have_text("Someone (probably via the console) updated length and maximum abstract length of event type Discussion with ID #{event_type_id} in conference #{conference.short_title}")
expect(page).to have_text("Someone (probably via the console) deleted event type Discussion with ID #{event_type_id} in conference #{conference.short_title}")
end
scenario 'display changes in lodging', feature: true, versioning: true, js: true do
lodging = create(:lodging, conference: conference, name: 'Hotel XYZ')
lodging.update_attributes(description: 'Nice view,close to venue', website_link: 'http://www.example.com')
lodging_id = lodging.id
lodging.destroy
visit admin_revision_history_path
expect(page).to have_text("Someone (probably via the console) created new lodging Hotel XYZ in conference #{conference.short_title}")
expect(page).to have_text("Someone (probably via the console) updated description and website link of lodging Hotel XYZ in conference #{conference.short_title}")
expect(page).to have_text("Someone (probably via the console) deleted lodging Hotel XYZ in conference #{conference.short_title}")
expect(page).to have_text("Someone (probably via the console) created new lodging Hotel XYZ with ID #{lodging_id} in conference #{conference.short_title}")
expect(page).to have_text("Someone (probably via the console) updated description and website link of lodging Hotel XYZ with ID #{lodging_id} in conference #{conference.short_title}")
expect(page).to have_text("Someone (probably via the console) deleted lodging Hotel XYZ with ID #{lodging_id} in conference #{conference.short_title}")
end
scenario 'display changes in role', feature: true, versioning: true, js: true do
@ -102,12 +106,13 @@ feature 'Version' do
venue = create(:venue, conference: conference)
room = create(:room, venue: venue, name: 'Auditorium')
room.update_attributes(size: 120)
room_id = room.id
room.destroy
visit admin_revision_history_path
expect(page).to have_text("Someone (probably via the console) created new room Auditorium in conference #{conference.short_title}")
expect(page).to have_text("Someone (probably via the console) updated size of room Auditorium in conference #{conference.short_title}")
expect(page).to have_text("Someone (probably via the console) deleted room Auditorium in conference #{conference.short_title}")
expect(page).to have_text("Someone (probably via the console) created new room Auditorium with ID #{room_id} in conference #{conference.short_title}")
expect(page).to have_text("Someone (probably via the console) updated size of room Auditorium with ID #{room_id} in conference #{conference.short_title}")
expect(page).to have_text("Someone (probably via the console) deleted room Auditorium with ID #{room_id} in conference #{conference.short_title}")
end
scenario 'display changes in sponsor', feature: true, versioning: true, js: true do
@ -115,55 +120,60 @@ feature 'Version' do
sponsor = create(:sponsor, conference: conference, name: 'SUSE', sponsorship_level: conference.sponsorship_levels.first)
sponsor.update_attributes(website_url: 'https://www.suse.com/company/history', sponsorship_level: conference.sponsorship_levels.second)
sponsor.destroy
sponsor_id = sponsor.id
visit admin_revision_history_path
expect(page).to have_text("Someone (probably via the console) created new sponsor SUSE in conference #{conference.short_title}")
expect(page).to have_text("Someone (probably via the console) updated website url and sponsorship level of sponsor SUSE in conference #{conference.short_title}")
expect(page).to have_text("Someone (probably via the console) deleted sponsor SUSE in conference #{conference.short_title}")
expect(page).to have_text("Someone (probably via the console) created new sponsor SUSE with ID #{sponsor_id} in conference #{conference.short_title}")
expect(page).to have_text("Someone (probably via the console) updated website url and sponsorship level of sponsor SUSE with ID #{sponsor_id} in conference #{conference.short_title}")
expect(page).to have_text("Someone (probably via the console) deleted sponsor SUSE with ID #{sponsor_id} in conference #{conference.short_title}")
end
scenario 'display changes in sponsorship_level', feature: true, versioning: true, js: true do
sponsorship_level = create(:sponsorship_level, conference: conference)
sponsorship_level.update_attributes(title: 'Gold')
sponsorship_level_id = sponsorship_level.id
sponsorship_level.destroy
visit admin_revision_history_path
expect(page).to have_text("Someone (probably via the console) created new sponsorship level Gold in conference #{conference.short_title}")
expect(page).to have_text("Someone (probably via the console) updated title of sponsorship level Gold in conference #{conference.short_title}")
expect(page).to have_text("Someone (probably via the console) deleted sponsorship level Gold in conference #{conference.short_title}")
expect(page).to have_text("Someone (probably via the console) created new sponsorship level Gold with ID #{sponsorship_level_id} in conference #{conference.short_title}")
expect(page).to have_text("Someone (probably via the console) updated title of sponsorship level Gold with ID #{sponsorship_level_id} in conference #{conference.short_title}")
expect(page).to have_text("Someone (probably via the console) deleted sponsorship level Gold with ID #{sponsorship_level_id} in conference #{conference.short_title}")
end
scenario 'display changes in ticket', feature: true, versioning: true, js: true do
ticket = create(:ticket, conference: conference, title: 'Gold')
ticket.update_attributes(price: 50, description: 'Premium Ticket')
ticket_id = ticket.id
ticket.destroy
visit admin_revision_history_path
expect(page).to have_text("Someone (probably via the console) created new ticket Gold in conference #{conference.short_title}")
expect(page).to have_text("Someone (probably via the console) updated price cents and description of ticket Gold in conference #{conference.short_title}")
expect(page).to have_text("Someone (probably via the console) deleted ticket Gold in conference #{conference.short_title}")
expect(page).to have_text("Someone (probably via the console) created new ticket Gold with ID #{ticket_id} in conference #{conference.short_title}")
expect(page).to have_text("Someone (probably via the console) updated price cents and description of ticket Gold with ID #{ticket_id} in conference #{conference.short_title}")
expect(page).to have_text("Someone (probably via the console) deleted ticket Gold with ID #{ticket_id} in conference #{conference.short_title}")
end
scenario 'display changes in track', feature: true, versioning: true, js: true do
track = create(:track, program: conference.program, name: 'Distribution')
track.update_attributes(description: 'Events about Linux distributions')
track_id = track.id
track.destroy
visit admin_revision_history_path
expect(page).to have_text("Someone (probably via the console) created new track Distribution in conference #{conference.short_title}")
expect(page).to have_text("Someone (probably via the console) updated description of track Distribution in conference #{conference.short_title}")
expect(page).to have_text("Someone (probably via the console) deleted track Distribution in conference #{conference.short_title}")
expect(page).to have_text("Someone (probably via the console) created new track Distribution with ID #{track_id} in conference #{conference.short_title}")
expect(page).to have_text("Someone (probably via the console) updated description of track Distribution with ID #{track_id} in conference #{conference.short_title}")
expect(page).to have_text("Someone (probably via the console) deleted track Distribution with ID #{track_id} in conference #{conference.short_title}")
end
scenario 'display changes in venue', feature: true, versioning: true, js: true do
venue = create(:venue, conference: conference, name: 'Example University')
venue.update_attributes(website: 'www.example.com new', description: 'Just another beautiful venue')
venue_id = venue.id
venue.destroy
visit admin_revision_history_path
expect(page).to have_text("Someone (probably via the console) created new venue Example University in conference #{conference.short_title}")
expect(page).to have_text("Someone (probably via the console) updated website and description of venue Example University in conference #{conference.short_title}")
expect(page).to have_text("Someone (probably via the console) deleted venue Example University in conference #{conference.short_title}")
expect(page).to have_text("Someone (probably via the console) created new venue Example University with ID #{venue_id} in conference #{conference.short_title}")
expect(page).to have_text("Someone (probably via the console) updated website and description of venue Example University with ID #{venue_id} in conference #{conference.short_title}")
expect(page).to have_text("Someone (probably via the console) deleted venue Example University with ID #{venue_id} in conference #{conference.short_title}")
end
scenario 'display changes in event', feature: true, versioning: true, js: true do
@ -209,12 +219,13 @@ feature 'Version' do
scenario 'display changes in difficulty levels', feature: true, versioning: true, js: true do
difficulty_level = create(:difficulty_level, program: conference.program, title: 'Expert')
difficulty_level.update_attributes(description: 'Only for Experts')
difficulty_level_id = difficulty_level.id
difficulty_level.destroy
visit admin_revision_history_path
expect(page).to have_text("Someone (probably via the console) created new difficulty level Expert in conference #{conference.short_title}")
expect(page).to have_text("Someone (probably via the console) updated description of difficulty level Expert in conference #{conference.short_title}")
expect(page).to have_text("Someone (probably via the console) deleted difficulty level Expert in conference #{conference.short_title}")
expect(page).to have_text("Someone (probably via the console) created new difficulty level Expert with ID #{difficulty_level_id} in conference #{conference.short_title}")
expect(page).to have_text("Someone (probably via the console) updated description of difficulty level Expert with ID #{difficulty_level_id} in conference #{conference.short_title}")
expect(page).to have_text("Someone (probably via the console) deleted difficulty level Expert with ID #{difficulty_level_id} in conference #{conference.short_title}")
end
scenario 'display changes in splashpages', feature: true, versioning: true, js: true do
@ -232,13 +243,14 @@ feature 'Version' do
uncheck('Display social media')
check('Make splash page public?')
click_button 'Save Splashpage'
splashpage_id = conference.splashpage.id
click_link 'Delete'
visit admin_revision_history_path
expect(page).to have_text("#{organizer.name} created new splashpage in conference #{conference.short_title}")
expect(page).to have_text("#{organizer.name} created new splashpage with ID #{splashpage_id} in conference #{conference.short_title}")
expect(page).to have_text("#{organizer.name} updated public, include program, include cfp, include venue, include tickets, include lodgings,
include sponsors and include social media of splashpage in conference #{conference.short_title}")
expect(page).to have_text("#{organizer.name} deleted splashpage in conference #{conference.short_title}")
include sponsors and include social media of splashpage with ID #{splashpage_id} in conference #{conference.short_title}")
expect(page).to have_text("#{organizer.name} deleted splashpage with ID #{splashpage_id} in conference #{conference.short_title}")
end
scenario 'displays users subscribe/unsubscribe to conferences', feature: true, versioning: true, js: true do
@ -249,10 +261,10 @@ feature 'Version' do
PaperTrail::Version.last.item.destroy!
visit admin_revision_history_path
expect(page).to have_text("#{organizer.name} subscribed to conference #{conference.title}")
expect(page).to have_text("#{organizer.name} unsubscribed from conference #{conference.title}")
expect(page).to have_text("Someone (probably via the console) subscribed #{organizer.name} to conference #{conference.title}")
expect(page).to have_text("Someone (probably via the console) unsubscribed #{organizer.name} from conference #{conference.title}")
expect(page).to have_text("#{organizer.name} subscribed to conference #{conference.short_title}")
expect(page).to have_text("#{organizer.name} unsubscribed from conference #{conference.short_title}")
expect(page).to have_text("Someone (probably via the console) subscribed #{organizer.name} to conference #{conference.short_title}")
expect(page).to have_text("Someone (probably via the console) unsubscribed #{organizer.name} from conference #{conference.short_title}")
end
scenario 'display changes in conference commercials', feature: true, versioning: true, js: true do
@ -312,8 +324,8 @@ feature 'Version' do
Registration.last.destroy
visit admin_revision_history_path
expect(page).to have_text("Someone (probably via the console) registered #{organizer.name} to conference #{conference.title}")
expect(page).to have_text("Someone (probably via the console) unregistered #{organizer.name} from conference #{conference.title}")
expect(page).to have_text("Someone (probably via the console) registered #{organizer.name} to conference #{conference.short_title}")
expect(page).to have_text("Someone (probably via the console) unregistered #{organizer.name} from conference #{conference.short_title}")
end
scenario 'display changes in event registration', feature: true, versioning: true, js: true do
@ -335,12 +347,13 @@ feature 'Version' do
scenario 'display changes in target', feature: true, versioning: true, js: true do
target = create(:target, conference: conference)
target.update_attributes(due_date: Date.today, target_count: 1000)
target_id = target.id
target.destroy
visit admin_revision_history_path
expect(page).to have_text("Someone (probably via the console) created new target 1000 Submissions by #{Date.today} in conference #{conference.short_title}")
expect(page).to have_text("Someone (probably via the console) updated due date and target count of target 1000 Submissions by #{Date.today} in conference #{conference.short_title}")
expect(page).to have_text("Someone (probably via the console) deleted target 1000 Submissions by #{Date.today} in conference #{conference.short_title}")
expect(page).to have_text("Someone (probably via the console) created new target 1000 Submissions by #{Date.today} with ID #{target_id} in conference #{conference.short_title}")
expect(page).to have_text("Someone (probably via the console) updated due date and target count of target 1000 Submissions by #{Date.today} with ID #{target_id} in conference #{conference.short_title}")
expect(page).to have_text("Someone (probably via the console) deleted target 1000 Submissions by #{Date.today} with ID #{target_id} in conference #{conference.short_title}")
end
scenario 'display changes in comment', feature: true, versioning: true, js: true do
@ -376,12 +389,13 @@ feature 'Version' do
scenario 'display changes in campaign', feature: true, versioning: true, js: true do
campaign = create(:campaign, conference: conference, name: 'Test Campaign', utm_campaign: 'campaign')
campaign.update_attributes(utm_source: 'source', utm_medium: 'medium', utm_term: 'term', utm_content: 'content')
campaign_id = campaign.id
campaign.destroy
visit admin_revision_history_path
expect(page).to have_text("Someone (probably via the console) created new campaign Test Campaign in conference #{conference.short_title}")
expect(page).to have_text("Someone (probably via the console) updated utm source, utm medium, utm term and utm content of campaign Test Campaign in conference #{conference.short_title}")
expect(page).to have_text("Someone (probably via the console) deleted campaign Test Campaign in conference #{conference.short_title}")
expect(page).to have_text("Someone (probably via the console) created new campaign Test Campaign with ID #{campaign_id} in conference #{conference.short_title}")
expect(page).to have_text("Someone (probably via the console) updated utm source, utm medium, utm term and utm content of campaign Test Campaign with ID #{campaign_id} in conference #{conference.short_title}")
expect(page).to have_text("Someone (probably via the console) deleted campaign Test Campaign with ID #{campaign_id} in conference #{conference.short_title}")
end
scenario 'display password reset requests', feature: true, versioning: true, js: true do