From 675f5e78951fb9a6e8884510070e6c03ed464fd6 Mon Sep 17 00:00:00 2001 From: Chrisbr Date: Thu, 15 May 2014 13:20:17 +0200 Subject: [PATCH] Implements tracks feature test --- spec/features/tracks_spec.rb | 60 ++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 spec/features/tracks_spec.rb diff --git a/spec/features/tracks_spec.rb b/spec/features/tracks_spec.rb new file mode 100644 index 00000000..b1ff4925 --- /dev/null +++ b/spec/features/tracks_spec.rb @@ -0,0 +1,60 @@ +require 'spec_helper' + +feature Track do + # It is necessary to use bang version of let to build roles before user + let!(:organizer_role) { create(:organizer_role) } + let!(:participant_role) { create(:participant_role) } + let!(:admin_role) { create(:admin_role) } + + shared_examples 'tracks' do |user| + scenario 'adds and updates tracks', feature: true, js: true do + conference = create(:conference) + sign_in create(user) + visit admin_conference_tracks_path( + conference_id: conference.short_title) + + # Add track + click_link 'Add track' + expect(page.all('div.nested-fields').count == 1).to be true + + page. + find('div.nested-fields:nth-of-type(1) div:nth-of-type(1) input'). + set('Example track') + page. + find('div.nested-fields:nth-of-type(1) div:nth-of-type(2) input'). + set('#ff0000') + page. + find('div.nested-fields:nth-of-type(1) div:nth-of-type(3) textarea'). + set('Example room description') + + click_button 'Update Conference' + + # Validations + expect(flash).to eq('Tracks were successfully updated.') + expect( + find('div.nested-fields:nth-of-type(1) div:nth-of-type(1) input'). + value).to eq('Example track') + expect( + find('div.nested-fields:nth-of-type(1) div:nth-of-type(2) input'). + value).to eq('#ff0000') + expect( + find('div.nested-fields:nth-of-type(1) div:nth-of-type(3) textarea'). + value).to eq('Example room description') + + # Remove track + click_link 'Remove track' + expect(page.all('div.nested-fields').count == 0).to be true + click_button 'Update Conference' + expect(flash).to eq('Tracks were successfully updated.') + expect(page.all('div.nested-fields').count == 0).to be true + end + end + + describe 'admin' do + it_behaves_like 'tracks', :admin + end + + describe 'organizer' do + it_behaves_like 'tracks', :organizer + end +end