summaryrefslogtreecommitdiff
path: root/spec/helpers/auth_helper_spec.rb
diff options
context:
space:
mode:
authorAndrei Gliga <otzy_007@yahoo.com>2016-05-04 17:04:54 +0300
committerAndrei Gliga <otzy_007@yahoo.com>2016-05-12 13:44:46 +0300
commit8c2b72b1c80e8bbd082ac8e1aedb21a1aad07235 (patch)
tree65d371526f4384b36c37b03b6eaf03d568e8a631 /spec/helpers/auth_helper_spec.rb
parent47ee5125e881694b7713f187b48589a2f4bbd747 (diff)
downloadgitlab-ce-8c2b72b1c80e8bbd082ac8e1aedb21a1aad07235.tar.gz
tests for enabled_button_based_providers helper method of AuthHelper
Diffstat (limited to 'spec/helpers/auth_helper_spec.rb')
-rw-r--r--spec/helpers/auth_helper_spec.rb22
1 files changed, 21 insertions, 1 deletions
diff --git a/spec/helpers/auth_helper_spec.rb b/spec/helpers/auth_helper_spec.rb
index e47a54fdac5..5d66c92d26e 100644
--- a/spec/helpers/auth_helper_spec.rb
+++ b/spec/helpers/auth_helper_spec.rb
@@ -2,7 +2,9 @@ require "spec_helper"
describe AuthHelper do
describe "button_based_providers" do
- it 'returns all enabled providers' do
+ let(:settings) { ApplicationSetting.create_from_defaults }
+
+ it 'returns all enabled providers from devise' do
allow(helper).to receive(:auth_providers) { [:twitter, :github] }
expect(helper.button_based_providers).to include(*[:twitter, :github])
end
@@ -16,5 +18,23 @@ describe AuthHelper do
allow(helper).to receive(:auth_providers) { [] }
expect(helper.button_based_providers).to eq([])
end
+
+ it 'returns all the enabled providers from settings' do
+ allow(helper).to receive(:auth_providers) { [:twitter, :github] }
+ expect(helper.enabled_button_based_providers).to include(*['twitter', 'github'])
+ end
+
+ it 'should not return github as provider because it\'s disabled from settings' do
+ settings.update_attribute(
+ :disabled_oauth_sign_in_sources,
+ ['github']
+ )
+
+ allow(helper).to receive(:auth_providers) { [:twitter, :github] }
+ allow(helper).to receive(:current_application_settings) { settings }
+
+ expect(helper.enabled_button_based_providers).to include('twitter')
+ expect(helper.enabled_button_based_providers).to_not include('github')
+ end
end
end