summaryrefslogtreecommitdiffstats
path: root/spec
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
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')
-rw-r--r--spec/features/register_band_spec.rb13
-rw-r--r--spec/registration_spec.rb24
-rw-r--r--spec/support/band_factory.rb54
-rw-r--r--spec/support/submit_form_helper.rb2
4 files changed, 53 insertions, 40 deletions
diff --git a/spec/features/register_band_spec.rb b/spec/features/register_band_spec.rb
index 92bf9d3..625cb20 100644
--- a/spec/features/register_band_spec.rb
+++ b/spec/features/register_band_spec.rb
@@ -30,7 +30,7 @@ feature "Submit registration form" do
context "with invalid data" do
scenario "retains submitted data in form", js: true do
- @band_params['songs'] = nil
+ @band_params['name'] = ""
fill_in_form_with(@band_params)
expect(find_field('Bandnavn:').value).to eql(@band_params['name'])
@@ -48,6 +48,17 @@ feature "Submit registration form" do
within '#form-members .member-info' do
expect(find_field('Navn:').value).to eql(@band_params['members']['1']['name'])
+ expect(find_field('Instrument:').value).to eql(@band_params['members']['1']['instrument'])
+ expect(find_field('Alder:').value).to eql(@band_params['members']['1']['age'])
+ end
+
+ within '#form-songs #song-1-info' do
+ expect(find_field('Tittel:').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
diff --git a/spec/registration_spec.rb b/spec/registration_spec.rb
index 89e2fa5..7e4ca3a 100644
--- a/spec/registration_spec.rb
+++ b/spec/registration_spec.rb
@@ -53,25 +53,25 @@ describe RegistrationApp do
it 'displays submitted data to user' do
expect(last_response).to match(/Bandnavn\: #{band_params['name']}/)
- expect(last_response).to match(/Hjemsted\: Oslo/)
- expect(last_response).to match(/Webside\: http\:\/\/imbalance.no/)
- expect(last_response).to match(/Plateselskap\: Calculated Imperfection/)
- expect(last_response).to match(/Kort bio\: Thrash metal from Norway/)
+ expect(last_response).to match(/Hjemsted\: #{band_params['city']}/)
+ expect(last_response).to match(/Webside\: #{band_params['website']}/)
+ expect(last_response).to match(/Plateselskap\: #{band_params['label']}/)
+ expect(last_response).to match(/Kort bio\: #{band_params['shortbio']}/)
expect(last_response).to match(/Kontaktperson: #{band_params['contact']['name']}/)
expect(last_response).to match(/Kontaktadresse: #{band_params['contact']['addr']}/)
expect(last_response).to match(/Telefon: #{band_params['contact']['phone']}/)
expect(last_response).to match(/Epost: #{band_params['contact']['email']}/)
- expect(last_response).to match(/Harald Eilertsen, Bass\/Vocals/)
- expect(last_response).to match(/Welle, Drums/)
- expect(last_response).to match(/Thormodr, Guitar/)
+ expect(last_response).to match(/#{band_params['members']['1']['name']}, #{band_params['members']['1']['instrument']}/)
+ expect(last_response).to match(/#{band_params['members']['2']['name']}, #{band_params['members']['2']['instrument']}/)
+ expect(last_response).to match(/#{band_params['members']['3']['name']}, #{band_params['members']['3']['instrument']}/)
- expect(last_response).to match(/Bestial by Nature/)
- expect(last_response).to match(/Spilletid: 02:80/)
- expect(last_response).to match(/Utøvere: Harald Eilertsen, Thormod Steinert, Lars Welle/)
- expect(last_response).to match(/Låtskrivere: Harald Eilertsen, Thormod Steinert/)
- expect(last_response).to match(/Merknad: Rævrukkje rum kjurr!/)
+ expect(last_response).to match(/#{band_params['songs']['1']['title']}/)
+ expect(last_response).to match(/Spilletid: #{band_params['songs']['1']['time']}/)
+ expect(last_response).to match(/Utøvere: #{band_params['songs']['1']['performers'].split("\n").join(", ")}/)
+ expect(last_response).to match(/Låtskrivere: #{band_params['songs']['1']['composers'].split("\n").join(", ")}/)
+ expect(last_response).to match(/Merknad: #{band_params['songs']['1']['notes']}/)
end
it "generates a PDF file" do
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']