Display who added commercial for event

Activate versioning for tests

The tests were failing because of the lack of versioning.By default, versioning is off for tests.
As a result, here (app/views/proposal/_form.html.haml L43) commercial,versions.last returns nil as there are no versions.
This commit is contained in:
Nishanth Vijayan 2016-07-29 20:09:16 +05:30
parent 8335aa8b43
commit 48828f8930
5 changed files with 14 additions and 11 deletions

View file

@ -383,7 +383,7 @@ module ApplicationHelper
reverse.sub(',', ' dna ').reverse
end
def change_creator_link(user_id)
def link_to_user(user_id)
user = User.find_by(id: user_id)
if user
link_to user.name, admin_user_path(id: user_id)
@ -479,16 +479,16 @@ module ApplicationHelper
def user_change_description(version)
if version.event == 'create'
change_creator_link(version.item_id) + ' signed up'
link_to_user(version.item_id) + ' signed up'
elsif version.event == 'update'
if version.changeset.keys.include?('reset_password_sent_at')
'Someone requested password reset of'
elsif version.changeset.keys.include?('confirmed_at') && version.changeset['confirmed_at'][0].nil?
(version.whodunnit.nil? ? change_creator_link(version.item_id) : change_creator_link(version.whodunnit)) + ' confirmed account of'
(version.whodunnit.nil? ? link_to_user(version.item_id) : link_to_user(version.whodunnit)) + ' confirmed account of'
elsif version.changeset.keys.include?('confirmed_at') && version.changeset['confirmed_at'][1].nil?
change_creator_link(version.whodunnit) + ' unconfirmed account of'
link_to_user(version.whodunnit) + ' unconfirmed account of'
else
change_creator_link(version.whodunnit) + " updated #{updated_attributes(version)} of"
link_to_user(version.whodunnit) + " updated #{updated_attributes(version)} of"
end
end
end

View file

@ -21,7 +21,7 @@
= version.id
%td
%p
= change_creator_link(version.whodunnit)
= link_to_user(version.whodunnit)
- if version.item_type == 'Event'
= event_change_description(version)

View file

@ -17,7 +17,7 @@
= version.id
%td.col-md-9
%p
= change_creator_link(version.whodunnit) unless version.item_type == 'User'
= link_to_user(version.whodunnit) unless version.item_type == 'User'
- case version.item_type
- when 'Event'

View file

@ -40,3 +40,6 @@
- if can? :destroy, commercial
= link_to 'Delete', conference_program_proposal_commercial_path(@conference.short_title, @event.id, commercial.id),
:method => :delete, :data => { :confirm => 'Are you sure?' }, class: 'btn btn-danger'
.text-right
= "added by "
= link_to_user(commercial.versions.last.whodunnit)

View file

@ -58,7 +58,7 @@ feature Commercial do
sign_out
end
scenario 'adds a valid commercial of an event', feature: true, js: true do
scenario 'adds a valid commercial of an event', feature: true, versioning: true, js: true do
visit edit_conference_program_proposal_path(conference.short_title, event.id)
click_link 'Commercials'
fill_in 'commercial_url', with: 'https://www.youtube.com/watch?v=M9bq_alk-sw'
@ -85,7 +85,7 @@ feature Commercial do
expect(event.commercials.count).to eq 0
end
scenario 'updates a commercial of an event', feature: true, js: true do
scenario 'updates a commercial of an event', feature: true, versioning: true, js: true do
commercial = create(:commercial,
commercialable_id: event.id,
commercialable_type: 'Event')
@ -99,7 +99,7 @@ feature Commercial do
expect(commercial.url).to eq('https://www.youtube.com/watch?v=M9bq_alk-sw')
end
scenario 'does not update a commercial of an event with invalid data', feature: true, js: true do
scenario 'does not update a commercial of an event with invalid data', feature: true, versioning: true, js: true do
commercial = create(:commercial,
commercialable_id: event.id,
commercialable_type: 'Event')
@ -113,7 +113,7 @@ feature Commercial do
expect(commercial.url).to eq('https://www.youtube.com/watch?v=BTTygyxuGj8')
end
scenario 'deletes a commercial of an event', feature: true, js: true do
scenario 'deletes a commercial of an event', feature: true, versioning: true, js: true do
create(:commercial,
commercialable_id: event.id,
commercialable_type: 'Event')