Introduce strong parameters

This commit is contained in:
Stella Rouzi 2015-10-28 18:05:15 +02:00
parent 38bc2e3c3a
commit 355ecc0ac6
93 changed files with 172 additions and 241 deletions

View file

@ -22,7 +22,7 @@ describe Admin::RegistrationPeriodsController do
context 'valid attributes' do
it 'locates the requested registration period object' do
patch :update, conference_id: conference.short_title, conference: attributes_for(:registration_period)
patch :update, conference_id: conference.short_title, registration_period: attributes_for(:registration_period)
expect(assigns(:registration_period)).to eq(conference.registration_period)
end

View file

@ -20,18 +20,19 @@ describe Admin::UsersController do
end
describe 'PATCH #update' do
context 'valid attributes' do
before :each do
patch :update, id: user.id, user: { name: 'new name', email: 'new_email@osem.io' }
end
it 'locates requested @user' do
patch :update, id: user.id
expect(build(:user, id: user.id)).to eq(user)
end
it 'changes @users attributes' do
patch :update, id: user.id
expect(build(
:user, email: 'new@email.osem', id: user.id).email).
to eq('new@email.osem')
:user, email: 'email_new@osem.io', id: user.id).email).
to eq('email_new@osem.io')
end
it 'redirects to the updated user' do
patch :update, id: user.id
expect(response).to redirect_to admin_users_path
end
end

View file

@ -2,11 +2,11 @@ require 'spec_helper'
feature 'Has correct abilities' do
# It is necessary to use bang version of let to build roles before user
let(:conference1) { create(:conference, venue: create(:venue)) } # user is organizer
let(:conference2) { create(:conference, venue: create(:venue)) } # user is cfp
let(:conference3) { create(:conference, venue: create(:venue)) } # user is info_desk
let(:conference4) { create(:conference, venue: create(:venue)) } # user is volunteer coordinator
let(:conference5) { create(:conference, venue: create(:venue)) } # user has no role
let(:conference1) { create(:conference) } # user is organizer
let(:conference2) { create(:conference) } # user is cfp
let(:conference3) { create(:conference) } # user is info_desk
let(:conference4) { create(:conference) } # user is volunteer coordinator
let(:conference5) { create(:conference) } # user has no role
let(:role_organizer) { create(:role, name: 'organizer', resource: conference1) }
let(:role_cfp) { create(:role, name: 'cfp', resource: conference2) }
@ -77,6 +77,10 @@ feature 'Has correct abilities' do
visit admin_conference_targets_path(conference1.short_title)
expect(current_path).to eq(admin_conference_targets_path(conference1.short_title))
visit new_admin_conference_venue_path(conference1.short_title)
expect(current_path).to eq(new_admin_conference_venue_path(conference1.short_title))
conference1.venue = create(:venue)
visit edit_admin_conference_venue_path(conference1.short_title)
expect(current_path).to eq(edit_admin_conference_venue_path(conference1.short_title))