summaryrefslogtreecommitdiffstats
path: root/spec/support
diff options
context:
space:
mode:
authorHarald Eilertsen <haraldei@anduin.net>2015-10-15 10:11:56 +0200
committerHarald Eilertsen <haraldei@anduin.net>2015-10-28 21:32:17 +0100
commit57af2ee2e51b614ac6e2fa81b1075a55d3c0c252 (patch)
tree81731790772b47e444b8a1abb70abdec543da2dd /spec/support
parentc69ab8c2bc8dfa59070249dd434219d83a792dbc (diff)
downloadnorsk-urskog-registrations-57af2ee2e51b614ac6e2fa81b1075a55d3c0c252.tar.gz
norsk-urskog-registrations-57af2ee2e51b614ac6e2fa81b1075a55d3c0c252.tar.bz2
norsk-urskog-registrations-57af2ee2e51b614ac6e2fa81b1075a55d3c0c252.zip
Retain member and song info on errors in form.
Diffstat (limited to 'spec/support')
-rw-r--r--spec/support/band_factory.rb54
-rw-r--r--spec/support/submit_form_helper.rb2
2 files changed, 29 insertions, 27 deletions
diff --git a/spec/support/band_factory.rb b/spec/support/band_factory.rb
index 498f532..56993fa 100644
--- a/spec/support/band_factory.rb
+++ b/spec/support/band_factory.rb
@@ -3,46 +3,46 @@ module BandFactory
opts = {
:songs => 1,
:name => 'Band name',
+ :city => 'Somewhere',
+ :website => 'http://bandsite.com',
+ :label => 'A Record Label',
+ :bio => 'A short bio about the band',
:contact_name => 'Contact Name',
:contact_addr => "Streetname 666\n1234Someplace Nice",
:contact_phone => '98765432',
- :contact_email => 'band@example.com'
+ :contact_email => 'band@example.com',
+ :members => [
+ { :name => 'Member 1', :instrument => 'Instrument 1', :age => '24' },
+ { :name => 'Member 2', :instrument => 'Instrument 2', :age => '0' },
+ { :name => 'Member 3', :instrument => '', :age => '' },
+ ],
}.merge(options)
num_songs = opts.delete(:songs)
params = {
'name' => opts[:name],
- 'city' => 'Oslo',
- 'website' => 'http://imbalance.no',
- 'label' => 'Calculated Imperfection',
- 'shortbio' => 'Thrash metal from Norway',
+ 'city' => opts[:city],
+ 'website' => opts[:website],
+ 'label' => opts[:label],
+ 'shortbio' => opts[:bio],
'contact' => {
'name' => opts[:contact_name],
'addr' => opts[:contact_addr],
'phone' => opts[:contact_phone],
'email' => opts[:contact_email]
},
- 'members' => {
- '1' => {
- 'name' => 'Harald Eilertsen',
- 'instrument' => 'Bass/Vocals',
- 'age' => ''
- },
- '2' => {
- 'name' => 'Welle',
- 'instrument' => 'Drums',
- 'age' => ''
- },
- '3' => {
- 'name' => 'Thormodr',
- 'instrument' => 'Guitar',
- 'age' => ''
- }
- },
+ 'members' => {},
'songs' => {}
}
+ (1..opts[:members].length).each do |i|
+ params['members'][i.to_s] = {}
+ params['members'][i.to_s]['name'] = opts[:members][i-1][:name]
+ params['members'][i.to_s]['instrument'] = opts[:members][i-1][:instrument]
+ params['members'][i.to_s]['age'] = opts[:members][i-1][:age]
+ end
+
(1..num_songs).each do |i|
num = i.to_s
params['songs'][num] = create_song_params
@@ -53,12 +53,12 @@ module BandFactory
def create_song_params
{
- 'title' => 'Bestial by Nature',
- 'time' => '02:80',
+ 'title' => 'A song title',
+ 'time' => '02:30',
'isrc' => '',
- 'performers' => "Harald Eilertsen\nThormod Steinert\nLars Welle",
- 'composers' => "Harald Eilertsen\nThormod Steinert",
- 'notes' => 'Rævrukkje rum kjurr!'
+ 'performers' => "Performer 1\nPerformer 2\nPerformer 3",
+ 'composers' => "Composer 1\nComposer 2",
+ 'notes' => 'Some notes'
}
end
end
diff --git a/spec/support/submit_form_helper.rb b/spec/support/submit_form_helper.rb
index acccbd6..80d06bf 100644
--- a/spec/support/submit_form_helper.rb
+++ b/spec/support/submit_form_helper.rb
@@ -17,6 +17,8 @@ module SubmitFormHelper
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']