summaryrefslogtreecommitdiffstats
path: root/spec/support/submit_form_helper.rb
blob: 80d06bf9a018000f328e0d414daeac886959c64e (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
module SubmitFormHelper
  def fill_in_form_with(params)
    fill_in 'Bandnavn:', with: params['name']
    fill_in 'Hjemsted:', with: params['city']
    fill_in 'Webside:', with: params['website']
    fill_in 'Plateselskap:', with: params['label']
    fill_in 'Kort bio:', with: params['shortbio']

    within '#form-contact-info' do
      fill_in 'Navn:', with: params['contact']['name']
      fill_in 'Postadresse:', with: params['contact']['addr']
      fill_in 'Tlf:', with: params['contact']['phone']
      fill_in 'E-post:', with: params['contact']['email']
    end

    click_on 'Legg til medlem'

    within '#form-members .member-info' do
      fill_in 'Navn:', with: params['members']['1']['name']
      fill_in 'Instrument:', with: params['members']['1']['instrument']
      fill_in 'Alder:', with: params['members']['1']['age']
    end

    if params['songs']
      click_on 'Legg til låt'

      within '#form-songs #song-1-info' do
        fill_in 'Tittel:', with: params['songs']['1']['title']
        fill_in 'Lengde:', with: params['songs']['1']['time']
        fill_in 'ISRC-kode:', with: params['songs']['1']['isrc']
        fill_in 'Utøvere:', with: params['songs']['1']['performers']
        fill_in 'Opphavsmenn:', with: params['songs']['1']['composers']
        fill_in 'Andre merknader:', with: params['songs']['1']['notes']
      end
    end

    click_on 'Send skjema'
  end
end