aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGareth Rees <gareth@mysociety.org>2015-01-06 17:11:20 +0000
committerGareth Rees <gareth@mysociety.org>2015-01-06 17:11:37 +0000
commitc3b00a9f523df5fd0b648e716bd1347e68bc1230 (patch)
tree4fffdc15a5a398a275523cdb735f0ad062200a71
parenta081a555d85a63684fb932a1fa025bda12ca7715 (diff)
Scope AlaveteliDsl#login fields within signup_form
Fills in the first “Your e-mail:” field it finds, which could be the sign _up_ form if the view is overridden to swap the order of the sign in and sign up forms. Also compacts a simple conditional on to one line.
-rw-r--r--spec/integration/alaveteli_dsl.rb17
1 files changed, 9 insertions, 8 deletions
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