Commit 8c2b72b1 authored by Andrei Gliga's avatar Andrei Gliga
Browse files

tests for enabled_button_based_providers helper method of AuthHelper

parent fee2f626ec4a
......@@ -2,7 +2,9 @@
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 @@
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
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment