diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 3fa634898..280dd0c4d 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -82,9 +82,7 @@ class ApplicationController < ActionController::Base end def ensure_signup_complete - if user_signed_in? && - current_user.registering_with_oauth && - %w(finish_signup do_finish_signup).exclude?(action_name) + if user_signed_in? && !devise_controller? && current_user.registering_with_oauth redirect_to finish_signup_path end end diff --git a/app/views/users/registrations/finish_signup.html.erb b/app/views/users/registrations/finish_signup.html.erb index 5542ed6c3..7d034e90f 100644 --- a/app/views/users/registrations/finish_signup.html.erb +++ b/app/views/users/registrations/finish_signup.html.erb @@ -16,4 +16,7 @@ <% end %> <%= f.submit t("devise_views.users.registrations.new.submit"), class: 'button radius expand' %> +
+ <%= link_to t("devise_views.users.registrations.new.cancel"), destroy_user_session_path, class: 'delete', method: :delete %> +
<% end %> diff --git a/config/locales/devise_views.en.yml b/config/locales/devise_views.en.yml index 2cb15ffef..8253a7ccc 100755 --- a/config/locales/devise_views.en.yml +++ b/config/locales/devise_views.en.yml @@ -107,6 +107,7 @@ en: update_submit: Update waiting_for: 'Awaiting confirmation of:' new: + cancel: Cancel login email_label: Email organization_signup: Do you represent an organisation or collective? %{signup_link} organization_signup_link: Sign up here diff --git a/config/locales/devise_views.es.yml b/config/locales/devise_views.es.yml index 51dd9b452..b203040c6 100644 --- a/config/locales/devise_views.es.yml +++ b/config/locales/devise_views.es.yml @@ -107,6 +107,7 @@ es: update_submit: Actualizar waiting_for: 'Esperando confirmación de:' new: + cancel: Cancelar login email_label: Email organization_signup: "¿Representas a una organización / colectivo? %{signup_link}" organization_signup_link: Regístrate aquí diff --git a/spec/features/users_auth_spec.rb b/spec/features/users_auth_spec.rb index 3526ce97c..a1c9374be 100644 --- a/spec/features/users_auth_spec.rb +++ b/spec/features/users_auth_spec.rb @@ -125,6 +125,21 @@ feature 'Users' do 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) diff --git a/spec/support/common_actions.rb b/spec/support/common_actions.rb index f9331d328..ab6adcbd8 100644 --- a/spec/support/common_actions.rb +++ b/spec/support/common_actions.rb @@ -116,6 +116,10 @@ module CommonActions 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("-")