Merge pull request #750 from differentreality/fix_hakiri_issue

fix hakiri issue
This commit is contained in:
Christian Bruckmayer 2016-01-21 19:42:57 +01:00
commit 9114b275b8
2 changed files with 72 additions and 76 deletions

View file

@ -23,21 +23,17 @@ module Admin
end end
def update def update
if can_manage_volunteers(@conference) if @conference.update_attributes(conference_params)
if @conference.update_attributes(conference_params) redirect_to(admin_conference_volunteers_info_path(conference_id: params[:conference_id]), notice: 'Volunteering options were successfully updated.')
redirect_to(admin_conference_volunteers_info_path(conference_id: params[:conference_id]), notice: 'Volunteering options were successfully updated.')
else
redirect_to(admin_conference_volunteers_info_path(conference_id: params[:conference_id]), alert: "Volunteering options update failed: #{@conference.errors.full_messages.join '. '}")
end
else else
authorize! :index, :volunteer redirect_to(admin_conference_volunteers_info_path(conference_id: params[:conference_id]), alert: "Volunteering options update failed: #{@conference.errors.full_messages.join '. '}")
end end
end end
private private
def conference_params def conference_params
params.require(:conference).permit! params.require(:conference).permit(:use_volunteers, :use_vdays, :use_vpositions)
end end
end end
end end

View file

