Require code of conduct acceptance on registration

This commit is contained in:
James Mason 2018-03-16 16:23:01 -07:00 committed by Ana María Martínez Gómez
parent 95196c7f80
commit 03ef28e74d
9 changed files with 91 additions and 8 deletions

View file

@ -2,6 +2,7 @@ require 'spec_helper'
feature 'Code of Conduct:' do
let!(:organization) { create(:organization) }
let!(:conference) { create(:full_conference, organization: organization) }
let(:admin) { create(:admin) }
let(:sample_text) { Faker::Lorem.paragraph }
@ -45,8 +46,6 @@ feature 'Code of Conduct:' do
end
context 'on a conference' do
let!(:conference) { create(:full_conference, organization: organization) }
it 'is linked from the index' do
visit conferences_path
within "#conference-#{conference.id}" do
@ -62,5 +61,34 @@ feature 'Code of Conduct:' do
end
end
end
describe 'as a participant' do
let!(:organization) { create(:organization, code_of_conduct: sample_text) }
let!(:participant) { create(:user) }
before { sign_in participant }
it 'must be accepted', js: true do
visit conferences_path
within "#conference-#{conference.id}" do
click_on 'Register'
end
expect(page).to have_text('I have read and accept the Code of Conduct')
expect(page).not_to have_text(sample_text)
within 'form' do
click_on 'Code of Conduct'
end
expect(page).to have_content(sample_text)
find('button.close').click
click_on 'Register'
expect(conference.user_registered?(participant)).to be_falsey
expect(page).to have_content('Accepted code of conduct must be accepted')
check 'registration[accepted_code_of_conduct]'
click_on 'Register'
expect(conference.user_registered?(participant)).to be_truthy
visit conference_conference_registration_path(conference)
expect(page).to have_content('You have accepted the Code of Conduct')
end
end
end
end