Only load dummy providers in specs where they are required
This commit is contained in:
parent
142687f4d4
commit
04c711e438
|
@ -11,6 +11,7 @@ describe 'Chat Controller', type: :request do
|
|||
let(:channel) { DiscourseChat::Channel.create(provider:'dummy') }
|
||||
|
||||
include_context "dummy provider"
|
||||
include_context "validated dummy provider"
|
||||
|
||||
before do
|
||||
SiteSetting.chat_integration_enabled = true
|
||||
|
@ -48,7 +49,7 @@ describe 'Chat Controller', type: :request do
|
|||
|
||||
expect(json['providers'].size).to eq(2)
|
||||
|
||||
expect(json['providers'][0]).to eq('name'=> 'dummy',
|
||||
expect(json['providers'].find{|h| h['name']=='dummy'}).to eq('name'=> 'dummy',
|
||||
'id'=> 'dummy',
|
||||
'channel_parameters'=> []
|
||||
)
|
||||
|
|
|
@ -1,10 +1,6 @@
|
|||
|
||||
RSpec.shared_context "dummy provider" do
|
||||
before(:each) do
|
||||
if defined? ::DiscourseChat::Provider::DummyProvider
|
||||
::DiscourseChat::Provider.send(:remove_const, :DummyProvider)
|
||||
end
|
||||
|
||||
module ::DiscourseChat::Provider::DummyProvider
|
||||
PROVIDER_NAME = "dummy".freeze
|
||||
PROVIDER_ENABLED_SETTING = :chat_integration_enabled # Tie to main plugin enabled setting
|
||||
|
@ -32,7 +28,10 @@ RSpec.shared_context "dummy provider" do
|
|||
@@raise_exception = bool
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
after(:each) do
|
||||
::DiscourseChat::Provider.send(:remove_const, :DummyProvider)
|
||||
end
|
||||
|
||||
let(:provider){::DiscourseChat::Provider::DummyProvider}
|
||||
|
@ -40,10 +39,6 @@ end
|
|||
|
||||
RSpec.shared_context "validated dummy provider" do
|
||||
before(:each) do
|
||||
if defined? ::DiscourseChat::Provider::Dummy2Provider
|
||||
::DiscourseChat::Provider.send(:remove_const, :Dummy2Provider)
|
||||
end
|
||||
|
||||
module ::DiscourseChat::Provider::Dummy2Provider
|
||||
PROVIDER_NAME = "dummy2".freeze
|
||||
PROVIDER_ENABLED_SETTING = :chat_integration_enabled # Tie to main plugin enabled setting
|
||||
|
@ -64,11 +59,7 @@ RSpec.shared_context "validated dummy provider" do
|
|||
|
||||
end
|
||||
|
||||
let(:provider){::DiscourseChat::Provider::DummyProvider}
|
||||
after(:each) do
|
||||
::DiscourseChat::Provider.send(:remove_const, :Dummy2Provider)
|
||||
end
|
||||
end
|
||||
|
||||
RSpec.configure do |rspec|
|
||||
rspec.include_context "dummy provider"
|
||||
rspec.include_context "validated dummy provider"
|
||||
|
||||
end
|
Loading…
Reference in New Issue