debian-mirror-gitlab/spec/controllers/profiles/accounts_controller_spec.rb

48 lines
1.4 KiB
Ruby
Raw Normal View History

2016-06-22 15:30:34 +05:30
require 'spec_helper'
describe Profiles::AccountsController do
2017-08-17 22:00:37 +05:30
describe 'DELETE unlink' do
let(:user) { create(:omniauth_user) }
2016-06-22 15:30:34 +05:30
2017-08-17 22:00:37 +05:30
before do
sign_in(user)
end
2016-06-22 15:30:34 +05:30
2017-08-17 22:00:37 +05:30
it 'renders 404 if someone tries to unlink a non existent provider' do
2019-02-13 22:33:31 +05:30
delete :unlink, params: { provider: 'github' }
2016-06-22 15:30:34 +05:30
2018-03-17 18:26:18 +05:30
expect(response).to have_gitlab_http_status(404)
2017-08-17 22:00:37 +05:30
end
[:saml, :cas3].each do |provider|
describe "#{provider} provider" do
let(:user) { create(:omniauth_user, provider: provider.to_s) }
it "does not allow to unlink connected account" do
identity = user.identities.last
2019-02-13 22:33:31 +05:30
delete :unlink, params: { provider: provider.to_s }
2017-08-17 22:00:37 +05:30
2018-03-17 18:26:18 +05:30
expect(response).to have_gitlab_http_status(302)
2017-08-17 22:00:37 +05:30
expect(user.reload.identities).to include(identity)
end
end
end
2017-09-10 17:25:29 +05:30
[:twitter, :facebook, :google_oauth2, :gitlab, :github, :bitbucket, :crowd, :auth0, :authentiq].each do |provider|
2017-08-17 22:00:37 +05:30
describe "#{provider} provider" do
let(:user) { create(:omniauth_user, provider: provider.to_s) }
it 'allows to unlink connected account' do
identity = user.identities.last
2016-06-22 15:30:34 +05:30
2019-02-13 22:33:31 +05:30
delete :unlink, params: { provider: provider.to_s }
2016-06-22 15:30:34 +05:30
2018-03-17 18:26:18 +05:30
expect(response).to have_gitlab_http_status(302)
2017-08-17 22:00:37 +05:30
expect(user.reload.identities).not_to include(identity)
end
end
end
2016-06-22 15:30:34 +05:30
end
end