summaryrefslogtreecommitdiffstats
path: root/spec/features/register_band_spec.rb
blob: a2bd4549479d726f973a6e680c3b6a1f559204bb (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
require 'spec_helper'

feature "Submit registration form" do
  background do
    visit '/'
    @band_params = create_band_params
  end

  context "with all fields filled in" do
    scenario "displays thank you page", js: true 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", js: true 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).to eql(@band_params['members'])

      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-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).to eql(@band_params['songs']['1']['performers'])
        expect(find_field('Opphavsmenn:').value).to eql(@band_params['songs']['1']['composers'])
        expect(find_field('Andre merknader:').value).to eql(@band_params['songs']['1']['notes'])
      end
    end
  end
end