aboutsummaryrefslogtreecommitdiffstats
path: root/spec
diff options
context:
space:
mode:
Diffstat (limited to 'spec')
-rw-r--r--spec/controllers/request_controller_spec.rb15
-rw-r--r--spec/integration/alaveteli_dsl.rb17
2 files changed, 21 insertions, 11 deletions
diff --git a/spec/controllers/request_controller_spec.rb b/spec/controllers/request_controller_spec.rb
index 1a2992611..02237b29d 100644
--- a/spec/controllers/request_controller_spec.rb
+++ b/spec/controllers/request_controller_spec.rb
@@ -1087,6 +1087,16 @@ describe RequestController, "when creating a new request" do
response.redirect_url.should =~ /request\/why_is_your_quango_called_gerald\/new$/
end
+ it "sets the request_sent flash to true if successful" do
+ session[:user_id] = @user.id
+ post :new, :info_request => { :public_body_id => @body.id,
+ :title => "Why is your quango called Geraldine?", :tag_string => "" },
+ :outgoing_message => { :body => "This is a silly letter. It is too short to be interesting." },
+ :submitted_new_request => 1, :preview => 0
+
+ expect(flash[:request_sent]).to be_true
+ end
+
it "should give an error if the same request is submitted twice" do
session[:user_id] = @user.id
@@ -2568,10 +2578,9 @@ describe RequestController, "#new_batch" do
assigns[:existing_batch].should_not be_nil
end
- it 'should display a success notice' do
+ it 'sets the batch_sent flash to true' do
make_request
- notice_text = "<p>Your Freedom of Information requests will be <strong>sent</strong> shortly!"
- flash[:notice].should match notice_text
+ expect(flash[:batch_sent]).to be_true
end
end
diff --git a/spec/integration/alaveteli_dsl.rb b/spec/integration/alaveteli_dsl.rb
index 1d56abbdf..b408bc4c6 100644
--- a/spec/integration/alaveteli_dsl.rb
+++ b/spec/integration/alaveteli_dsl.rb
@@ -33,15 +33,16 @@ def login(user)
sess.reset!
sess.extend(AlaveteliDsl)
- if user.is_a? User
- u = user
- else
- u = users(user)
- end
+ u = user.is_a?(User) ? user : users(user)
+
sess.visit signin_path
- sess.fill_in "Your e-mail:", :with => u.email
- sess.fill_in "Password:", :with => "jonespassword"
- sess.click_button "Sign in"
+
+ sess.within '#signin_form' do
+ sess.fill_in "Your e-mail:", :with => u.email
+ sess.fill_in "Password:", :with => "jonespassword"
+ sess.click_button "Sign in"
+ end
+
assert sess.session[:user_id] == u.id
end
end