Skip to content

Commit

Permalink
Merge pull request consuldemocracy#33 from AyuntamientoMadrid/refacto…
Browse files Browse the repository at this point in the history
…r-omniauth-cancel

refactors cancel login link
  • Loading branch information
xuanxu committed Feb 2, 2016
2 parents 67cef54 + 82d62bf commit 2ebbc5e
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
4 changes: 1 addition & 3 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,7 @@ def set_comment_flags(comments)
end

def ensure_signup_complete
if user_signed_in? &&
current_user.registering_with_oauth &&
%w(finish_signup do_finish_signup destroy).exclude?(action_name)
if user_signed_in? && !devise_controller? && current_user.registering_with_oauth
redirect_to finish_signup_path
end
end
Expand Down
15 changes: 15 additions & 0 deletions spec/features/users_auth_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,21 @@
expect(page).to have_field('user_email', with: 'manueladelascarmenas@example.com')
end

scenario 'Cancelling signup' do
OmniAuth.config.add_mock(:twitter, twitter_hash)

visit '/'
click_link 'Register'
click_link 'Sign up with Twitter'

expect(current_path).to eq(finish_signup_path)
click_link 'Cancel login'


visit '/'
expect_to_not_be_signed_in
end

scenario 'Sign in, user was already signed up with OAuth' do
user = create(:user, email: 'manuela@madrid.es', password: 'judgementday')
create(:identity, uid: '12345', provider: 'twitter', user: user)
Expand Down
4 changes: 4 additions & 0 deletions spec/support/common_actions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,10 @@ def expect_to_be_signed_in
expect(find('.top-bar')).to have_content 'My account'
end

def expect_to_not_be_signed_in
expect(find('.top-bar')).to_not have_content 'My account'
end

def select_date(values, selector)
selector = selector[:from]
day, month, year = values.split("-")
Expand Down

0 comments on commit 2ebbc5e

Please sign in to comment.