Green user sign in flow

This commit is contained in:
2014-12-24 09:34:05 +01:00
parent a30b17648d
commit 4faee9aa6e
6 changed files with 126 additions and 37 deletions
@@ -21,17 +21,45 @@ step "there is a facebook user" do
@user ||= create :user, provider: 'facebook', uid: '123456790' # uid from spec_helper oauth setup
end
end
step "there is a instagram user" do
if @user
raise "There already is a user, but not a instagram user"
else
@user ||= create :user, provider: 'instagram', uid: '123498765' # uid from spec_helper oauth setup
end
end
step "the user is redirected to the sign in page" do
ember_route_should_be '/sign_in'
end
step "I am signed in as a user" do
step "there is a user"
visit test_login_admin_users_path(email: @user.email)
end
step "I am signed out as a user" do
step "the user clicks the sign in via facebook button" do
find('.sign-in-button.facebook').click
end
step "the user clicks the sign in via instagram button" do
find('.sign-in-button.instagram').click
end
step "the user has no active session" do
visit destroy_user_session_path
end
step "I should be signed in as a user through facebook" do
step "the user should be signed in as the facebook user" do
@user = User.find_by_oauth_token 'fbAuthToken234'
@user.should be_present
# For now, actually better to test a signed in response from the server
step "the newly created user info should be stored in the local storage"
end
step "the user should be signed in as the instagram user" do
@user = User.find_by_oauth_token 'igAuthToken234'
@user.should be_present
# For now, actually better to test a signed in response from the server
step "the newly created user info should be stored in the local storage"
end
@@ -42,13 +70,24 @@ step 'there is another signed in user user' do
visit test_login_admin_users_path(email: @other_user.email)
end
step "I should be redirected to the user home" do
route_should_be 'user#index'
step "the user should be redirected to the homepage" do
ember_route_should_be '/'
end
step "the newly created user info should be stored in the local storage" do
page.evaluate_script(%|Qstorage.getItem('user_id')|).should == @user.id
page.evaluate_script(%|Qstorage.getItem('auth_token')|).should == @user.authentication_token
max_wait = 4
time = 0.0
time_step = 0.25
user_id = page.evaluate_script(%|Qstorage.getItem('user_id')|)
auth_token = page.evaluate_script(%|Qstorage.getItem('auth_token')|)
while time < max_wait && user_id != @user.id && auth_token != @user.authentication_token
time += time_step
sleep time_step
user_id = page.evaluate_script(%|Qstorage.getItem('user_id')|)
auth_token = page.evaluate_script(%|Qstorage.getItem('auth_token')|)
end
user_id.should == @user.id
auth_token.should == @user.authentication_token
end
step "the user authentication token changes" do