mirror of
https://github.com/discourse/discourse.git
synced 2025-09-06 10:50:21 +08:00
correct specs
This commit is contained in:
parent
24c7d2913b
commit
e806e6e96f
2 changed files with 26 additions and 26 deletions
|
@ -4,7 +4,7 @@ RSpec.describe Jobs::DiscourseNarrativeBot::RemapOldBotImages do
|
||||||
context "when bot's post contains an old link" do
|
context "when bot's post contains an old link" do
|
||||||
let(:post) do
|
let(:post) do
|
||||||
Fabricate(:post,
|
Fabricate(:post,
|
||||||
user_id: -2,
|
user: User.find(-2),
|
||||||
raw: 'If you’d like to learn more, select <img src="/images/font-awesome-gear.png" width="16" height="16"> <img src="/images/font-awesome-ellipsis.png" width="16" height="16"> below and <img src="/images/font-awesome-bookmark.png" width="16" height="16"> **bookmark this private message**. If you do, there may be a :gift: in your future!'
|
raw: 'If you’d like to learn more, select <img src="/images/font-awesome-gear.png" width="16" height="16"> <img src="/images/font-awesome-ellipsis.png" width="16" height="16"> below and <img src="/images/font-awesome-bookmark.png" width="16" height="16"> **bookmark this private message**. If you do, there may be a :gift: in your future!'
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
@ -25,7 +25,7 @@ RSpec.describe Jobs::DiscourseNarrativeBot::RemapOldBotImages do
|
||||||
context 'subfolder' do
|
context 'subfolder' do
|
||||||
let(:post) do
|
let(:post) do
|
||||||
Fabricate(:post,
|
Fabricate(:post,
|
||||||
user_id: -2,
|
user: User.find(-2),
|
||||||
raw: 'If you’d like to learn more, select <img src="/community/images/font-awesome-ellipsis.png" width="16" height="16"> below and <img src="/community/images/font-awesome-bookmark.png" width="16" height="16"> **bookmark this private message**. If you do, there may be a :gift: in your future!'
|
raw: 'If you’d like to learn more, select <img src="/community/images/font-awesome-ellipsis.png" width="16" height="16"> below and <img src="/community/images/font-awesome-bookmark.png" width="16" height="16"> **bookmark this private message**. If you do, there may be a :gift: in your future!'
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
|
@ -6,8 +6,8 @@ describe ::DiscoursePoll::PollsController do
|
||||||
|
|
||||||
let!(:user) { log_in }
|
let!(:user) { log_in }
|
||||||
let(:topic) { Fabricate(:topic) }
|
let(:topic) { Fabricate(:topic) }
|
||||||
let(:poll) { Fabricate(:post, topic_id: topic.id, user_id: user.id, raw: "[poll]\n- A\n- B\n[/poll]") }
|
let(:poll) { Fabricate(:post, topic: topic, user: user, raw: "[poll]\n- A\n- B\n[/poll]") }
|
||||||
let(:multi_poll) { Fabricate(:post, topic_id: topic.id, user_id: user.id, raw: "[poll min=1 max=2 type=multiple public=true]\n- A\n- B\n[/poll]") }
|
let(:multi_poll) { Fabricate(:post, topic: topic, user: user, raw: "[poll min=1 max=2 type=multiple public=true]\n- A\n- B\n[/poll]") }
|
||||||
|
|
||||||
describe "#vote" do
|
describe "#vote" do
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@ describe ::DiscoursePoll::PollsController do
|
||||||
post_id: poll.id, poll_name: "poll", options: ["5c24fc1df56d764b550ceae1b9319125"]
|
post_id: poll.id, poll_name: "poll", options: ["5c24fc1df56d764b550ceae1b9319125"]
|
||||||
}, format: :json
|
}, format: :json
|
||||||
|
|
||||||
expect(response).to be_success
|
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)
|
||||||
|
@ -30,7 +30,7 @@ describe ::DiscoursePoll::PollsController do
|
||||||
post_id: poll.id, poll_name: "poll", options: ["A", "B"]
|
post_id: poll.id, poll_name: "poll", options: ["A", "B"]
|
||||||
}, format: :json
|
}, format: :json
|
||||||
|
|
||||||
expect(response).not_to be_success
|
expect(response.status).not_to eq(200)
|
||||||
json = ::JSON.parse(response.body)
|
json = ::JSON.parse(response.body)
|
||||||
expect(json["errors"][0]).to eq(I18n.t("poll.requires_at_least_1_valid_option"))
|
expect(json["errors"][0]).to eq(I18n.t("poll.requires_at_least_1_valid_option"))
|
||||||
end
|
end
|
||||||
|
@ -40,13 +40,13 @@ describe ::DiscoursePoll::PollsController do
|
||||||
post_id: poll.id, poll_name: "poll", options: ["5c24fc1df56d764b550ceae1b9319125"]
|
post_id: poll.id, poll_name: "poll", options: ["5c24fc1df56d764b550ceae1b9319125"]
|
||||||
}, format: :json
|
}, format: :json
|
||||||
|
|
||||||
expect(response).to be_success
|
expect(response.status).to eq(200)
|
||||||
|
|
||||||
put :vote, params: {
|
put :vote, params: {
|
||||||
post_id: poll.id, poll_name: "poll", options: ["e89dec30bbd9bf50fabf6a05b4324edf"]
|
post_id: poll.id, poll_name: "poll", options: ["e89dec30bbd9bf50fabf6a05b4324edf"]
|
||||||
}, format: :json
|
}, format: :json
|
||||||
|
|
||||||
expect(response).to be_success
|
expect(response.status).to eq(200)
|
||||||
json = ::JSON.parse(response.body)
|
json = ::JSON.parse(response.body)
|
||||||
expect(json["poll"]["voters"]).to eq(1)
|
expect(json["poll"]["voters"]).to eq(1)
|
||||||
expect(json["poll"]["options"][0]["votes"]).to eq(0)
|
expect(json["poll"]["options"][0]["votes"]).to eq(0)
|
||||||
|
@ -60,7 +60,7 @@ describe ::DiscoursePoll::PollsController do
|
||||||
post_id: poll.id, poll_name: "poll", options: ["5c24fc1df56d764b550ceae1b9319125"]
|
post_id: poll.id, poll_name: "poll", options: ["5c24fc1df56d764b550ceae1b9319125"]
|
||||||
}, format: :json
|
}, format: :json
|
||||||
|
|
||||||
expect(response).to be_success
|
expect(response.status).to eq(200)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "ensures topic is not archived" do
|
it "ensures topic is not archived" do
|
||||||
|
@ -70,7 +70,7 @@ describe ::DiscoursePoll::PollsController do
|
||||||
post_id: poll.id, poll_name: "poll", options: ["A"]
|
post_id: poll.id, poll_name: "poll", options: ["A"]
|
||||||
}, format: :json
|
}, format: :json
|
||||||
|
|
||||||
expect(response).not_to be_success
|
expect(response.status).not_to eq(200)
|
||||||
json = ::JSON.parse(response.body)
|
json = ::JSON.parse(response.body)
|
||||||
expect(json["errors"][0]).to eq(I18n.t("poll.topic_must_be_open_to_vote"))
|
expect(json["errors"][0]).to eq(I18n.t("poll.topic_must_be_open_to_vote"))
|
||||||
end
|
end
|
||||||
|
@ -82,7 +82,7 @@ describe ::DiscoursePoll::PollsController do
|
||||||
post_id: poll.id, poll_name: "poll", options: ["A"]
|
post_id: poll.id, poll_name: "poll", options: ["A"]
|
||||||
}, format: :json
|
}, format: :json
|
||||||
|
|
||||||
expect(response).not_to be_success
|
expect(response.status).not_to eq(200)
|
||||||
json = ::JSON.parse(response.body)
|
json = ::JSON.parse(response.body)
|
||||||
expect(json["errors"][0]).to eq(I18n.t("poll.post_is_deleted"))
|
expect(json["errors"][0]).to eq(I18n.t("poll.post_is_deleted"))
|
||||||
end
|
end
|
||||||
|
@ -94,7 +94,7 @@ describe ::DiscoursePoll::PollsController do
|
||||||
post_id: poll.id, poll_name: "poll", options: ["A"]
|
post_id: poll.id, poll_name: "poll", options: ["A"]
|
||||||
}, format: :json
|
}, format: :json
|
||||||
|
|
||||||
expect(response).not_to be_success
|
expect(response.status).not_to eq(200)
|
||||||
json = ::JSON.parse(response.body)
|
json = ::JSON.parse(response.body)
|
||||||
expect(json["errors"][0]).to eq(I18n.t("poll.user_cant_post_in_topic"))
|
expect(json["errors"][0]).to eq(I18n.t("poll.user_cant_post_in_topic"))
|
||||||
end
|
end
|
||||||
|
@ -104,7 +104,7 @@ describe ::DiscoursePoll::PollsController do
|
||||||
post_id: Fabricate(:post).id, poll_name: "foobar", options: ["A"]
|
post_id: Fabricate(:post).id, poll_name: "foobar", options: ["A"]
|
||||||
}, format: :json
|
}, format: :json
|
||||||
|
|
||||||
expect(response).not_to be_success
|
expect(response.status).not_to eq(200)
|
||||||
json = ::JSON.parse(response.body)
|
json = ::JSON.parse(response.body)
|
||||||
expect(json["errors"][0]).to eq(I18n.t("poll.no_polls_associated_with_this_post"))
|
expect(json["errors"][0]).to eq(I18n.t("poll.no_polls_associated_with_this_post"))
|
||||||
end
|
end
|
||||||
|
@ -114,7 +114,7 @@ describe ::DiscoursePoll::PollsController do
|
||||||
post_id: poll.id, poll_name: "foobar", options: ["A"]
|
post_id: poll.id, poll_name: "foobar", options: ["A"]
|
||||||
}, format: :json
|
}, format: :json
|
||||||
|
|
||||||
expect(response).not_to be_success
|
expect(response.status).not_to eq(200)
|
||||||
json = ::JSON.parse(response.body)
|
json = ::JSON.parse(response.body)
|
||||||
expect(json["errors"][0]).to eq(I18n.t("poll.no_poll_with_this_name", name: "foobar"))
|
expect(json["errors"][0]).to eq(I18n.t("poll.no_poll_with_this_name", name: "foobar"))
|
||||||
end
|
end
|
||||||
|
@ -126,7 +126,7 @@ describe ::DiscoursePoll::PollsController do
|
||||||
post_id: closed_poll.id, poll_name: "poll", options: ["5c24fc1df56d764b550ceae1b9319125"]
|
post_id: closed_poll.id, poll_name: "poll", options: ["5c24fc1df56d764b550ceae1b9319125"]
|
||||||
}, format: :json
|
}, format: :json
|
||||||
|
|
||||||
expect(response).not_to be_success
|
expect(response.status).not_to eq(200)
|
||||||
json = ::JSON.parse(response.body)
|
json = ::JSON.parse(response.body)
|
||||||
expect(json["errors"][0]).to eq(I18n.t("poll.poll_must_be_open_to_vote"))
|
expect(json["errors"][0]).to eq(I18n.t("poll.poll_must_be_open_to_vote"))
|
||||||
end
|
end
|
||||||
|
@ -139,7 +139,7 @@ describe ::DiscoursePoll::PollsController do
|
||||||
post_id: poll.id, poll_name: "poll", options: ["5c24fc1df56d764b550ceae1b9319125"]
|
post_id: poll.id, poll_name: "poll", options: ["5c24fc1df56d764b550ceae1b9319125"]
|
||||||
}, format: :json
|
}, format: :json
|
||||||
|
|
||||||
expect(response).to be_success
|
expect(response.status).to eq(200)
|
||||||
|
|
||||||
json = ::JSON.parse(response.body)
|
json = ::JSON.parse(response.body)
|
||||||
expect(json["poll"]["voters"]).to eq(18)
|
expect(json["poll"]["voters"]).to eq(18)
|
||||||
|
@ -157,7 +157,7 @@ describe ::DiscoursePoll::PollsController do
|
||||||
format: :json
|
format: :json
|
||||||
end.first
|
end.first
|
||||||
|
|
||||||
expect(response).to be_success
|
expect(response.status).to eq(200)
|
||||||
|
|
||||||
json = ::JSON.parse(response.body)
|
json = ::JSON.parse(response.body)
|
||||||
expect(json["poll"]["voters"]).to eq(1)
|
expect(json["poll"]["voters"]).to eq(1)
|
||||||
|
@ -172,7 +172,7 @@ describe ::DiscoursePoll::PollsController do
|
||||||
params: body.merge(options: ["e89dec30bbd9bf50fabf6a05b4324edf"]),
|
params: body.merge(options: ["e89dec30bbd9bf50fabf6a05b4324edf"]),
|
||||||
format: :json
|
format: :json
|
||||||
|
|
||||||
expect(response).to be_success
|
expect(response.status).to eq(200)
|
||||||
|
|
||||||
json = ::JSON.parse(response.body)
|
json = ::JSON.parse(response.body)
|
||||||
expect(json["poll"]["voters"]).to eq(1)
|
expect(json["poll"]["voters"]).to eq(1)
|
||||||
|
@ -188,7 +188,7 @@ describe ::DiscoursePoll::PollsController do
|
||||||
params: body.merge(options: ["e89dec30bbd9bf50fabf6a05b4324edf", "5c24fc1df56d764b550ceae1b9319125"]),
|
params: body.merge(options: ["e89dec30bbd9bf50fabf6a05b4324edf", "5c24fc1df56d764b550ceae1b9319125"]),
|
||||||
format: :json
|
format: :json
|
||||||
|
|
||||||
expect(response).to be_success
|
expect(response.status).to eq(200)
|
||||||
|
|
||||||
json = ::JSON.parse(response.body)
|
json = ::JSON.parse(response.body)
|
||||||
expect(json["poll"]["voters"]).to eq(2)
|
expect(json["poll"]["voters"]).to eq(2)
|
||||||
|
@ -208,7 +208,7 @@ describe ::DiscoursePoll::PollsController do
|
||||||
post_id: poll.id, poll_name: "poll", status: "closed"
|
post_id: poll.id, poll_name: "poll", status: "closed"
|
||||||
}, format: :json
|
}, format: :json
|
||||||
|
|
||||||
expect(response).to be_success
|
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")
|
||||||
end
|
end
|
||||||
|
@ -221,7 +221,7 @@ describe ::DiscoursePoll::PollsController do
|
||||||
post_id: poll.id, poll_name: "poll", status: "closed"
|
post_id: poll.id, poll_name: "poll", status: "closed"
|
||||||
}, format: :json
|
}, format: :json
|
||||||
|
|
||||||
expect(response).to be_success
|
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")
|
||||||
end
|
end
|
||||||
|
@ -233,7 +233,7 @@ describe ::DiscoursePoll::PollsController do
|
||||||
post_id: poll.id, poll_name: "poll", status: "closed"
|
post_id: poll.id, poll_name: "poll", status: "closed"
|
||||||
}, format: :json
|
}, format: :json
|
||||||
|
|
||||||
expect(response).not_to be_success
|
expect(response.status).not_to eq(200)
|
||||||
json = ::JSON.parse(response.body)
|
json = ::JSON.parse(response.body)
|
||||||
expect(json["errors"][0]).to eq(I18n.t("poll.post_is_deleted"))
|
expect(json["errors"][0]).to eq(I18n.t("poll.post_is_deleted"))
|
||||||
end
|
end
|
||||||
|
@ -253,7 +253,7 @@ describe ::DiscoursePoll::PollsController do
|
||||||
post_id: multi_poll.id, poll_name: "poll", options: [first]
|
post_id: multi_poll.id, poll_name: "poll", options: [first]
|
||||||
}, format: :json
|
}, format: :json
|
||||||
|
|
||||||
expect(response).to be_success
|
expect(response.status).to eq(200)
|
||||||
|
|
||||||
user2 = log_in
|
user2 = log_in
|
||||||
|
|
||||||
|
@ -261,7 +261,7 @@ describe ::DiscoursePoll::PollsController do
|
||||||
post_id: multi_poll.id, poll_name: "poll", options: [first]
|
post_id: multi_poll.id, poll_name: "poll", options: [first]
|
||||||
}, format: :json
|
}, format: :json
|
||||||
|
|
||||||
expect(response).to be_success
|
expect(response.status).to eq(200)
|
||||||
|
|
||||||
user3 = log_in
|
user3 = log_in
|
||||||
|
|
||||||
|
@ -271,13 +271,13 @@ describe ::DiscoursePoll::PollsController do
|
||||||
options: [first, second]
|
options: [first, second]
|
||||||
}, format: :json
|
}, format: :json
|
||||||
|
|
||||||
expect(response).to be_success
|
expect(response.status).to eq(200)
|
||||||
|
|
||||||
get :voters, params: {
|
get :voters, params: {
|
||||||
poll_name: 'poll', post_id: multi_poll.id, voter_limit: 2
|
poll_name: 'poll', post_id: multi_poll.id, voter_limit: 2
|
||||||
}, format: :json
|
}, format: :json
|
||||||
|
|
||||||
expect(response).to be_success
|
expect(response.status).to eq(200)
|
||||||
|
|
||||||
json = JSON.parse(response.body)
|
json = JSON.parse(response.body)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue