spec/features/user_spec.rb in sprangular-0.0.1 vs spec/features/user_spec.rb in sprangular-0.1.0

- old
+ new

@@ -3,11 +3,11 @@ describe "User", js: true do scenario "sign in and sign out" do user = create(:user, email: 'user@example.com', password: '123456', password_confirmation: '123456') visit sprangular_engine.root_path - wait_for_route_changes + wait_for_loading within 'header' do page.find('a', text: 'Sign in').click end @@ -37,11 +37,11 @@ expect(page).to have_text("Welcome to Sprangular") end scenario "sign up" do visit sprangular_engine.root_path - wait_for_route_changes + wait_for_loading within 'header' do page.find('a', text: 'Sign in').click end @@ -65,11 +65,11 @@ scenario "redirected to requested page after sign in" do user = create(:user, email: 'user@example.com', password: '123456', password_confirmation: '123456') visit sprangular_engine.root_path - wait_for_route_changes + wait_for_loading within 'header' do page.find('a', text: 'My Account').click end @@ -85,11 +85,11 @@ end end scenario "redirected to requested page after sign up" do visit sprangular_engine.root_path - wait_for_route_changes + wait_for_loading within 'header' do page.find('a', text: 'My Account').click end @@ -111,11 +111,11 @@ scenario "reset password" do create(:store, url: 'example.com') user = create(:user, email: 'user@example.com', password: '123456', password_confirmation: '123456') visit sprangular_engine.root_path - wait_for_route_changes + wait_for_loading within 'header' do page.find('a', text: 'Sign in').click end @@ -132,11 +132,11 @@ user = user.reload raw_token = user.send_reset_password_instructions visit sprangular_engine.root_path(anchor: "!/reset-password/#{raw_token}") - wait_for_route_changes + wait_for_loading within :css, "form[name=ResetPasswordForm]" do fill_in "password", with: "654321" fill_in "password_confirmation", with: "654321" @@ -147,7 +147,42 @@ within "header" do expect(page).to have_content("Log out") expect(page).to_not have_content("Sign in") end + end + + scenario "update account details" do + user = create(:user, email: 'user@example.com', password: '123456', password_confirmation: '123456') + + visit sprangular_engine.root_path + wait_for_loading + + within 'header' do + page.find('a', text: 'Sign in').click + end + + within :css, 'form[name=signinForm]' do + fill_in "email", with: "user@example.com" + fill_in "password", with: "123456" + + click_on "Sign in" + end + + within 'header' do + page.find('a', text: 'My Account').click + end + + page.find(:css, '#account a').click + + within :css, 'form[name=accountForm]' do + fill_in "email", with: "user2@example.com" + fill_in "password", with: "123456" + fill_in "password_confirmation", with: "123456" + + click_on "Update" + end + + user.reload + expect(user.email).to eql("user2@example.com") end end