59 lines
1.7 KiB
Ruby
59 lines
1.7 KiB
Ruby
|
|
step "there is no user information stored in the local storage" do
|
|
visit '/'
|
|
page.execute_script %|Qstorage = window.localStorage|
|
|
page.evaluate_script(%|Qstorage.getItem('user_id')|).should be_blank
|
|
page.evaluate_script(%|Qstorage.getItem('auth_token')|).should be_blank
|
|
end
|
|
|
|
step "I visit the user obtain token path" do
|
|
visit user_root_path # obtain token through ember application
|
|
end
|
|
|
|
step "there is a user" do
|
|
@user ||= create :user
|
|
end
|
|
|
|
step "there is a facebook user" do
|
|
if @user
|
|
raise "There already is a user, but not a facebook user"
|
|
else
|
|
@user ||= create :user, provider: 'facebook', uid: '123456790' # uid from spec_helper oauth setup
|
|
end
|
|
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
|
|
visit destroy_user_session_path
|
|
end
|
|
|
|
step "I should be signed in as a user through facebook" do
|
|
@user = User.find_by_oauth_token 'fbAuthToken234'
|
|
# 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 'there is another signed in user user' do
|
|
Capybara.session_name = :other_user
|
|
step 'there is another user'
|
|
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'
|
|
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
|
|
end
|
|
|
|
step "the user authentication token changes" do
|
|
@user ||= User.first
|
|
@user.reset_authentication_token!
|
|
@user.reload
|
|
end
|