From 9826f10a60b7228b7800c506d4ef6cc960541170 Mon Sep 17 00:00:00 2001 From: Guo Xiang Tan Date: Fri, 8 Jun 2018 08:57:43 +0800 Subject: [PATCH] Fix specs for Rails 5.2. --- spec/jobs/regular/notify_chats_spec.rb | 3 +-- spec/requests/chat_controller_spec.rb | 32 ++++++++++++------------- spec/requests/public_controller_spec.rb | 4 ++-- 3 files changed, 19 insertions(+), 20 deletions(-) diff --git a/spec/jobs/regular/notify_chats_spec.rb b/spec/jobs/regular/notify_chats_spec.rb index df1ad30..bbc2e6b 100644 --- a/spec/jobs/regular/notify_chats_spec.rb +++ b/spec/jobs/regular/notify_chats_spec.rb @@ -1,8 +1,7 @@ require 'rails_helper' RSpec.describe PostCreator do - let(:first_post) { Fabricate(:post) } - let(:topic) { Fabricate(:topic, posts: [first_post]) } + let(:topic) { Fabricate(:post).topic } before do SiteSetting.queue_jobs = true diff --git a/spec/requests/chat_controller_spec.rb b/spec/requests/chat_controller_spec.rb index 9ecea2b..c82187a 100644 --- a/spec/requests/chat_controller_spec.rb +++ b/spec/requests/chat_controller_spec.rb @@ -2,8 +2,8 @@ require 'rails_helper' require_relative '../dummy_provider' 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(:category) { Fabricate(:category) } let(:category2) { Fabricate(:category) } @@ -45,7 +45,7 @@ describe 'Chat Controller', type: :request do it 'should return the right response' do get '/admin/plugins/chat/providers.json' - expect(response).to be_success + expect(response.status).to eq(200) json = JSON.parse(response.body) @@ -73,7 +73,7 @@ describe 'Chat Controller', type: :request do channel_id: channel.id, topic_id: topic.id } - expect(response).to be_success + expect(response.status).to eq(200) JSON.parse(response.body) end @@ -83,7 +83,7 @@ describe 'Chat Controller', type: :request do channel_id: 999, topic_id: topic.id } - expect(response).not_to be_success + expect(response.status).to eq(422) end end end @@ -106,7 +106,7 @@ describe 'Chat Controller', type: :request do 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'] @@ -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 @@ -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 @@ -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 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 @@ -216,7 +216,7 @@ describe 'Chat Controller', type: :request do it 'should be able delete a channel' do 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) 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 @@ -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 @@ -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 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 @@ -330,7 +330,7 @@ describe 'Chat Controller', type: :request do it 'should be able delete a rule' do 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) end end diff --git a/spec/requests/public_controller_spec.rb b/spec/requests/public_controller_spec.rb index 80962ad..92b45c1 100644 --- a/spec/requests/public_controller_spec.rb +++ b/spec/requests/public_controller_spec.rb @@ -13,7 +13,7 @@ describe 'Public Controller', type: :request do 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"}') end @@ -22,7 +22,7 @@ describe 'Public Controller', type: :request do key = 'abcdefghijk' get "/chat-transcript/#{key}.json" - expect(response).not_to be_success + expect(response.status).to eq(404) end end