2017-07-10 13:19:59 -04:00
|
|
|
|
|
|
|
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
|
2017-07-17 12:53:32 -04:00
|
|
|
CHANNEL_PARAMETERS = []
|
2017-07-13 15:50:45 -04:00
|
|
|
|
2017-07-10 13:19:59 -04:00
|
|
|
@@sent_messages = []
|
|
|
|
@@raise_exception = nil
|
|
|
|
|
|
|
|
def self.trigger_notification(post, channel)
|
|
|
|
if @@raise_exception
|
|
|
|
raise @@raise_exception
|
|
|
|
end
|
|
|
|
@@sent_messages.push(post: post.id, channel: channel)
|
|
|
|
end
|
|
|
|
|
|
|
|
def self.sent_messages
|
|
|
|
@@sent_messages
|
|
|
|
end
|
|
|
|
|
2017-07-13 16:47:15 -04:00
|
|
|
def self.sent_to_channel_ids
|
|
|
|
@@sent_messages.map{|x| x[:channel].id}
|
|
|
|
end
|
|
|
|
|
2017-07-10 13:19:59 -04:00
|
|
|
def self.set_raise_exception(bool)
|
|
|
|
@@raise_exception = bool
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
let(:provider){::DiscourseChat::Provider::DummyProvider}
|
2017-07-13 15:50:45 -04:00
|
|
|
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
|
2017-07-17 12:53:32 -04:00
|
|
|
CHANNEL_PARAMETERS = [
|
2017-07-18 13:23:20 -04:00
|
|
|
{key: "val", regex: '^\S+$'}
|
2017-07-17 12:53:32 -04:00
|
|
|
]
|
2017-07-13 15:50:45 -04:00
|
|
|
|
|
|
|
@@sent_messages = []
|
|
|
|
|
|
|
|
def self.trigger_notification(post, channel)
|
|
|
|
@@sent_messages.push(post: post.id, channel: channel)
|
|
|
|
end
|
|
|
|
|
|
|
|
def self.sent_messages
|
|
|
|
@@sent_messages
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
let(:provider){::DiscourseChat::Provider::DummyProvider}
|
2017-07-10 13:19:59 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
RSpec.configure do |rspec|
|
|
|
|
rspec.include_context "dummy provider"
|
2017-07-13 15:50:45 -04:00
|
|
|
rspec.include_context "validated dummy provider"
|
|
|
|
|
2017-07-10 13:19:59 -04:00
|
|
|
end
|