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