summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHarald Eilertsen <haraldei@anduin.net>2016-08-16 22:36:34 +0200
committerHarald Eilertsen <haraldei@anduin.net>2016-08-16 22:36:34 +0200
commitc3316a339c0f62d8b19fe7c2c1a9f23e9651bd55 (patch)
tree1900bd2138dbdb1c6d4103fc5ef0aaa2d2dce37e
parent9594f5be7daa673b88654e0f47db07d1c1454765 (diff)
downloadnorsk-urskog-registrations-c3316a339c0f62d8b19fe7c2c1a9f23e9651bd55.tar.gz
norsk-urskog-registrations-c3316a339c0f62d8b19fe7c2c1a9f23e9651bd55.tar.bz2
norsk-urskog-registrations-c3316a339c0f62d8b19fe7c2c1a9f23e9651bd55.zip
Redirect to registrations closed message instead of modifying body.
-rw-r--r--registration.rb8
-rw-r--r--spec/registration_spec.rb14
2 files changed, 12 insertions, 10 deletions
diff --git a/registration.rb b/registration.rb
index f7a31b0..da11e4e 100644
--- a/registration.rb
+++ b/registration.rb
@@ -14,9 +14,7 @@ class RegistrationApp < Sinatra::Base
config_file File.join(settings.root, 'config.yml')
before do
- if !accept_registrations(settings)
- halt erb :registration_closed
- end
+ redirect to('/registrations_closed') unless accept_registrations(settings)
end
get '/' do
@@ -25,6 +23,10 @@ class RegistrationApp < Sinatra::Base
erb :index
end
+ get '/registrations_closed' do
+ erb :registration_closed
+ end
+
post '/submit' do
if request.form_data?
@band = Band.new(request['band'])
diff --git a/spec/registration_spec.rb b/spec/registration_spec.rb
index 4dd57d5..95ed6a0 100644
--- a/spec/registration_spec.rb
+++ b/spec/registration_spec.rb
@@ -42,12 +42,10 @@ describe RegistrationApp do
get '/'
end
- it 'should succeed' do
- expect(last_response).to be_ok
- end
-
- it 'displays message that registration is closed' do
- expect(last_response.body).to match(/Registreringen er stengt/)
+ it 'should redirect to registrations closed page' do
+ expect(last_response).to be_redirect
+ follow_redirect!
+ expect(last_response.location).to match '/registrations_closed'
end
end
end
@@ -183,7 +181,9 @@ describe RegistrationApp do
end
it 'redirects to registration closed message' do
- expect(last_response.body).to match('Registreringen er stengt')
+ expect(last_response).to be_redirect
+ follow_redirect!
+ expect(last_response.location).to match '/registrations_closed'
end
end
end