Commit fc88527c authored by Andrei Gliga's avatar Andrei Gliga

use stub_application_setting instead

parent 2e4c914a
...@@ -2,8 +2,6 @@ require "spec_helper" ...@@ -2,8 +2,6 @@ require "spec_helper"
describe AuthHelper do describe AuthHelper do
describe "button_based_providers" do describe "button_based_providers" do
let(:settings) { ApplicationSetting.create_from_defaults }
it 'returns all enabled providers from devise' do it 'returns all enabled providers from devise' do
allow(helper).to receive(:auth_providers) { [:twitter, :github] } allow(helper).to receive(:auth_providers) { [:twitter, :github] }
expect(helper.button_based_providers).to include(*[:twitter, :github]) expect(helper.button_based_providers).to include(*[:twitter, :github])
...@@ -25,13 +23,11 @@ describe AuthHelper do ...@@ -25,13 +23,11 @@ describe AuthHelper do
end end
it "should not return github as provider because it's disabled from settings" do it "should not return github as provider because it's disabled from settings" do
settings.update_attribute( stub_application_setting(
:disabled_oauth_sign_in_sources, disabled_oauth_sign_in_sources: ['github']
['github']
) )
allow(helper).to receive(:auth_providers) { [:twitter, :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 include('twitter')
expect(helper.enabled_button_based_providers).to_not include('github') expect(helper.enabled_button_based_providers).to_not include('github')
...@@ -44,13 +40,11 @@ describe AuthHelper do ...@@ -44,13 +40,11 @@ describe AuthHelper do
end end
it 'returns false for button_based_providers_enabled? because there providers' do it 'returns false for button_based_providers_enabled? because there providers' do
settings.update_attribute( stub_application_setting(
:disabled_oauth_sign_in_sources, disabled_oauth_sign_in_sources: ['github', 'twitter']
['github', 'twitter']
) )
allow(helper).to receive(:auth_providers) { [:twitter, :github] } allow(helper).to receive(:auth_providers) { [:twitter, :github] }
allow(helper).to receive(:current_application_settings) { settings }
expect(helper.button_based_providers_enabled?).to be false expect(helper.button_based_providers_enabled?).to be false
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