# Band registration form for Norsk Urskog Metal Sampler # Copyright (C) 2015-2018 Harald Eilersen # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . require 'spec_helper' feature "Submit registration form" do background do Capybara.app.set :accept_registrations, { start: Date.today.iso8601, stop: (Date.today + 1).iso8601 } visit '/' @band_params = create_band_params end context "with all fields filled in" do scenario "displays thank you page" do fill_in_form_with(@band_params) 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 end 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 end context "with invalid data" do scenario "retains submitted data in form" do @band_params['name'] = "" 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']) expect(find_field('Medlemmer:').value.gsub("\r\n", "\n")).to eql(@band_params['members']) within ('#form-contact-info') do expect(find_field('Navn:').value).to eql(@band_params['contact']['name']) expect(find_field('Adresse:').value).to eql(@band_params['contact']['street']) expect(find_field('Postnr:').value).to eql(@band_params['contact']['postcode']) expect(find_field('Sted:').value).to eql(@band_params['contact']['city']) 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-songs #song-1-info' do expect(find_field('Låttittel:').value).to eql(@band_params['songs']['1']['title']) expect(find_field('Lengde:').value).to eql(@band_params['songs']['1']['time']) expect(find_field('ISRC-kode:').value).to eql(@band_params['songs']['1']['isrc']) expect(find_field('Utøvere:').value.gsub("\r\n", "\n")).to eql(@band_params['songs']['1']['performers']) expect(find_field('Opphavsmenn:').value.gsub("\r\n", "\n")).to eql(@band_params['songs']['1']['composers']) expect(find_field('Andre merknader:').value).to eql(@band_params['songs']['1']['notes']) end end end end