summaryrefslogtreecommitdiffstats
path: root/spec/features/register_band_spec.rb
blob: fd8b08a351974c1590998ad43367f9b2fe3c135e (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
require 'spec_helper'

feature "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

    click_on 'Legg til medlem'

    within '#form-members .member-info' do
      fill_in 'Navn:', with: @band_params['members']['1']['name']
    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']
    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 "/"
  end
end