mirror of
https://github.com/discourse/discourse.git
synced 2025-03-09 14:34:35 +00:00
DEV: Remove the use of mocks in our tests.
This commit is contained in:
parent
2ce684b134
commit
a4aa4a9be4
@ -12,17 +12,20 @@ describe ::DiscoursePoll::PollsController do
|
|||||||
describe "#vote" do
|
describe "#vote" do
|
||||||
|
|
||||||
it "works" do
|
it "works" do
|
||||||
MessageBus.expects(:publish)
|
message = MessageBus.track_publish do
|
||||||
|
put :vote, params: {
|
||||||
|
post_id: poll.id, poll_name: "poll", options: ["5c24fc1df56d764b550ceae1b9319125"]
|
||||||
|
}, format: :json
|
||||||
|
|
||||||
put :vote, params: {
|
expect(response.status).to eq(200)
|
||||||
post_id: poll.id, poll_name: "poll", options: ["5c24fc1df56d764b550ceae1b9319125"]
|
end.first
|
||||||
}, format: :json
|
|
||||||
|
|
||||||
expect(response.status).to eq(200)
|
|
||||||
json = ::JSON.parse(response.body)
|
json = ::JSON.parse(response.body)
|
||||||
expect(json["poll"]["name"]).to eq("poll")
|
expect(json["poll"]["name"]).to eq("poll")
|
||||||
expect(json["poll"]["voters"]).to eq(1)
|
expect(json["poll"]["voters"]).to eq(1)
|
||||||
expect(json["vote"]).to eq(["5c24fc1df56d764b550ceae1b9319125"])
|
expect(json["vote"]).to eq(["5c24fc1df56d764b550ceae1b9319125"])
|
||||||
|
|
||||||
|
expect(message.channel).to eq("/polls/#{poll.topic_id}")
|
||||||
end
|
end
|
||||||
|
|
||||||
it "requires at least 1 valid option" do
|
it "requires at least 1 valid option" do
|
||||||
@ -202,28 +205,33 @@ describe ::DiscoursePoll::PollsController do
|
|||||||
describe "#toggle_status" do
|
describe "#toggle_status" do
|
||||||
|
|
||||||
it "works for OP" do
|
it "works for OP" do
|
||||||
MessageBus.expects(:publish)
|
message = MessageBus.track_publish do
|
||||||
|
put :toggle_status, params: {
|
||||||
|
post_id: poll.id, poll_name: "poll", status: "closed"
|
||||||
|
}, format: :json
|
||||||
|
|
||||||
put :toggle_status, params: {
|
expect(response.status).to eq(200)
|
||||||
post_id: poll.id, poll_name: "poll", status: "closed"
|
end.first
|
||||||
}, format: :json
|
|
||||||
|
|
||||||
expect(response.status).to eq(200)
|
|
||||||
json = ::JSON.parse(response.body)
|
json = ::JSON.parse(response.body)
|
||||||
expect(json["poll"]["status"]).to eq("closed")
|
expect(json["poll"]["status"]).to eq("closed")
|
||||||
|
expect(message.channel).to eq("/polls/#{poll.topic_id}")
|
||||||
end
|
end
|
||||||
|
|
||||||
it "works for staff" do
|
it "works for staff" do
|
||||||
log_in(:moderator)
|
log_in(:moderator)
|
||||||
MessageBus.expects(:publish)
|
|
||||||
|
|
||||||
put :toggle_status, params: {
|
message = MessageBus.track_publish do
|
||||||
post_id: poll.id, poll_name: "poll", status: "closed"
|
put :toggle_status, params: {
|
||||||
}, format: :json
|
post_id: poll.id, poll_name: "poll", status: "closed"
|
||||||
|
}, format: :json
|
||||||
|
|
||||||
|
expect(response.status).to eq(200)
|
||||||
|
end.first
|
||||||
|
|
||||||
expect(response.status).to eq(200)
|
|
||||||
json = ::JSON.parse(response.body)
|
json = ::JSON.parse(response.body)
|
||||||
expect(json["poll"]["status"]).to eq("closed")
|
expect(json["poll"]["status"]).to eq("closed")
|
||||||
|
expect(message.channel).to eq("/polls/#{poll.topic_id}")
|
||||||
end
|
end
|
||||||
|
|
||||||
it "ensures post is not trashed" do
|
it "ensures post is not trashed" do
|
||||||
|
Loading…
x
Reference in New Issue
Block a user