mirror of
https://github.com/discourse/discourse-chat-integration.git
synced 2025-03-09 14:35:34 +00:00
Correct rubocop offenses
This commit is contained in:
parent
4c379876b6
commit
4f9ad4efef
@ -37,7 +37,7 @@ class DiscourseChat::ChatController < ApplicationController
|
|||||||
render json: { errors: [e.message] }, status: 422
|
render json: { errors: [e.message] }, status: 422
|
||||||
rescue DiscourseChat::ProviderError => e
|
rescue DiscourseChat::ProviderError => e
|
||||||
Rails.logger.error("Test provider failed #{e.info}")
|
Rails.logger.error("Test provider failed #{e.info}")
|
||||||
if e.info.key?(:error_key) and !e.info[:error_key].nil?
|
if e.info.key?(:error_key) && !e.info[:error_key].nil?
|
||||||
render json: { error_key: e.info[:error_key] }, status: 422
|
render json: { error_key: e.info[:error_key] }, status: 422
|
||||||
else
|
else
|
||||||
render json: { errors: [e.message] }, status: 422
|
render json: { errors: [e.message] }, status: 422
|
||||||
@ -63,7 +63,7 @@ class DiscourseChat::ChatController < ApplicationController
|
|||||||
begin
|
begin
|
||||||
providers = ::DiscourseChat::Provider.enabled_providers.map { |x| x::PROVIDER_NAME }
|
providers = ::DiscourseChat::Provider.enabled_providers.map { |x| x::PROVIDER_NAME }
|
||||||
|
|
||||||
if not defined? params[:channel] and defined? params[:channel][:provider]
|
if (not defined? params[:channel]) && defined? params[:channel][:provider]
|
||||||
raise Discourse::InvalidParameters, 'Provider is not valid'
|
raise Discourse::InvalidParameters, 'Provider is not valid'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -110,7 +110,7 @@ module DiscourseChat
|
|||||||
category: category_name
|
category: category_name
|
||||||
)
|
)
|
||||||
|
|
||||||
if SiteSetting.tagging_enabled and not rule.tags.nil?
|
if SiteSetting.tagging_enabled && (not rule.tags.nil?)
|
||||||
text << I18n.t("chat_integration.provider.#{provider}.status.rule_string_tags_suffix", tags: rule.tags.join(', '))
|
text << I18n.t("chat_integration.provider.#{provider}.status.rule_string_tags_suffix", tags: rule.tags.join(', '))
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -129,7 +129,7 @@ module DiscourseChat
|
|||||||
def self.delete_by_index(channel, index)
|
def self.delete_by_index(channel, index)
|
||||||
rules = channel.rules.order_by_precedence
|
rules = channel.rules.order_by_precedence
|
||||||
|
|
||||||
return false if index < 1 or index > rules.size
|
return false if index < (1) || index > (rules.size)
|
||||||
|
|
||||||
return :deleted if rules[index - 1].destroy
|
return :deleted if rules[index - 1].destroy
|
||||||
end
|
end
|
||||||
@ -192,11 +192,10 @@ module DiscourseChat
|
|||||||
def self.save_transcript(transcript)
|
def self.save_transcript(transcript)
|
||||||
secret = SecureRandom.hex
|
secret = SecureRandom.hex
|
||||||
redis_key = "chat_integration:transcript:" + secret
|
redis_key = "chat_integration:transcript:" + secret
|
||||||
$redis.set(redis_key, transcript, {:ex => 3600}) # Expire in 1 hour
|
$redis.set(redis_key, transcript, ex: 3600) # Expire in 1 hour
|
||||||
|
|
||||||
return secret
|
return secret
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -11,11 +11,11 @@ class DiscourseChat::Rule < DiscourseChat::PluginModel
|
|||||||
self.type ||= 'normal'
|
self.type ||= 'normal'
|
||||||
end
|
end
|
||||||
|
|
||||||
validates :filter, :inclusion => { :in => %w(watch follow mute),
|
validates :filter, inclusion: { in: %w(watch follow mute),
|
||||||
:message => "%{value} is not a valid filter" }
|
message: "%{value} is not a valid filter" }
|
||||||
|
|
||||||
validates :type, :inclusion => { :in => %w(normal group_message group_mention),
|
validates :type, inclusion: { in: %w(normal group_message group_mention),
|
||||||
:message => "%{value} is not a valid filter" }
|
message: "%{value} is not a valid filter" }
|
||||||
|
|
||||||
validate :channel_valid?, :category_valid?, :group_valid?, :tags_valid?
|
validate :channel_valid?, :category_valid?, :group_valid?, :tags_valid?
|
||||||
|
|
||||||
@ -34,7 +34,7 @@ class DiscourseChat::Rule < DiscourseChat::PluginModel
|
|||||||
return unless type == 'normal'
|
return unless type == 'normal'
|
||||||
|
|
||||||
# Validate category
|
# Validate category
|
||||||
if not (category_id.nil? or Category.where(id: category_id).exists?)
|
if not (category_id.nil? || Category.where(id: category_id).exists?)
|
||||||
errors.add(:category_id, "#{category_id} is not a valid category id")
|
errors.add(:category_id, "#{category_id} is not a valid category id")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -64,7 +64,7 @@ class DiscourseChat::Rule < DiscourseChat::PluginModel
|
|||||||
|
|
||||||
# We never want an empty array, set it to nil instead
|
# We never want an empty array, set it to nil instead
|
||||||
def tags=(array)
|
def tags=(array)
|
||||||
if array.nil? or array.empty?
|
if array.nil? || array.empty?
|
||||||
super(nil)
|
super(nil)
|
||||||
else
|
else
|
||||||
super(array)
|
super(array)
|
||||||
@ -74,7 +74,7 @@ class DiscourseChat::Rule < DiscourseChat::PluginModel
|
|||||||
# These are only allowed to be integers
|
# These are only allowed to be integers
|
||||||
%w(channel_id category_id group_id).each do |name|
|
%w(channel_id category_id group_id).each do |name|
|
||||||
define_method "#{name}=" do |val|
|
define_method "#{name}=" do |val|
|
||||||
if val.nil? or val.blank?
|
if val.nil? || val.blank?
|
||||||
super(nil)
|
super(nil)
|
||||||
else
|
else
|
||||||
super(val.to_i)
|
super(val.to_i)
|
||||||
|
@ -46,7 +46,7 @@ module DiscourseChat
|
|||||||
if SiteSetting.tagging_enabled
|
if SiteSetting.tagging_enabled
|
||||||
topic_tags = topic.tags.present? ? topic.tags.pluck(:name) : []
|
topic_tags = topic.tags.present? ? topic.tags.pluck(:name) : []
|
||||||
matching_rules = matching_rules.select do |rule|
|
matching_rules = matching_rules.select do |rule|
|
||||||
next true if rule.tags.nil? or rule.tags.empty? # Filter has no tags specified
|
next true if rule.tags.nil? || rule.tags.empty? # Filter has no tags specified
|
||||||
any_tags_match = !((rule.tags & topic_tags).empty?)
|
any_tags_match = !((rule.tags & topic_tags).empty?)
|
||||||
next any_tags_match # If any tags match, keep this filter, otherwise throw away
|
next any_tags_match # If any tags match, keep this filter, otherwise throw away
|
||||||
end
|
end
|
||||||
@ -84,7 +84,7 @@ module DiscourseChat
|
|||||||
provider.trigger_notification(post, channel)
|
provider.trigger_notification(post, channel)
|
||||||
channel.update_attribute('error_key', nil) if channel.error_key
|
channel.update_attribute('error_key', nil) if channel.error_key
|
||||||
rescue => e
|
rescue => e
|
||||||
if e.class == DiscourseChat::ProviderError and e.info.key?(:error_key) and !e.info[:error_key].nil?
|
if e.class == (DiscourseChat::ProviderError) && e.info.key?(:error_key) && !e.info[:error_key].nil?
|
||||||
channel.update_attribute('error_key', e.info[:error_key])
|
channel.update_attribute('error_key', e.info[:error_key])
|
||||||
else
|
else
|
||||||
channel.update_attribute('error_key', 'chat_integration.channel_exception')
|
channel.update_attribute('error_key', 'chat_integration.channel_exception')
|
||||||
@ -104,6 +104,5 @@ module DiscourseChat
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
@ -71,11 +71,11 @@ module DiscourseChat
|
|||||||
engines = []
|
engines = []
|
||||||
DiscourseChat::Provider.providers.each do |provider|
|
DiscourseChat::Provider.providers.each do |provider|
|
||||||
engine = provider.constants.select do |constant|
|
engine = provider.constants.select do |constant|
|
||||||
constant.to_s =~ /Engine$/ and not constant.to_s == "HookEngine"
|
constant.to_s =~ (/Engine$/) && (not constant.to_s == "HookEngine")
|
||||||
end.map(&provider.method(:const_get)).first
|
end.map(&provider.method(:const_get)).first
|
||||||
|
|
||||||
if engine
|
if engine
|
||||||
engines.push({engine: engine, name: provider::PROVIDER_NAME})
|
engines.push(engine: engine, name: provider::PROVIDER_NAME)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -13,9 +13,7 @@ module DiscourseChat
|
|||||||
event_type = 'm.room.message'
|
event_type = 'm.room.message'
|
||||||
uid = Time.now.to_i
|
uid = Time.now.to_i
|
||||||
|
|
||||||
url_params = URI.encode_www_form({
|
url_params = URI.encode_www_form(access_token: SiteSetting.chat_integration_matrix_access_token)
|
||||||
access_token: SiteSetting.chat_integration_matrix_access_token
|
|
||||||
})
|
|
||||||
|
|
||||||
url = "#{homeserver}/_matrix/client/r0/rooms/#{CGI::escape(room_id)}/send/#{event_type}/#{uid}"
|
url = "#{homeserver}/_matrix/client/r0/rooms/#{CGI::escape(room_id)}/send/#{event_type}/#{uid}"
|
||||||
|
|
||||||
@ -42,18 +40,14 @@ module DiscourseChat
|
|||||||
|
|
||||||
message = {
|
message = {
|
||||||
msgtype: 'm.notice',
|
msgtype: 'm.notice',
|
||||||
body: I18n.t('chat_integration.provider.matrix.text_message', {
|
body: I18n.t('chat_integration.provider.matrix.text_message', user: display_name,
|
||||||
user: display_name,
|
|
||||||
post_url: post.full_url,
|
post_url: post.full_url,
|
||||||
title: post.topic.title
|
title: post.topic.title),
|
||||||
}),
|
|
||||||
format: 'org.matrix.custom.html',
|
format: 'org.matrix.custom.html',
|
||||||
formatted_body: I18n.t('chat_integration.provider.matrix.formatted_message', {
|
formatted_body: I18n.t('chat_integration.provider.matrix.formatted_message', user: display_name,
|
||||||
user: display_name,
|
|
||||||
post_url: post.full_url,
|
post_url: post.full_url,
|
||||||
title: post.topic.title,
|
title: post.topic.title,
|
||||||
excerpt: post.excerpt(SiteSetting.chat_integration_discord_excerpt_length, text_entities: true, strip_links: true, remap_emoji: true),
|
excerpt: post.excerpt(SiteSetting.chat_integration_discord_excerpt_length, text_entities: true, strip_links: true, remap_emoji: true))
|
||||||
})
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -66,6 +66,3 @@ module DiscourseChat::Provider::MattermostProvider
|
|||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -68,7 +68,7 @@ module DiscourseChat::Provider::SlackProvider
|
|||||||
|
|
||||||
# Load the user data (we need this to change user IDs into usernames)
|
# Load the user data (we need this to change user IDs into usernames)
|
||||||
req = Net::HTTP::Post.new(URI('https://slack.com/api/users.list'))
|
req = Net::HTTP::Post.new(URI('https://slack.com/api/users.list'))
|
||||||
req.set_form_data({token: SiteSetting.chat_integration_slack_access_token})
|
req.set_form_data(token: SiteSetting.chat_integration_slack_access_token)
|
||||||
response = http.request(req)
|
response = http.request(req)
|
||||||
return error_text unless response.kind_of? Net::HTTPSuccess
|
return error_text unless response.kind_of? Net::HTTPSuccess
|
||||||
json = JSON.parse(response.body)
|
json = JSON.parse(response.body)
|
||||||
@ -185,6 +185,3 @@ module DiscourseChat::Provider::SlackProvider
|
|||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@ class ChatIntegrationSlackEnabledSettingValidator
|
|||||||
end
|
end
|
||||||
|
|
||||||
def valid_value?(val)
|
def valid_value?(val)
|
||||||
return true if val == 'f' or val == false
|
return true if val == ('f') || val == (false)
|
||||||
return false if SiteSetting.chat_integration_slack_outbound_webhook_url.blank? && SiteSetting.chat_integration_slack_access_token.blank?
|
return false if SiteSetting.chat_integration_slack_outbound_webhook_url.blank? && SiteSetting.chat_integration_slack_access_token.blank?
|
||||||
true
|
true
|
||||||
end
|
end
|
||||||
|
@ -105,7 +105,7 @@ module DiscourseChat::Provider::SlackProvider
|
|||||||
json = JSON.parse(response.body)
|
json = JSON.parse(response.body)
|
||||||
|
|
||||||
unless json["ok"] == true
|
unless json["ok"] == true
|
||||||
if json.key?("error") and (json["error"] == 'channel_not_found' or json["error"] == 'is_archived')
|
if json.key?("error") && (json["error"] == ('channel_not_found') || json["error"] == ('is_archived'))
|
||||||
error_key = 'chat_integration.provider.slack.errors.channel_not_found'
|
error_key = 'chat_integration.provider.slack.errors.channel_not_found'
|
||||||
else
|
else
|
||||||
error_key = json.to_s
|
error_key = json.to_s
|
||||||
@ -127,7 +127,7 @@ module DiscourseChat::Provider::SlackProvider
|
|||||||
unless response.kind_of? Net::HTTPSuccess
|
unless response.kind_of? Net::HTTPSuccess
|
||||||
if response.code.to_s == '403'
|
if response.code.to_s == '403'
|
||||||
error_key = 'chat_integration.provider.slack.errors.action_prohibited'
|
error_key = 'chat_integration.provider.slack.errors.action_prohibited'
|
||||||
elsif response.body == 'channel_not_found' or response.body == 'channel_is_archived'
|
elsif response.body == ('channel_not_found') || response.body == ('channel_is_archived')
|
||||||
error_key = 'chat_integration.provider.slack.errors.channel_not_found'
|
error_key = 'chat_integration.provider.slack.errors.channel_not_found'
|
||||||
else
|
else
|
||||||
error_key = nil
|
error_key = nil
|
||||||
@ -135,7 +135,6 @@ module DiscourseChat::Provider::SlackProvider
|
|||||||
raise ::DiscourseChat::ProviderError.new info: { error_key: error_key, request: req.body, response_code: response.code, response_body: response.body }
|
raise ::DiscourseChat::ProviderError.new info: { error_key: error_key, request: req.body, response_code: response.code, response_body: response.body }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.trigger_notification(post, channel)
|
def self.trigger_notification(post, channel)
|
||||||
|
@ -27,7 +27,7 @@ module DiscourseChat::Provider::TelegramProvider
|
|||||||
|
|
||||||
DiscourseChat::Provider::TelegramProvider.sendMessage(message)
|
DiscourseChat::Provider::TelegramProvider.sendMessage(message)
|
||||||
|
|
||||||
elsif params.key?('channel_post') and params['channel_post']['text'].include? '/getchatid'
|
elsif params.key?('channel_post') && params['channel_post']['text'].include?('/getchatid')
|
||||||
chat_id = params['channel_post']['chat']['id']
|
chat_id = params['channel_post']['chat']['id']
|
||||||
|
|
||||||
message_text = I18n.t(
|
message_text = I18n.t(
|
||||||
|
@ -2,7 +2,7 @@ DiscourseEvent.on(:site_setting_saved) do |sitesetting|
|
|||||||
isEnabledSetting = sitesetting.name == 'chat_integration_telegram_enabled'
|
isEnabledSetting = sitesetting.name == 'chat_integration_telegram_enabled'
|
||||||
isAccessToken = sitesetting.name == 'chat_integration_telegram_access_token'
|
isAccessToken = sitesetting.name == 'chat_integration_telegram_access_token'
|
||||||
|
|
||||||
if (isEnabledSetting or isAccessToken)
|
if (isEnabledSetting || isAccessToken)
|
||||||
enabled = isEnabledSetting ? sitesetting.value == 't' : SiteSetting.chat_integration_telegram_enabled
|
enabled = isEnabledSetting ? sitesetting.value == 't' : SiteSetting.chat_integration_telegram_enabled
|
||||||
if enabled
|
if enabled
|
||||||
Scheduler::Defer.later("Setup Telegram Webhook") do
|
Scheduler::Defer.later("Setup Telegram Webhook") do
|
||||||
|
@ -174,7 +174,7 @@ describe 'Chat Controller', type: :request do
|
|||||||
expect(response).to be_success
|
expect(response).to be_success
|
||||||
|
|
||||||
channel = DiscourseChat::Channel.all.first
|
channel = DiscourseChat::Channel.all.first
|
||||||
expect(channel.data).to eq({"val" => "something-else"})
|
expect(channel.data).to eq("val" => "something-else")
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should fail for invalid params' do
|
it 'should fail for invalid params' do
|
||||||
|
@ -225,7 +225,6 @@ RSpec.describe DiscourseChat::Manager do
|
|||||||
expect(DiscourseChat::Helper.delete_by_index(chan1, 1)).to eq(:deleted)
|
expect(DiscourseChat::Helper.delete_by_index(chan1, 1)).to eq(:deleted)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '.smart_create_rule' do
|
describe '.smart_create_rule' do
|
||||||
|
@ -18,7 +18,7 @@ RSpec.describe DiscourseChat::Provider::DiscordProvider do
|
|||||||
|
|
||||||
it 'includes the protocol in the avatar URL' do
|
it 'includes the protocol in the avatar URL' do
|
||||||
stub1 = stub_request(:post, 'https://discordapp.com/api/webhooks/1234/abcd?wait=true')
|
stub1 = stub_request(:post, 'https://discordapp.com/api/webhooks/1234/abcd?wait=true')
|
||||||
.with(body: hash_including({embeds:[hash_including({author:hash_including({url:/^https?:\/\//})})]}))
|
.with(body: hash_including(embeds: [hash_including(author: hash_including(url: /^https?:\/\//))]))
|
||||||
.to_return(status: 200)
|
.to_return(status: 200)
|
||||||
described_class.trigger_notification(post, chan1)
|
described_class.trigger_notification(post, chan1)
|
||||||
expect(stub1).to have_been_requested.once
|
expect(stub1).to have_been_requested.once
|
||||||
|
@ -5,13 +5,10 @@ RSpec.describe DiscourseChat::Channel do
|
|||||||
include_context "dummy provider"
|
include_context "dummy provider"
|
||||||
include_context "validated dummy provider"
|
include_context "validated dummy provider"
|
||||||
|
|
||||||
|
|
||||||
it 'should save and load successfully' do
|
it 'should save and load successfully' do
|
||||||
expect(DiscourseChat::Channel.all.length).to eq(0)
|
expect(DiscourseChat::Channel.all.length).to eq(0)
|
||||||
|
|
||||||
chan = DiscourseChat::Channel.create({
|
chan = DiscourseChat::Channel.create(provider: "dummy")
|
||||||
provider:"dummy",
|
|
||||||
})
|
|
||||||
|
|
||||||
expect(DiscourseChat::Channel.all.length).to eq(1)
|
expect(DiscourseChat::Channel.all.length).to eq(1)
|
||||||
|
|
||||||
@ -51,7 +48,7 @@ RSpec.describe DiscourseChat::Channel do
|
|||||||
end
|
end
|
||||||
|
|
||||||
it 'can find its own rules' do
|
it 'can find its own rules' do
|
||||||
channel = DiscourseChat::Channel.create({provider:'dummy'})
|
channel = DiscourseChat::Channel.create(provider: 'dummy')
|
||||||
expect(channel.rules.size).to eq(0)
|
expect(channel.rules.size).to eq(0)
|
||||||
DiscourseChat::Rule.create(channel: channel)
|
DiscourseChat::Rule.create(channel: channel)
|
||||||
DiscourseChat::Rule.create(channel: channel)
|
DiscourseChat::Rule.create(channel: channel)
|
||||||
@ -59,7 +56,7 @@ RSpec.describe DiscourseChat::Channel do
|
|||||||
end
|
end
|
||||||
|
|
||||||
it 'destroys its rules on destroy' do
|
it 'destroys its rules on destroy' do
|
||||||
channel = DiscourseChat::Channel.create({provider:'dummy'})
|
channel = DiscourseChat::Channel.create(provider: 'dummy')
|
||||||
expect(channel.rules.size).to eq(0)
|
expect(channel.rules.size).to eq(0)
|
||||||
rule1 = DiscourseChat::Rule.create(channel: channel)
|
rule1 = DiscourseChat::Rule.create(channel: channel)
|
||||||
rule2 = DiscourseChat::Rule.create(channel: channel)
|
rule2 = DiscourseChat::Rule.create(channel: channel)
|
||||||
@ -106,6 +103,5 @@ RSpec.describe DiscourseChat::Channel do
|
|||||||
expect(channel2.valid?).to eq(true)
|
expect(channel2.valid?).to eq(true)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
@ -28,12 +28,10 @@ RSpec.describe DiscourseChat::Rule do
|
|||||||
it 'should save and load successfully' do
|
it 'should save and load successfully' do
|
||||||
expect(DiscourseChat::Rule.all.length).to eq(0)
|
expect(DiscourseChat::Rule.all.length).to eq(0)
|
||||||
|
|
||||||
rule = DiscourseChat::Rule.create({
|
rule = DiscourseChat::Rule.create(channel: channel,
|
||||||
channel: channel,
|
|
||||||
category_id: category.id,
|
category_id: category.id,
|
||||||
tags: [tag1.name, tag2.name],
|
tags: [tag1.name, tag2.name],
|
||||||
filter: 'watch'
|
filter: 'watch')
|
||||||
})
|
|
||||||
|
|
||||||
expect(DiscourseChat::Rule.all.length).to eq(1)
|
expect(DiscourseChat::Rule.all.length).to eq(1)
|
||||||
|
|
||||||
@ -48,11 +46,9 @@ RSpec.describe DiscourseChat::Rule do
|
|||||||
|
|
||||||
describe 'general operations' do
|
describe 'general operations' do
|
||||||
before do
|
before do
|
||||||
rule = DiscourseChat::Rule.create({
|
rule = DiscourseChat::Rule.create(channel: channel,
|
||||||
channel: channel,
|
|
||||||
category_id: category.id,
|
category_id: category.id,
|
||||||
tags: [tag1.name, tag2.name]
|
tags: [tag1.name, tag2.name])
|
||||||
})
|
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'can be modified' do
|
it 'can be modified' do
|
||||||
@ -76,10 +72,10 @@ RSpec.describe DiscourseChat::Rule do
|
|||||||
end
|
end
|
||||||
|
|
||||||
it 'can delete all' do
|
it 'can delete all' do
|
||||||
DiscourseChat::Rule.create({channel:channel})
|
DiscourseChat::Rule.create(channel: channel)
|
||||||
DiscourseChat::Rule.create({channel:channel})
|
DiscourseChat::Rule.create(channel: channel)
|
||||||
DiscourseChat::Rule.create({channel:channel})
|
DiscourseChat::Rule.create(channel: channel)
|
||||||
DiscourseChat::Rule.create({channel:channel})
|
DiscourseChat::Rule.create(channel: channel)
|
||||||
|
|
||||||
expect(DiscourseChat::Rule.all.length).to eq(5)
|
expect(DiscourseChat::Rule.all.length).to eq(5)
|
||||||
|
|
||||||
@ -154,11 +150,9 @@ RSpec.describe DiscourseChat::Rule do
|
|||||||
describe 'validations' do
|
describe 'validations' do
|
||||||
|
|
||||||
let(:rule) do
|
let(:rule) do
|
||||||
DiscourseChat::Rule.create({
|
DiscourseChat::Rule.create(filter: 'watch',
|
||||||
filter: 'watch',
|
|
||||||
channel: channel,
|
channel: channel,
|
||||||
category_id: category.id,
|
category_id: category.id)
|
||||||
})
|
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'validates channel correctly' do
|
it 'validates channel correctly' do
|
||||||
|
Loading…
x
Reference in New Issue
Block a user