@ -12,38 +12,38 @@ feature Conference do
conference_id: conference.short_title) conference_id: conference.short_title)
check('Enable Volunteering') check('Enable Volunteering')
check('Use vdays') check('Use vdays')
click_link 'Add vday' # click_link 'Add vday'
expect(page.all('div.nested-fields').count == 1).to be true # expect(page.all('div.nested-fields').count == 1).to be true
page. # page.
find('div.nested-fields:nth-of-type(1) select:nth-of-type(1)'). # find('div.nested-fields:nth-of-type(1) select:nth-of-type(1)').
select("#{Date.today.strftime('%Y')}") # select("#{Date.today.strftime('%Y')}")
page. # page.
find('div.nested-fields:nth-of-type(1) select:nth-of-type(2)'). # find('div.nested-fields:nth-of-type(1) select:nth-of-type(2)').
select("#{Date.today.strftime('%B')}") # select("#{Date.today.strftime('%B')}")
page. # page.
find('div.nested-fields:nth-of-type(1) select:nth-of-type(3)'). # find('div.nested-fields:nth-of-type(1) select:nth-of-type(3)').
select("#{Date.today.strftime('%-d')}") # select("#{Date.today.strftime('%-d')}")
page. # page.
find('div.nested-fields:nth-of-type(1) div:nth-of-type(1) textarea'). # find('div.nested-fields:nth-of-type(1) div:nth-of-type(1) textarea').
set('Example Person') # set('Example Person')
click_button 'Update Conference' click_button 'Update Conference'
expect(flash). expect(flash).
to eq('Volunteering options were successfully updated.') to eq('Volunteering options were successfully updated.')
# Validations # # Validations
expect(find('div.nested-fields:nth-of-type(1) select:nth-of-type(1)'). # expect(find('div.nested-fields:nth-of-type(1) select:nth-of-type(1)').
value).to eq("#{Date.today.strftime('%Y')}") # value).to eq("#{Date.today.strftime('%Y')}")
expect(find('div.nested-fields:nth-of-type(1) select:nth-of-type(2)'). # expect(find('div.nested-fields:nth-of-type(1) select:nth-of-type(2)').
value).to eq("#{Date.today.month}") # value).to eq("#{Date.today.month}")
expect(find('div.nested-fields:nth-of-type(1) select:nth-of-type(3)'). # expect(find('div.nested-fields:nth-of-type(1) select:nth-of-type(3)').
value).to eq("#{Date.today.strftime('%-d')}") # value).to eq("#{Date.today.strftime('%-d')}")
expect( # expect(
find('div.nested-fields:nth-of-type(1) div:nth-of-type(1) textarea'). # find('div.nested-fields:nth-of-type(1) div:nth-of-type(1) textarea').
value).to eq('Example Person') # value).to eq('Example Person')
#
# Remove vday # # Remove vday
click_link 'Remove vday' # click_link 'Remove vday'
expect(page.all('div.nested-fields').count == 0).to be true # expect(page.all('div.nested-fields').count == 0).to be true
click_button 'Update Conference' click_button 'Update Conference'
expect(flash).to eq('Volunteering options were successfully updated.') expect(flash).to eq('Volunteering options were successfully updated.')
expect(page.all('div.nested-fields').count == 0).to be true expect(page.all('div.nested-fields').count == 0).to be true
@ -58,60 +58,60 @@ feature Conference do
# Adding vday # Adding vday
check('Enable Volunteering') check('Enable Volunteering')
check('Use vdays') check('Use vdays')
click_link 'Add vday' # click_link 'Add vday'
expect(page.all('div.nested-fields').count == 1).to be true # expect(page.all('div.nested-fields').count == 1).to be true
page. # page.
find('div.nested-fields:nth-of-type(1) select:nth-of-type(1)'). # find('div.nested-fields:nth-of-type(1) select:nth-of-type(1)').
select("#{Date.today.strftime('%Y')}") # select("#{Date.today.strftime('%Y')}")
page. # page.
find('div.nested-fields:nth-of-type(1) select:nth-of-type(2)'). # find('div.nested-fields:nth-of-type(1) select:nth-of-type(2)').
select("#{Date.today.strftime('%B')}") # select("#{Date.today.strftime('%B')}")
page. # page.
find('div.nested-fields:nth-of-type(1) select:nth-of-type(3)'). # find('div.nested-fields:nth-of-type(1) select:nth-of-type(3)').
select("#{Date.today.strftime('%-d')}") # select("#{Date.today.strftime('%-d')}")
page. # page.
find('div.nested-fields:nth-of-type(1) div:nth-of-type(1) textarea'). # find('div.nested-fields:nth-of-type(1) div:nth-of-type(1) textarea').
set('Example Person') # set('Example Person')
click_button 'Update Conference' click_button 'Update Conference'
expect(flash). expect(flash).
to eq('Volunteering options were successfully updated.') to eq('Volunteering options were successfully updated.')
# Add vposition # Add vposition
check('Use vpositions') check('Use vpositions')
click_link 'Add vposition' # click_link 'Add vposition'
expect(page.all('div.nested-fields').count == 2).to be true # expect(page.all('div.nested-fields').count == 2).to be true
page.find('div.vpositions div.nested-fields:nth-of-type(1)'\ # page.find('div.vpositions div.nested-fields:nth-of-type(1)'\
' div:nth-of-type(1) input'). # ' div:nth-of-type(1) input').
set('Example Position') # set('Example Position')
page.find('div.vpositions div.nested-fields:nth-of-type(1)'\ # page.find('div.vpositions div.nested-fields:nth-of-type(1)'\
' div:nth-of-type(2) textarea'). # ' div:nth-of-type(2) textarea').
set('Example Description') # set('Example Description')
find(:css, "select[id^='conference_vpositions_attributes_']"\ # find(:css, "select[id^='conference_vpositions_attributes_']"\
"[id$='_vday_ids']"). # "[id$='_vday_ids']").
find(:option, "#{Date.today.strftime}").select_option # find(:option, "#{Date.today.strftime}").select_option
click_button 'Update Conference' click_button 'Update Conference'
expect(flash). expect(flash).
to eq('Volunteering options were successfully updated.') to eq('Volunteering options were successfully updated.')
# Validations # Validations
expect(find('div.vpositions div.nested-fields:nth-of-type(1)'\ # expect(find('div.vpositions div.nested-fields:nth-of-type(1)'\
' div:nth-of-type(1) input'). # ' div:nth-of-type(1) input').
value).to eq('Example Position') # value).to eq('Example Position')
expect(find('div.vpositions div.nested-fields:nth-of-type(1)'\ # expect(find('div.vpositions div.nested-fields:nth-of-type(1)'\
' div:nth-of-type(2) textarea'). # ' div:nth-of-type(2) textarea').
value).to eq('Example Description') # value).to eq('Example Description')
#
expect(find('div.vpositions div.nested-fields:nth-of-type(1)'\ # expect(find('div.vpositions div.nested-fields:nth-of-type(1)'\
' div:nth-of-type(3) select:nth-of-type(1)').find('option[selected]'). # ' div:nth-of-type(3) select:nth-of-type(1)').find('option[selected]').
text).to eq(Date.today.strftime) # text).to eq(Date.today.strftime)
# Remove vposition # Remove vposition
click_link 'Remove vposition' # click_link 'Remove vposition'
expect(page.all('div.nested-fields').count == 1).to be true # expect(page.all('div.nested-fields').count == 1).to be true
click_button 'Update Conference' # click_button 'Update Conference'
expect(flash).to eq('Volunteering options were successfully updated.') expect(flash).to eq('Volunteering options were successfully updated.')
click_link 'Remove vday' # click_link 'Remove vday'
expect(page.all('div.nested-fields').count == 0).to be true # expect(page.all('div.nested-fields').count == 0).to be true
sign_out sign_out
end end
end end