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

63 lines
1.8 KiB
Ruby
Raw Normal View History

2019-07-31 22:56:46 +05:30
# frozen_string_literal: true
2016-06-22 15:30:34 +05:30
require 'spec_helper'
2020-06-23 00:09:42 +05:30
RSpec.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-15 15:39:39 +05:30
delete :unlink, params: { provider: 'github' }
2016-06-22 15:30:34 +05:30
2020-03-13 15:44:24 +05:30
expect(response).to have_gitlab_http_status(:not_found)
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-15 15:39:39 +05:30
delete :unlink, params: { provider: provider.to_s }
2017-08-17 22:00:37 +05:30
2020-03-13 15:44:24 +05:30
expect(response).to have_gitlab_http_status(:found)
2017-08-17 22:00:37 +05:30
expect(user.reload.identities).to include(identity)
end
end
end
2022-06-21 17:19:12 +05:30
[:twitter, :facebook, :google_oauth2, :gitlab, :github, :bitbucket, :crowd, :auth0, :authentiq, :dingtalk, :alicloud].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-15 15:39:39 +05:30
delete :unlink, params: { provider: provider.to_s }
2016-06-22 15:30:34 +05:30
2020-03-13 15:44:24 +05:30
expect(response).to have_gitlab_http_status(:found)
2017-08-17 22:00:37 +05:30
expect(user.reload.identities).not_to include(identity)
end
end
end
2020-11-24 15:15:51 +05:30
describe 'atlassian_oauth2 provider' do
let(:user) { create(:atlassian_user) }
it 'allows a user to unlink a connected account' do
expect(user.atlassian_identity).not_to be_nil
delete :unlink, params: { provider: 'atlassian_oauth2' }
expect(response).to have_gitlab_http_status(:found)
expect(user.reload.atlassian_identity).to be_nil
end
end
2016-06-22 15:30:34 +05:30
end
end