summaryrefslogtreecommitdiffstats
path: root/spec
diff options
context:
space:
mode:
Diffstat (limited to 'spec')
-rw-r--r--spec/features/register_band_spec.rb78
1 files changed, 38 insertions, 40 deletions
diff --git a/spec/features/register_band_spec.rb b/spec/features/register_band_spec.rb
index fd8b08a..8970137 100644
--- a/spec/features/register_band_spec.rb
+++ b/spec/features/register_band_spec.rb
@@ -1,56 +1,54 @@
require 'spec_helper'
-feature "Registration form" do
+feature "Submit registration form" do
background do
visit '/'
@band_params = create_band_params
end
- scenario "displays thank you page when registration is successful", js: true do
- fill_in 'Bandnavn:', with: @band_params['name']
- fill_in 'Hjemsted:', with: @band_params['city']
- fill_in 'Webside:', with: @band_params['website']
- fill_in 'Plateselskap:', with: @band_params['label']
- fill_in 'Kort bio:', with: @band_params['shortbio']
-
- within '#form-contact-info' do
- fill_in 'Navn:', with: @band_params['contact']['name']
- fill_in 'Postadresse:', with: @band_params['contact']['addr']
- fill_in 'Tlf:', with: @band_params['contact']['phone']
- fill_in 'E-post:', with: @band_params['contact']['email']
- end
+ context "with all fields filled in" do
+ scenario "displays thank you page", js: true do
+ fill_in_form_with(@band_params)
- click_on 'Legg til medlem'
+ expect(page).to have_content "Takk for at du vil være med på Norsk Urskog"
- within '#form-members .member-info' do
- fill_in 'Navn:', with: @band_params['members']['1']['name']
+ expect(page).to have_content "Bandnavn: #{@band_params['name']}"
+ expect(page).to have_content "Hjemsted: #{@band_params['city']}"
+ expect(page).to have_content "Webside: #{@band_params['website']}"
+ expect(page).to have_content "Plateselskap: #{@band_params['label']}"
+ expect(page).to have_content "Kort bio: #{@band_params['shortbio']}"
end
+ end
- click_on 'Legg til låt'
-
- within '#form-songs #song-1-info' do
- fill_in 'Tittel:', with: @band_params['songs']['1']['title']
- fill_in 'Lengde:', with: @band_params['songs']['1']['time']
- fill_in 'ISRC-kode:', with: @band_params['songs']['1']['isrc']
- fill_in 'Utøvere:', with: @band_params['songs']['1']['performers']
- fill_in 'Opphavsmenn:', with: @band_params['songs']['1']['composers']
- fill_in 'Andre merknader:', with: @band_params['songs']['1']['notes']
+ context "with no data" do
+ scenario "gives error message, and redisplays form" do
+ click_on 'Send skjema'
+ expect(page).to have_content "Det er feil i skjemaet"
+ expect(page).to have_content "Påmeldingsskjema for Band"
end
-
- click_on 'Send skjema'
-
- expect(page).to have_content "Takk for at du vil være med på Norsk Urskog"
-
- expect(page).to have_content "Bandnavn: #{@band_params['name']}"
- expect(page).to have_content "Hjemsted: #{@band_params['city']}"
- expect(page).to have_content "Webside: #{@band_params['website']}"
- expect(page).to have_content "Plateselskap: #{@band_params['label']}"
- expect(page).to have_content "Kort bio: #{@band_params['shortbio']}"
end
- scenario "submitting form with no data gives error message, and redisplays form" do
- click_on 'Send skjema'
- expect(page).to have_content "Det er feil i skjemaet"
- expect(page).to have_current_path "/"
+ context "with invalid data" do
+ scenario "retains submitted data in form", js: true do
+ @band_params['songs'] = nil
+ fill_in_form_with(@band_params)
+
+ expect(find_field('Bandnavn:').value).to eql(@band_params['name'])
+ expect(find_field('Hjemsted:').value).to eql(@band_params['city'])
+ expect(find_field('Webside:').value).to eql(@band_params['website'])
+ expect(find_field('Plateselskap:').value).to eql(@band_params['label'])
+ expect(find_field('Kort bio:').value).to eql(@band_params['shortbio'])
+
+ within ('#form-contact-info') do
+ expect(find_field('Navn:').value).to eql(@band_params['contact']['name'])
+ expect(find_field('Postadresse:').value).to eql(@band_params['contact']['addr'])
+ expect(find_field('Tlf:').value).to eql(@band_params['contact']['phone'])
+ expect(find_field('E-post:').value).to eql(@band_params['contact']['email'])
+ end
+
+ within '#form-members .member-info' do
+ expect(find_field('Navn:').value).to eql(params['members']['1']['name'])
+ end
+ end
end
end