mirror of
https://github.com/discourse/discourse-chat-integration.git
synced 2025-02-18 01:15:20 +00:00
Fix specs for Rails 5.2.
This commit is contained in:
parent
956f3993fe
commit
9826f10a60
@ -1,8 +1,7 @@
|
|||||||
require 'rails_helper'
|
require 'rails_helper'
|
||||||
|
|
||||||
RSpec.describe PostCreator do
|
RSpec.describe PostCreator do
|
||||||
let(:first_post) { Fabricate(:post) }
|
let(:topic) { Fabricate(:post).topic }
|
||||||
let(:topic) { Fabricate(:topic, posts: [first_post]) }
|
|
||||||
|
|
||||||
before do
|
before do
|
||||||
SiteSetting.queue_jobs = true
|
SiteSetting.queue_jobs = true
|
||||||
|
@ -2,8 +2,8 @@ require 'rails_helper'
|
|||||||
require_relative '../dummy_provider'
|
require_relative '../dummy_provider'
|
||||||
|
|
||||||
describe 'Chat Controller', type: :request do
|
describe 'Chat Controller', type: :request do
|
||||||
let(:first_post) { Fabricate(:post) }
|
|
||||||
let(:topic) { Fabricate(:topic, posts: [first_post]) }
|
let(:topic) { Fabricate(:post).topic }
|
||||||
let(:admin) { Fabricate(:admin) }
|
let(:admin) { Fabricate(:admin) }
|
||||||
let(:category) { Fabricate(:category) }
|
let(:category) { Fabricate(:category) }
|
||||||
let(:category2) { Fabricate(:category) }
|
let(:category2) { Fabricate(:category) }
|
||||||
@ -45,7 +45,7 @@ describe 'Chat Controller', type: :request do
|
|||||||
it 'should return the right response' do
|
it 'should return the right response' do
|
||||||
get '/admin/plugins/chat/providers.json'
|
get '/admin/plugins/chat/providers.json'
|
||||||
|
|
||||||
expect(response).to be_success
|
expect(response.status).to eq(200)
|
||||||
|
|
||||||
json = JSON.parse(response.body)
|
json = JSON.parse(response.body)
|
||||||
|
|
||||||
@ -73,7 +73,7 @@ describe 'Chat Controller', type: :request do
|
|||||||
channel_id: channel.id, topic_id: topic.id
|
channel_id: channel.id, topic_id: topic.id
|
||||||
}
|
}
|
||||||
|
|
||||||
expect(response).to be_success
|
expect(response.status).to eq(200)
|
||||||
|
|
||||||
JSON.parse(response.body)
|
JSON.parse(response.body)
|
||||||
end
|
end
|
||||||
@ -83,7 +83,7 @@ describe 'Chat Controller', type: :request do
|
|||||||
channel_id: 999, topic_id: topic.id
|
channel_id: 999, topic_id: topic.id
|
||||||
}
|
}
|
||||||
|
|
||||||
expect(response).not_to be_success
|
expect(response.status).to eq(422)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -106,7 +106,7 @@ describe 'Chat Controller', type: :request do
|
|||||||
|
|
||||||
get '/admin/plugins/chat/channels.json', params: { provider: 'dummy' }
|
get '/admin/plugins/chat/channels.json', params: { provider: 'dummy' }
|
||||||
|
|
||||||
expect(response).to be_success
|
expect(response.status).to eq(200)
|
||||||
|
|
||||||
channels = JSON.parse(response.body)['channels']
|
channels = JSON.parse(response.body)['channels']
|
||||||
|
|
||||||
@ -146,7 +146,7 @@ describe 'Chat Controller', type: :request do
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
expect(response).to be_success
|
expect(response.status).to eq(200)
|
||||||
|
|
||||||
channel = DiscourseChat::Channel.all.last
|
channel = DiscourseChat::Channel.all.last
|
||||||
|
|
||||||
@ -161,7 +161,7 @@ describe 'Chat Controller', type: :request do
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
expect(response).not_to be_success
|
expect(response.status).to eq(422)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -184,7 +184,7 @@ describe 'Chat Controller', type: :request do
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
expect(response).to be_success
|
expect(response.status).to eq(200)
|
||||||
|
|
||||||
channel = DiscourseChat::Channel.all.last
|
channel = DiscourseChat::Channel.all.last
|
||||||
expect(channel.data).to eq("val" => "something-else")
|
expect(channel.data).to eq("val" => "something-else")
|
||||||
@ -197,7 +197,7 @@ describe 'Chat Controller', type: :request do
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
expect(response).not_to be_success
|
expect(response.status).to eq(422)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -216,7 +216,7 @@ describe 'Chat Controller', type: :request do
|
|||||||
it 'should be able delete a channel' do
|
it 'should be able delete a channel' do
|
||||||
delete "/admin/plugins/chat/channels/#{channel.id}.json"
|
delete "/admin/plugins/chat/channels/#{channel.id}.json"
|
||||||
|
|
||||||
expect(response).to be_success
|
expect(response.status).to eq(200)
|
||||||
expect(DiscourseChat::Channel.all.size).to eq(0)
|
expect(DiscourseChat::Channel.all.size).to eq(0)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -241,7 +241,7 @@ describe 'Chat Controller', type: :request do
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
expect(response).to be_success
|
expect(response.status).to eq(200)
|
||||||
|
|
||||||
rule = DiscourseChat::Rule.all.last
|
rule = DiscourseChat::Rule.all.last
|
||||||
|
|
||||||
@ -262,7 +262,7 @@ describe 'Chat Controller', type: :request do
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
expect(response).not_to be_success
|
expect(response.status).to eq(422)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -288,7 +288,7 @@ describe 'Chat Controller', type: :request do
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
expect(response).to be_success
|
expect(response.status).to eq(200)
|
||||||
|
|
||||||
rule = DiscourseChat::Rule.all.last
|
rule = DiscourseChat::Rule.all.last
|
||||||
expect(rule.category_id).to eq(category2.id)
|
expect(rule.category_id).to eq(category2.id)
|
||||||
@ -304,7 +304,7 @@ describe 'Chat Controller', type: :request do
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
expect(response).not_to be_success
|
expect(response.status).to eq(422)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -330,7 +330,7 @@ describe 'Chat Controller', type: :request do
|
|||||||
it 'should be able delete a rule' do
|
it 'should be able delete a rule' do
|
||||||
delete "/admin/plugins/chat/rules/#{rule.id}.json"
|
delete "/admin/plugins/chat/rules/#{rule.id}.json"
|
||||||
|
|
||||||
expect(response).to be_success
|
expect(response.status).to eq(200)
|
||||||
expect(DiscourseChat::Rule.all.size).to eq(0)
|
expect(DiscourseChat::Rule.all.size).to eq(0)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -13,7 +13,7 @@ describe 'Public Controller', type: :request do
|
|||||||
|
|
||||||
get "/chat-transcript/#{key}.json"
|
get "/chat-transcript/#{key}.json"
|
||||||
|
|
||||||
expect(response).to be_success
|
expect(response.status).to eq(200)
|
||||||
|
|
||||||
expect(response.body).to eq('{"content":"Some content here"}')
|
expect(response.body).to eq('{"content":"Some content here"}')
|
||||||
end
|
end
|
||||||
@ -22,7 +22,7 @@ describe 'Public Controller', type: :request do
|
|||||||
key = 'abcdefghijk'
|
key = 'abcdefghijk'
|
||||||
get "/chat-transcript/#{key}.json"
|
get "/chat-transcript/#{key}.json"
|
||||||
|
|
||||||
expect(response).not_to be_success
|
expect(response.status).to eq(404)
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user