2019-04-15 06:17:05 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-06-14 19:28:17 -04:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe Profiles::AccountsController do
|
2017-03-28 06:33:51 -04:00
|
|
|
describe 'DELETE unlink' do
|
|
|
|
let(:user) { create(:omniauth_user) }
|
2016-06-14 19:28:17 -04:00
|
|
|
|
2017-03-28 06:33:51 -04:00
|
|
|
before do
|
|
|
|
sign_in(user)
|
|
|
|
end
|
2016-06-14 19:28:17 -04:00
|
|
|
|
2017-03-28 06:33:51 -04:00
|
|
|
it 'renders 404 if someone tries to unlink a non existent provider' do
|
2018-12-17 17:52:17 -05:00
|
|
|
delete :unlink, params: { provider: 'github' }
|
2016-06-14 19:28:17 -04:00
|
|
|
|
2017-10-19 14:28:19 -04:00
|
|
|
expect(response).to have_gitlab_http_status(404)
|
2017-03-28 06:33:51 -04:00
|
|
|
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
|
|
|
|
|
2018-12-17 17:52:17 -05:00
|
|
|
delete :unlink, params: { provider: provider.to_s }
|
2017-03-28 06:33:51 -04:00
|
|
|
|
2017-10-19 14:28:19 -04:00
|
|
|
expect(response).to have_gitlab_http_status(302)
|
2017-03-28 06:33:51 -04:00
|
|
|
expect(user.reload.identities).to include(identity)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2017-07-17 08:16:49 -04:00
|
|
|
[:twitter, :facebook, :google_oauth2, :gitlab, :github, :bitbucket, :crowd, :auth0, :authentiq].each do |provider|
|
2017-03-28 06:33:51 -04:00
|
|
|
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-14 19:28:17 -04:00
|
|
|
|
2018-12-17 17:52:17 -05:00
|
|
|
delete :unlink, params: { provider: provider.to_s }
|
2016-06-14 19:28:17 -04:00
|
|
|
|
2017-10-19 14:28:19 -04:00
|
|
|
expect(response).to have_gitlab_http_status(302)
|
2017-03-28 06:33:51 -04:00
|
|
|
expect(user.reload.identities).not_to include(identity)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2016-06-14 19:28:17 -04:00
|
|
|
end
|
2016-06-14 19:37:22 -04:00
|
|
|
end
|