DEV: Use `response.parsed_body` in specs (#9615)
Most of it was autofixed with rubocop-discourse 2.1.1.
This commit is contained in:
parent
69ef0da4c2
commit
781e3f5e10
|
@ -25,7 +25,7 @@ describe ::DiscoursePoll::PollsController do
|
|||
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
json = ::JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json["poll"]["name"]).to eq("poll")
|
||||
expect(json["poll"]["voters"]).to eq(1)
|
||||
expect(json["vote"]).to eq(["5c24fc1df56d764b550ceae1b9319125"])
|
||||
|
@ -53,7 +53,7 @@ describe ::DiscoursePoll::PollsController do
|
|||
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
json = ::JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json["poll"]["name"]).to eq("poll")
|
||||
expect(json["poll"]["voters"]).to eq(1)
|
||||
expect(json["vote"]).to eq(["5c24fc1df56d764b550ceae1b9319125"])
|
||||
|
@ -80,7 +80,7 @@ describe ::DiscoursePoll::PollsController do
|
|||
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
json = ::JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json["poll"]["name"]).to eq("poll")
|
||||
expect(json["poll"]["voters"]).to eq(1)
|
||||
expect(json["vote"]).to eq(["5c24fc1df56d764b550ceae1b9319125"])
|
||||
|
@ -96,7 +96,7 @@ describe ::DiscoursePoll::PollsController do
|
|||
}, format: :json
|
||||
|
||||
expect(response.status).not_to eq(200)
|
||||
json = ::JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json["errors"][0]).to eq(I18n.t("poll.requires_at_least_1_valid_option"))
|
||||
end
|
||||
|
||||
|
@ -112,7 +112,7 @@ describe ::DiscoursePoll::PollsController do
|
|||
}, format: :json
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
json = ::JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json["poll"]["voters"]).to eq(1)
|
||||
expect(json["poll"]["options"][0]["votes"]).to eq(0)
|
||||
expect(json["poll"]["options"][1]["votes"]).to eq(1)
|
||||
|
@ -136,7 +136,7 @@ describe ::DiscoursePoll::PollsController do
|
|||
}, format: :json
|
||||
|
||||
expect(response.status).not_to eq(200)
|
||||
json = ::JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json["errors"][0]).to eq(I18n.t("poll.topic_must_be_open_to_vote"))
|
||||
end
|
||||
|
||||
|
@ -148,7 +148,7 @@ describe ::DiscoursePoll::PollsController do
|
|||
}, format: :json
|
||||
|
||||
expect(response.status).not_to eq(200)
|
||||
json = ::JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json["errors"][0]).to eq(I18n.t("poll.post_is_deleted"))
|
||||
end
|
||||
|
||||
|
@ -160,7 +160,7 @@ describe ::DiscoursePoll::PollsController do
|
|||
}, format: :json
|
||||
|
||||
expect(response.status).not_to eq(200)
|
||||
json = ::JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json["errors"][0]).to eq(I18n.t("poll.user_cant_post_in_topic"))
|
||||
end
|
||||
|
||||
|
@ -170,7 +170,7 @@ describe ::DiscoursePoll::PollsController do
|
|||
}, format: :json
|
||||
|
||||
expect(response.status).not_to eq(200)
|
||||
json = ::JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json["errors"][0]).to eq(I18n.t("poll.no_poll_with_this_name", name: "foobar"))
|
||||
end
|
||||
|
||||
|
@ -182,7 +182,7 @@ describe ::DiscoursePoll::PollsController do
|
|||
}, format: :json
|
||||
|
||||
expect(response.status).not_to eq(200)
|
||||
json = ::JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json["errors"][0]).to eq(I18n.t("poll.poll_must_be_open_to_vote"))
|
||||
end
|
||||
|
||||
|
@ -194,7 +194,7 @@ describe ::DiscoursePoll::PollsController do
|
|||
}, format: :json
|
||||
|
||||
expect(response.status).not_to eq(200)
|
||||
json = ::JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json["errors"][0]).to eq(I18n.t("js.poll.results.groups.title", groups: poll.polls.first.groups))
|
||||
end
|
||||
|
||||
|
@ -210,7 +210,7 @@ describe ::DiscoursePoll::PollsController do
|
|||
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
json = ::JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json["poll"]["voters"]).to eq(18)
|
||||
expect(json["poll"]["options"][0]["votes"]).to eq(12)
|
||||
expect(json["poll"]["options"][1]["votes"]).to eq(6)
|
||||
|
@ -230,7 +230,7 @@ describe ::DiscoursePoll::PollsController do
|
|||
expect(response.status).to eq(200)
|
||||
end.first
|
||||
|
||||
json = ::JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json["poll"]["status"]).to eq("closed")
|
||||
expect(message.channel).to eq(channel)
|
||||
end
|
||||
|
@ -248,7 +248,7 @@ describe ::DiscoursePoll::PollsController do
|
|||
expect(response.status).to eq(200)
|
||||
end.first
|
||||
|
||||
json = ::JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json["poll"]["status"]).to eq("closed")
|
||||
expect(message.channel).to eq(channel)
|
||||
end
|
||||
|
@ -261,7 +261,7 @@ describe ::DiscoursePoll::PollsController do
|
|||
}, format: :json
|
||||
|
||||
expect(response.status).not_to eq(200)
|
||||
json = ::JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json["errors"][0]).to eq(I18n.t("poll.post_is_deleted"))
|
||||
end
|
||||
|
||||
|
@ -303,7 +303,7 @@ describe ::DiscoursePoll::PollsController do
|
|||
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
json = JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
|
||||
# no user3 cause voter_limit is 2
|
||||
expect(json["voters"][first].map { |h| h["id"] }).to contain_exactly(user1.id, user2.id)
|
||||
|
@ -323,7 +323,7 @@ describe ::DiscoursePoll::PollsController do
|
|||
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
json = JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
|
||||
expect(json["voters"][first].size).to eq(1)
|
||||
|
||||
|
@ -347,7 +347,7 @@ describe ::DiscoursePoll::PollsController do
|
|||
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
json = JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
|
||||
expect(json["voters"][first].size).to eq(1)
|
||||
expect(json["voters"][second].size).to eq(1)
|
||||
|
@ -378,7 +378,7 @@ describe ::DiscoursePoll::PollsController do
|
|||
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
json = JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
|
||||
expect(json["voters"][first].size).to eq(1)
|
||||
end
|
||||
|
|
|
@ -17,7 +17,7 @@ describe PostsController do
|
|||
}, format: :json
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
json = ::JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json["cooked"]).to match("data-poll-")
|
||||
expect(Poll.exists?(post_id: json["id"])).to eq(true)
|
||||
end
|
||||
|
@ -30,7 +30,7 @@ describe PostsController do
|
|||
}, format: :json
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
json = ::JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json["cooked"]).to match("data-poll-")
|
||||
expect(Poll.exists?(post_id: json["id"])).to eq(true)
|
||||
end
|
||||
|
@ -49,7 +49,7 @@ describe PostsController do
|
|||
change { Poll.count }.by(1)
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
json = ::JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
post_id = json["id"]
|
||||
|
||||
expect(Poll.find_by(post_id: post_id).close_at).to eq_time(close_date)
|
||||
|
@ -67,7 +67,7 @@ describe PostsController do
|
|||
}, format: :json
|
||||
|
||||
expect(response).not_to be_successful
|
||||
json = ::JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json["errors"][0]).to eq(I18n.t("poll.default_poll_must_have_different_options"))
|
||||
end
|
||||
|
||||
|
@ -77,7 +77,7 @@ describe PostsController do
|
|||
}, format: :json
|
||||
|
||||
expect(response).not_to be_successful
|
||||
json = ::JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json["errors"][0]).to eq(I18n.t("poll.default_poll_must_have_at_least_1_option"))
|
||||
end
|
||||
|
||||
|
@ -91,7 +91,7 @@ describe PostsController do
|
|||
}, format: :json
|
||||
|
||||
expect(response).not_to be_successful
|
||||
json = ::JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json["errors"][0]).to eq(I18n.t("poll.default_poll_must_have_less_options", count: SiteSetting.poll_maximum_options))
|
||||
end
|
||||
|
||||
|
@ -101,7 +101,7 @@ describe PostsController do
|
|||
}, format: :json
|
||||
|
||||
expect(response).not_to be_successful
|
||||
json = ::JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json["errors"][0]).to eq(I18n.t("poll.default_poll_with_multiple_choices_has_invalid_parameters"))
|
||||
end
|
||||
|
||||
|
@ -111,7 +111,7 @@ describe PostsController do
|
|||
}, format: :json
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
json = ::JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json["cooked"]).to match("data-poll-")
|
||||
expect(json["cooked"]).to include("<script>")
|
||||
expect(Poll.find_by(post_id: json["id"]).name).to eq("<script>alert('xss')</script>")
|
||||
|
@ -123,7 +123,7 @@ describe PostsController do
|
|||
}, format: :json
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
json = ::JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json["cooked"]).to match("data-poll-")
|
||||
expect(Poll.exists?(post_id: json["id"])).to eq(true)
|
||||
end
|
||||
|
@ -134,7 +134,7 @@ describe PostsController do
|
|||
}, format: :json
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
json = ::JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json["cooked"]).to match("data-poll-")
|
||||
expect(Poll.where(post_id: json["id"]).count).to eq(1)
|
||||
end
|
||||
|
@ -149,7 +149,7 @@ describe PostsController do
|
|||
title: title, raw: "[poll]\n- A\n- B\n[/poll]"
|
||||
}, format: :json
|
||||
|
||||
::JSON.parse(response.body)["id"]
|
||||
response.parsed_body["id"]
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -159,7 +159,7 @@ describe PostsController do
|
|||
}, format: :json
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
json = ::JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json["post"]["polls"][0]["options"][2]["html"]).to eq("C")
|
||||
end
|
||||
|
||||
|
@ -171,7 +171,7 @@ describe PostsController do
|
|||
}, format: :json
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
json = ::JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json["post"]["polls_votes"]).to_not be
|
||||
end
|
||||
|
||||
|
@ -189,7 +189,7 @@ describe PostsController do
|
|||
title: title, raw: poll
|
||||
}, format: :json
|
||||
|
||||
::JSON.parse(response.body)["id"]
|
||||
response.parsed_body["id"]
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -207,14 +207,14 @@ describe PostsController do
|
|||
}, format: :json
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
json = ::JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json["post"]["polls"][0]["options"][1]["html"]).to eq("C")
|
||||
end
|
||||
|
||||
it "support changes on the post" do
|
||||
put :update, params: { id: post_id, post: { raw: updated } }, format: :json
|
||||
expect(response.status).to eq(200)
|
||||
json = ::JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json["post"]["cooked"]).to match("before")
|
||||
end
|
||||
|
||||
|
@ -232,7 +232,7 @@ describe PostsController do
|
|||
}, format: :json
|
||||
|
||||
expect(response).not_to be_successful
|
||||
json = ::JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json["errors"][0]).to eq(I18n.t(
|
||||
"poll.edit_window_expired.cannot_edit_default_poll_with_votes",
|
||||
minutes: poll_edit_window_mins
|
||||
|
@ -242,7 +242,7 @@ describe PostsController do
|
|||
it "support changes on the post" do
|
||||
put :update, params: { id: post_id, post: { raw: updated } }, format: :json
|
||||
expect(response.status).to eq(200)
|
||||
json = ::JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json["post"]["cooked"]).to match("before")
|
||||
end
|
||||
|
||||
|
@ -262,7 +262,7 @@ describe PostsController do
|
|||
}, format: :json
|
||||
|
||||
expect(response).not_to be_successful
|
||||
json = ::JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json["errors"][0]).to eq(I18n.t("poll.named_poll_must_have_different_options", name: "foo"))
|
||||
end
|
||||
|
||||
|
@ -272,7 +272,7 @@ describe PostsController do
|
|||
}, format: :json
|
||||
|
||||
expect(response).not_to be_successful
|
||||
json = ::JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json["errors"][0]).to eq(I18n.t("poll.named_poll_must_have_at_least_1_option", name: "foo"))
|
||||
end
|
||||
|
||||
|
@ -286,7 +286,7 @@ describe PostsController do
|
|||
}, format: :json
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
json = ::JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json["cooked"]).to match("data-poll-")
|
||||
expect(Poll.where(post_id: json["id"]).count).to eq(2)
|
||||
end
|
||||
|
@ -297,7 +297,7 @@ describe PostsController do
|
|||
}, format: :json
|
||||
|
||||
expect(response).not_to be_successful
|
||||
json = ::JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json["errors"][0]).to eq(I18n.t("poll.multiple_polls_without_name"))
|
||||
end
|
||||
|
||||
|
@ -307,7 +307,7 @@ describe PostsController do
|
|||
}, format: :json
|
||||
|
||||
expect(response).not_to be_successful
|
||||
json = ::JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json["errors"][0]).to eq(I18n.t("poll.multiple_polls_with_same_name", name: "foo"))
|
||||
end
|
||||
|
||||
|
@ -326,7 +326,7 @@ describe PostsController do
|
|||
}, format: :json
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
json = ::JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json["cooked"]).to eq("<p>[poll]</p>\n<ul>\n<li>A</li>\n<li>B<br>\n[/poll]</li>\n</ul>")
|
||||
end
|
||||
end
|
||||
|
@ -344,7 +344,7 @@ describe PostsController do
|
|||
}, format: :json
|
||||
|
||||
expect(response).not_to be_successful
|
||||
json = ::JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json["errors"][0]).to eq(I18n.t("poll.insufficient_rights_to_create"))
|
||||
end
|
||||
|
||||
|
@ -362,7 +362,7 @@ describe PostsController do
|
|||
topic_id: topic.id, raw: "[poll]\n- A\n- B\n[/poll]"
|
||||
}, format: :json
|
||||
|
||||
expect(::JSON.parse(response.body)["errors"]).to eq(nil)
|
||||
expect(response.parsed_body["errors"]).to eq(nil)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -379,7 +379,7 @@ describe PostsController do
|
|||
}, format: :json
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
json = ::JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json["cooked"]).to match("data-poll-")
|
||||
expect(Poll.exists?(post_id: json["id"])).to eq(true)
|
||||
end
|
||||
|
@ -398,7 +398,7 @@ describe PostsController do
|
|||
}, format: :json
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
json = ::JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json["cooked"]).to match("data-poll-")
|
||||
expect(Poll.exists?(post_id: json["id"])).to eq(true)
|
||||
end
|
||||
|
@ -417,7 +417,7 @@ describe PostsController do
|
|||
}, format: :json
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
json = ::JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json["cooked"]).to match("data-poll-")
|
||||
expect(Poll.exists?(post_id: json["id"])).to eq(true)
|
||||
end
|
||||
|
|
|
@ -24,7 +24,7 @@ describe "DiscoursePoll endpoints" do
|
|||
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
poll = JSON.parse(response.body)["voters"]
|
||||
poll = response.parsed_body["voters"]
|
||||
option = poll[option_a]
|
||||
|
||||
expect(option.length).to eq(1)
|
||||
|
@ -48,7 +48,7 @@ describe "DiscoursePoll endpoints" do
|
|||
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
poll = JSON.parse(response.body)["voters"]
|
||||
poll = response.parsed_body["voters"]
|
||||
|
||||
expect(poll[option_a]).to eq(nil)
|
||||
|
||||
|
@ -112,7 +112,7 @@ describe "DiscoursePoll endpoints" do
|
|||
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
poll = JSON.parse(response.body)["voters"]
|
||||
poll = response.parsed_body["voters"]
|
||||
|
||||
expect(poll.first["id"]).to eq(user.id)
|
||||
expect(poll.first["username"]).to eq(user.username)
|
||||
|
@ -165,7 +165,7 @@ describe "DiscoursePoll endpoints" do
|
|||
}
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
expect(JSON.parse(response.body).deep_symbolize_keys).to eq(
|
||||
expect(response.parsed_body.deep_symbolize_keys).to eq(
|
||||
grouped_results: [
|
||||
{ group: "Value0", options: [{ digest: option_a, html: "A", votes: 1 }, { digest: option_b, html: "B", votes: 0 }] },
|
||||
{ group: "Value1", options: [{ digest: option_a, html: "A", votes: 2 }, { digest: option_b, html: "B", votes: 1 }] },
|
||||
|
|
|
@ -24,7 +24,7 @@ describe 'invite only' do
|
|||
HTTP_API_USERNAME: admin.username
|
||||
}
|
||||
|
||||
user_id = JSON.parse(response.body)["user_id"]
|
||||
user_id = response.parsed_body["user_id"]
|
||||
expect(user_id).to be > 0
|
||||
|
||||
# activate and approve
|
||||
|
|
|
@ -74,7 +74,7 @@ describe 'rate limiter integration' do
|
|||
|
||||
expect(response.status).to eq(429)
|
||||
|
||||
data = JSON.parse(response.body)
|
||||
data = response.parsed_body
|
||||
|
||||
expect(response.headers['Retry-After']).to eq(60)
|
||||
expect(data["extras"]["wait_seconds"]).to eq(60)
|
||||
|
|
|
@ -22,7 +22,7 @@ describe Admin::ApiController do
|
|||
it "succeeds" do
|
||||
get "/admin/api/keys.json"
|
||||
expect(response.status).to eq(200)
|
||||
expect(JSON.parse(response.body)["keys"].length).to eq(2)
|
||||
expect(response.parsed_body["keys"].length).to eq(2)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -30,7 +30,7 @@ describe Admin::ApiController do
|
|||
it "succeeds" do
|
||||
get "/admin/api/keys/#{key1.id}.json"
|
||||
expect(response.status).to eq(200)
|
||||
data = JSON.parse(response.body)["key"]
|
||||
data = response.parsed_body["key"]
|
||||
expect(data["id"]).to eq(key1.id)
|
||||
expect(data["key"]).to eq(nil)
|
||||
expect(data["truncated_key"]).to eq(key1.key[0..3])
|
||||
|
@ -92,7 +92,7 @@ describe Admin::ApiController do
|
|||
}
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
data = JSON.parse(response.body)
|
||||
data = response.parsed_body
|
||||
|
||||
expect(data['key']['description']).to eq("master key description")
|
||||
expect(data['key']['user']).to eq(nil)
|
||||
|
@ -117,7 +117,7 @@ describe Admin::ApiController do
|
|||
}
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
data = JSON.parse(response.body)
|
||||
data = response.parsed_body
|
||||
|
||||
expect(data['key']['description']).to eq("restricted key description")
|
||||
expect(data['key']['user']['username']).to eq(user.username)
|
||||
|
|
|
@ -67,7 +67,7 @@ RSpec.describe Admin::BackupsController do
|
|||
get "/admin/backups.json"
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
filenames = JSON.parse(response.body).map { |backup| backup["filename"] }
|
||||
filenames = response.parsed_body.map { |backup| backup["filename"] }
|
||||
expect(filenames).to include(backup_filename)
|
||||
expect(filenames).to include(backup_filename2)
|
||||
end
|
||||
|
|
|
@ -27,7 +27,7 @@ describe Admin::BadgesController do
|
|||
}
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
expect(JSON.parse(response.body)["grant_count"]).to be > 0
|
||||
expect(response.parsed_body["grant_count"]).to be > 0
|
||||
end
|
||||
|
||||
it 'does not allow anything if enable_badge_sql is disabled' do
|
||||
|
@ -49,7 +49,7 @@ describe Admin::BadgesController do
|
|||
name: 'test', query: 'select 1 as user_id, null as granted_at', badge_type_id: 1
|
||||
}
|
||||
|
||||
json = JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(response.status).to eq(200)
|
||||
expect(json["badge"]["name"]).to eq('test')
|
||||
expect(json["badge"]["query"]).to eq('select 1 as user_id, null as granted_at')
|
||||
|
@ -76,7 +76,7 @@ describe Admin::BadgesController do
|
|||
|
||||
expect(groupings2.map { |g| g.name }).to eq(names)
|
||||
expect((groupings.map(&:id) - groupings2.map { |g| g.id }).compact).to be_blank
|
||||
expect(::JSON.parse(response.body)["badge_groupings"].length).to eq(groupings2.length)
|
||||
expect(response.parsed_body["badge_groupings"].length).to eq(groupings2.length)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -85,7 +85,7 @@ describe Admin::BadgesController do
|
|||
get "/admin/badges/types.json"
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
expect(::JSON.parse(response.body)["badge_types"]).to be_present
|
||||
expect(response.parsed_body["badge_types"]).to be_present
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@ describe Admin::ColorSchemesController do
|
|||
get "/admin/color_schemes.json"
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
schemes = JSON.parse(response.body).map { |scheme| scheme["name"] }
|
||||
schemes = response.parsed_body.map { |scheme| scheme["name"] }
|
||||
expect(schemes).to include(scheme_name)
|
||||
end
|
||||
end
|
||||
|
@ -38,7 +38,7 @@ describe Admin::ColorSchemesController do
|
|||
post "/admin/color_schemes.json", params: valid_params
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
expect(::JSON.parse(response.body)['id']).to be_present
|
||||
expect(response.parsed_body['id']).to be_present
|
||||
end
|
||||
|
||||
it "returns failure with invalid params" do
|
||||
|
@ -48,7 +48,7 @@ describe Admin::ColorSchemesController do
|
|||
post "/admin/color_schemes.json", params: valid_params
|
||||
|
||||
expect(response.status).to eq(422)
|
||||
expect(::JSON.parse(response.body)['errors']).to be_present
|
||||
expect(response.parsed_body['errors']).to be_present
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -77,7 +77,7 @@ describe Admin::ColorSchemesController do
|
|||
put "/admin/color_schemes/#{color_scheme.id}.json", params: params
|
||||
|
||||
expect(response.status).to eq(422)
|
||||
expect(::JSON.parse(response.body)['errors']).to be_present
|
||||
expect(response.parsed_body['errors']).to be_present
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ describe Admin::DashboardController do
|
|||
get "/admin/dashboard.json"
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
expect(JSON.parse(response.body)['version_check']).to be_present
|
||||
expect(response.parsed_body['version_check']).to be_present
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -41,7 +41,7 @@ describe Admin::DashboardController do
|
|||
it 'does not return discourse version info' do
|
||||
get "/admin/dashboard.json"
|
||||
expect(response.status).to eq(200)
|
||||
json = JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json['version_check']).not_to be_present
|
||||
end
|
||||
end
|
||||
|
@ -57,7 +57,7 @@ describe Admin::DashboardController do
|
|||
get "/admin/dashboard/problems.json"
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
json = JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json['problems'].size).to eq(0)
|
||||
end
|
||||
end
|
||||
|
@ -70,7 +70,7 @@ describe Admin::DashboardController do
|
|||
it 'returns an array of strings' do
|
||||
get "/admin/dashboard/problems.json"
|
||||
expect(response.status).to eq(200)
|
||||
json = JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json['problems'].size).to eq(2)
|
||||
expect(json['problems'][0]).to be_a(String)
|
||||
expect(json['problems'][1]).to be_a(String)
|
||||
|
|
|
@ -26,7 +26,7 @@ describe Admin::EmailController do
|
|||
|
||||
it 'does not include the password in the response' do
|
||||
get "/admin/email.json"
|
||||
mail_settings = JSON.parse(response.body)['settings']
|
||||
mail_settings = response.parsed_body['settings']
|
||||
|
||||
expect(
|
||||
mail_settings.select { |setting| setting['name'] == 'password' }
|
||||
|
@ -47,7 +47,7 @@ describe Admin::EmailController do
|
|||
get "/admin/email/sent.json"
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
log = JSON.parse(response.body).first
|
||||
log = response.parsed_body.first
|
||||
expect(log["id"]).to eq(email_log.id)
|
||||
expect(log["reply_key"]).to eq(nil)
|
||||
|
||||
|
@ -56,7 +56,7 @@ describe Admin::EmailController do
|
|||
get "/admin/email/sent.json"
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
log = JSON.parse(response.body).first
|
||||
log = response.parsed_body.first
|
||||
expect(log["id"]).to eq(email_log.id)
|
||||
expect(log["reply_key"]).to eq(post_reply_key.reply_key)
|
||||
end
|
||||
|
@ -80,7 +80,7 @@ describe Admin::EmailController do
|
|||
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
logs = JSON.parse(response.body)
|
||||
logs = response.parsed_body
|
||||
|
||||
expect(logs.size).to eq(1)
|
||||
expect(logs.first["reply_key"]).to eq(post_reply_key_2.reply_key)
|
||||
|
@ -98,7 +98,7 @@ describe Admin::EmailController do
|
|||
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
logs = JSON.parse(response.body)
|
||||
logs = response.parsed_body
|
||||
|
||||
expect(logs.first["id"]).to eq(log2.id)
|
||||
expect(logs.last["id"]).to eq(log1.id)
|
||||
|
@ -112,7 +112,7 @@ describe Admin::EmailController do
|
|||
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
logs = JSON.parse(response.body)
|
||||
logs = response.parsed_body
|
||||
|
||||
expect(logs.count).to eq(1)
|
||||
expect(logs.first["id"]).to eq(log1.id)
|
||||
|
@ -147,7 +147,7 @@ describe Admin::EmailController do
|
|||
admin.email
|
||||
)
|
||||
|
||||
incoming = JSON.parse(response.body)
|
||||
incoming = response.parsed_body
|
||||
expect(incoming['sent_test_email_message']).to eq(I18n.t("admin.email.sent_test"))
|
||||
end
|
||||
|
||||
|
@ -160,7 +160,7 @@ describe Admin::EmailController do
|
|||
eviltrout.email
|
||||
)
|
||||
|
||||
incoming = JSON.parse(response.body)
|
||||
incoming = response.parsed_body
|
||||
expect(incoming['sent_test_email_message']).to eq(I18n.t("admin.email.sent_test"))
|
||||
end
|
||||
|
||||
|
@ -173,7 +173,7 @@ describe Admin::EmailController do
|
|||
eviltrout.email
|
||||
)
|
||||
|
||||
incoming = JSON.parse(response.body)
|
||||
incoming = response.parsed_body
|
||||
expect(incoming['sent_test_email_message']).to eq(I18n.t("admin.email.sent_test"))
|
||||
end
|
||||
end
|
||||
|
@ -214,7 +214,7 @@ describe Admin::EmailController do
|
|||
Fabricate(:incoming_email, error: "")
|
||||
get "/admin/email/rejected.json"
|
||||
expect(response.status).to eq(200)
|
||||
rejected = JSON.parse(response.body)
|
||||
rejected = response.parsed_body
|
||||
expect(rejected.first['error']).to eq(I18n.t("emails.incoming.unrecognized_error"))
|
||||
end
|
||||
end
|
||||
|
@ -224,7 +224,7 @@ describe Admin::EmailController do
|
|||
incoming_email = Fabricate(:incoming_email, error: "")
|
||||
get "/admin/email/incoming/#{incoming_email.id}.json"
|
||||
expect(response.status).to eq(200)
|
||||
incoming = JSON.parse(response.body)
|
||||
incoming = response.parsed_body
|
||||
expect(incoming['error']).to eq(I18n.t("emails.incoming.unrecognized_error"))
|
||||
end
|
||||
end
|
||||
|
@ -234,7 +234,7 @@ describe Admin::EmailController do
|
|||
get "/admin/email/incoming_from_bounced/12345.json"
|
||||
expect(response.status).to eq(404)
|
||||
|
||||
json = JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json["errors"]).to include("Discourse::InvalidParameters")
|
||||
end
|
||||
|
||||
|
@ -242,7 +242,7 @@ describe Admin::EmailController do
|
|||
get "/admin/email/incoming_from_bounced/#{email_log.id}.json"
|
||||
expect(response.status).to eq(404)
|
||||
|
||||
json = JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json["errors"]).to include("Discourse::InvalidParameters")
|
||||
end
|
||||
|
||||
|
@ -262,7 +262,7 @@ describe Admin::EmailController do
|
|||
get "/admin/email/incoming_from_bounced/#{email_log.id}.json"
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
json = JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json["error"]).to eq(error_message)
|
||||
end
|
||||
|
||||
|
@ -276,7 +276,7 @@ describe Admin::EmailController do
|
|||
get "/admin/email/incoming_from_bounced/#{email_log.id}.json"
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
json = JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json["error"]).to eq(error_message)
|
||||
end
|
||||
|
||||
|
@ -286,7 +286,7 @@ describe Admin::EmailController do
|
|||
get "/admin/email/incoming_from_bounced/#{email_log.id}.json"
|
||||
expect(response.status).to eq(404)
|
||||
|
||||
json = JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json["errors"]).to include("Discourse::InvalidParameters")
|
||||
end
|
||||
|
||||
|
@ -294,7 +294,7 @@ describe Admin::EmailController do
|
|||
get "/admin/email/incoming_from_bounced/#{email_log.id}.json"
|
||||
expect(response.status).to eq(404)
|
||||
|
||||
json = JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json["errors"]).to include("Discourse::NotFound")
|
||||
end
|
||||
end
|
||||
|
@ -317,7 +317,7 @@ describe Admin::EmailController do
|
|||
EMAIL
|
||||
post "/admin/email/advanced-test.json", params: { email: email }
|
||||
expect(response.status).to eq(200)
|
||||
incoming = JSON.parse(response.body)
|
||||
incoming = response.parsed_body
|
||||
expect(incoming['format']).to eq(1)
|
||||
expect(incoming['text']).to eq("Hello, this is a test!")
|
||||
expect(incoming['elided']).to eq("---\n\nThis part should be elided.")
|
||||
|
|
|
@ -21,7 +21,7 @@ describe Admin::EmailStylesController do
|
|||
get '/admin/customize/email_style.json'
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
json = ::JSON.parse(response.body)['email_style']
|
||||
json = response.parsed_body['email_style']
|
||||
expect(json['html']).to eq(default_html)
|
||||
expect(json['css']).to eq(default_css)
|
||||
end
|
||||
|
@ -32,7 +32,7 @@ describe Admin::EmailStylesController do
|
|||
get '/admin/customize/email_style.json'
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
json = ::JSON.parse(response.body)['email_style']
|
||||
json = response.parsed_body['email_style']
|
||||
expect(json['html']).to eq("For you: %{email_content}")
|
||||
expect(json['css']).to eq(".user-name { font-size: 24px; }")
|
||||
end
|
||||
|
@ -59,7 +59,7 @@ describe Admin::EmailStylesController do
|
|||
email_style: valid_params.merge(html: 'No email content')
|
||||
}
|
||||
expect(response.status).to eq(422)
|
||||
json = JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json['errors']).to include(
|
||||
I18n.t(
|
||||
'email_style.html_missing_placeholder',
|
||||
|
|
|
@ -37,7 +37,7 @@ RSpec.describe Admin::EmailTemplatesController do
|
|||
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
json = ::JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json['email_templates']).to be_present
|
||||
end
|
||||
|
||||
|
@ -51,7 +51,7 @@ RSpec.describe Admin::EmailTemplatesController do
|
|||
|
||||
get '/admin/customize/email_templates.json'
|
||||
expect(response.status).to eq(200)
|
||||
templates = JSON.parse(response.body)['email_templates']
|
||||
templates = response.parsed_body['email_templates']
|
||||
template = templates.find { |t| t['id'] == 'user_notifications.admin_login' }
|
||||
expect(template['can_revert']).to eq(true)
|
||||
|
||||
|
@ -59,7 +59,7 @@ RSpec.describe Admin::EmailTemplatesController do
|
|||
|
||||
get '/admin/customize/email_templates.json'
|
||||
expect(response.status).to eq(200)
|
||||
templates = JSON.parse(response.body)['email_templates']
|
||||
templates = response.parsed_body['email_templates']
|
||||
template = templates.find { |t| t['id'] == 'user_notifications.admin_login' }
|
||||
expect(template['can_revert']).to eq(false)
|
||||
end
|
||||
|
@ -93,7 +93,7 @@ RSpec.describe Admin::EmailTemplatesController do
|
|||
|
||||
expect(response).not_to be_successful
|
||||
|
||||
json = ::JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json['error_type']).to eq('not_found')
|
||||
end
|
||||
|
||||
|
@ -103,7 +103,7 @@ RSpec.describe Admin::EmailTemplatesController do
|
|||
email_template: { subject: email_subject, body: email_body }
|
||||
}, headers: headers
|
||||
|
||||
json = ::JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json).to be_present
|
||||
|
||||
errors = json['errors']
|
||||
|
@ -196,7 +196,7 @@ RSpec.describe Admin::EmailTemplatesController do
|
|||
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
json = ::JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json).to be_present
|
||||
|
||||
template = json['email_template']
|
||||
|
@ -279,7 +279,7 @@ RSpec.describe Admin::EmailTemplatesController do
|
|||
delete '/admin/customize/email_templates/non_existent_template', headers: headers
|
||||
expect(response).not_to be_successful
|
||||
|
||||
json = ::JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json['error_type']).to eq('not_found')
|
||||
end
|
||||
|
||||
|
@ -307,7 +307,7 @@ RSpec.describe Admin::EmailTemplatesController do
|
|||
delete '/admin/customize/email_templates/user_notifications.admin_login', headers: headers
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
json = ::JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json).to be_present
|
||||
|
||||
template = json['email_template']
|
||||
|
|
|
@ -18,7 +18,7 @@ RSpec.describe Admin::EmojisController do
|
|||
get "/admin/customize/emojis.json"
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
json = ::JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json[0]["name"]).to eq("osama-test-emoji")
|
||||
expect(json[0]["url"]).to eq(upload.url)
|
||||
end
|
||||
|
@ -34,7 +34,7 @@ RSpec.describe Admin::EmojisController do
|
|||
}
|
||||
|
||||
expect(response.status).to eq(422)
|
||||
parsed = JSON.parse(response.body)
|
||||
parsed = response.parsed_body
|
||||
expect(parsed["errors"]).to eq([I18n.t('upload.images.size_not_found')])
|
||||
end
|
||||
end
|
||||
|
@ -49,7 +49,7 @@ RSpec.describe Admin::EmojisController do
|
|||
}
|
||||
|
||||
expect(response.status).to eq(422)
|
||||
parsed = JSON.parse(response.body)
|
||||
parsed = response.parsed_body
|
||||
expect(parsed["errors"]).to eq([
|
||||
"Name #{I18n.t('activerecord.errors.models.custom_emoji.attributes.name.taken')}"
|
||||
])
|
||||
|
@ -69,7 +69,7 @@ RSpec.describe Admin::EmojisController do
|
|||
|
||||
expect(upload.original_filename).to eq('logo.png')
|
||||
|
||||
data = JSON.parse(response.body)
|
||||
data = response.parsed_body
|
||||
expect(response.status).to eq(200)
|
||||
expect(data["errors"]).to eq(nil)
|
||||
expect(data["name"]).to eq(custom_emoji.name)
|
||||
|
@ -88,7 +88,7 @@ RSpec.describe Admin::EmojisController do
|
|||
|
||||
custom_emoji = CustomEmoji.last
|
||||
|
||||
data = JSON.parse(response.body)
|
||||
data = response.parsed_body
|
||||
expect(response.status).to eq(200)
|
||||
expect(custom_emoji.group).to eq("foo")
|
||||
end
|
||||
|
|
|
@ -88,7 +88,7 @@ RSpec.describe Admin::GroupsController do
|
|||
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
response_body = JSON.parse(response.body)
|
||||
response_body = response.parsed_body
|
||||
|
||||
expect(response_body["usernames"]).to contain_exactly(user.username, admin.username)
|
||||
|
||||
|
@ -190,7 +190,7 @@ RSpec.describe Admin::GroupsController do
|
|||
expect(user2.title).to eq("WAT")
|
||||
expect(user2.trust_level).to eq(4)
|
||||
|
||||
json = ::JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json['message']).to eq("2 users have been added to the group.")
|
||||
expect(json['users_not_added'][0]).to eq("doesnt_exist")
|
||||
end
|
||||
|
|
|
@ -24,7 +24,7 @@ describe Admin::PermalinksController do
|
|||
get "/admin/permalinks.json", params: { filter: "topic" }
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
result = JSON.parse(response.body)
|
||||
result = response.parsed_body
|
||||
expect(result.length).to eq(2)
|
||||
end
|
||||
|
||||
|
@ -37,7 +37,7 @@ describe Admin::PermalinksController do
|
|||
get "/admin/permalinks.json", params: { filter: "discourse" }
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
result = JSON.parse(response.body)
|
||||
result = response.parsed_body
|
||||
expect(result.length).to eq(2)
|
||||
end
|
||||
|
||||
|
@ -50,7 +50,7 @@ describe Admin::PermalinksController do
|
|||
get "/admin/permalinks.json", params: { filter: "discourse" }
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
result = JSON.parse(response.body)
|
||||
result = response.parsed_body
|
||||
expect(result.length).to eq(3)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -16,7 +16,7 @@ describe Admin::PluginsController do
|
|||
it 'should return JSON' do
|
||||
get "/admin/plugins.json"
|
||||
expect(response.status).to eq(200)
|
||||
expect(::JSON.parse(response.body).has_key?('plugins')).to eq(true)
|
||||
expect(response.parsed_body.has_key?('plugins')).to eq(true)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -27,7 +27,7 @@ describe Admin::ReportsController do
|
|||
}
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
expect(JSON.parse(response.body)["reports"].count).to eq(2)
|
||||
expect(response.parsed_body["reports"].count).to eq(2)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -42,9 +42,9 @@ describe Admin::ReportsController do
|
|||
}
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
expect(JSON.parse(response.body)["reports"].count).to eq(2)
|
||||
expect(JSON.parse(response.body)["reports"][0]["type"]).to eq("topics")
|
||||
expect(JSON.parse(response.body)["reports"][1]["type"]).to eq("not_found")
|
||||
expect(response.parsed_body["reports"].count).to eq(2)
|
||||
expect(response.parsed_body["reports"][0]["type"]).to eq("topics")
|
||||
expect(response.parsed_body["reports"][1]["type"]).to eq("not_found")
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -92,7 +92,7 @@ describe Admin::ReportsController do
|
|||
get "/admin/reports/topics.json"
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
expect(JSON.parse(response.body)["report"]["total"]).to eq(1)
|
||||
expect(response.parsed_body["report"]["total"]).to eq(1)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -107,7 +107,7 @@ describe Admin::ReportsController do
|
|||
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
report = JSON.parse(response.body)["report"]
|
||||
report = response.parsed_body["report"]
|
||||
|
||||
expect(report["type"]).to eq('topics')
|
||||
expect(report["data"].count).to eq(1)
|
||||
|
@ -126,7 +126,7 @@ describe Admin::ReportsController do
|
|||
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
report = JSON.parse(response.body)["report"]
|
||||
report = response.parsed_body["report"]
|
||||
|
||||
expect(report["type"]).to eq('signups')
|
||||
expect(report["data"].count).to eq(1)
|
||||
|
|
|
@ -38,7 +38,7 @@ describe Admin::RobotsTxtController do
|
|||
it "returns default content if there are no overrides" do
|
||||
get "/admin/customize/robots.json"
|
||||
expect(response.status).to eq(200)
|
||||
json = JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json["robots_txt"]).to be_present
|
||||
expect(json["overridden"]).to eq(false)
|
||||
end
|
||||
|
@ -47,7 +47,7 @@ describe Admin::RobotsTxtController do
|
|||
SiteSetting.overridden_robots_txt = "something"
|
||||
get "/admin/customize/robots.json"
|
||||
expect(response.status).to eq(200)
|
||||
json = JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json["robots_txt"]).to eq("something")
|
||||
expect(json["overridden"]).to eq(true)
|
||||
end
|
||||
|
@ -59,7 +59,7 @@ describe Admin::RobotsTxtController do
|
|||
it "overrides the site's default robots.txt" do
|
||||
put "/admin/customize/robots.json", params: { robots_txt: "new_content" }
|
||||
expect(response.status).to eq(200)
|
||||
json = JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json["robots_txt"]).to eq("new_content")
|
||||
expect(json["overridden"]).to eq(true)
|
||||
expect(SiteSetting.overridden_robots_txt).to eq("new_content")
|
||||
|
@ -82,7 +82,7 @@ describe Admin::RobotsTxtController do
|
|||
SiteSetting.overridden_robots_txt = "overridden_content"
|
||||
delete "/admin/customize/robots.json"
|
||||
expect(response.status).to eq(200)
|
||||
json = JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json["robots_txt"]).not_to include("overridden_content")
|
||||
expect(json["overridden"]).to eq(false)
|
||||
expect(SiteSetting.overridden_robots_txt).to eq("")
|
||||
|
|
|
@ -16,7 +16,7 @@ describe Admin::ScreenedEmailsController do
|
|||
Fabricate(:screened_email)
|
||||
get "/admin/logs/screened_emails.json"
|
||||
expect(response.status).to eq(200)
|
||||
json = JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json.size).to eq(1)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -24,13 +24,13 @@ describe Admin::ScreenedIpAddressesController do
|
|||
get "/admin/logs/screened_ip_addresses.json", params: { filter: "1.2.*" }
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
result = JSON.parse(response.body)
|
||||
result = response.parsed_body
|
||||
expect(result.length).to eq(3)
|
||||
|
||||
get "/admin/logs/screened_ip_addresses.json", params: { filter: "4.5.6.7" }
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
result = JSON.parse(response.body)
|
||||
result = response.parsed_body
|
||||
expect(result.length).to eq(1)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -16,7 +16,7 @@ describe Admin::ScreenedUrlsController do
|
|||
Fabricate(:screened_url)
|
||||
get "/admin/logs/screened_urls.json"
|
||||
expect(response.status).to eq(200)
|
||||
json = JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json.size).to eq(1)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -32,7 +32,7 @@ RSpec.describe Admin::SearchLogsController do
|
|||
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
json = ::JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json[0]['term']).to eq('ruby')
|
||||
expect(json[0]['searches']).to eq(1)
|
||||
expect(json[0]['ctr']).to eq(0)
|
||||
|
@ -67,7 +67,7 @@ RSpec.describe Admin::SearchLogsController do
|
|||
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
json = ::JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json['term']['type']).to eq('search_log_term')
|
||||
expect(json['term']['search_result']).to be_present
|
||||
end
|
||||
|
|
|
@ -19,7 +19,7 @@ describe Admin::SiteSettingsController do
|
|||
it 'returns valid info' do
|
||||
get "/admin/site_settings.json"
|
||||
expect(response.status).to eq(200)
|
||||
json = ::JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json["site_settings"].length).to be > 100
|
||||
|
||||
locale = json["site_settings"].select do |s|
|
||||
|
@ -183,7 +183,7 @@ describe Admin::SiteSettingsController do
|
|||
default_categories_watching: category_id
|
||||
}
|
||||
|
||||
expect(JSON.parse(response.body)["user_count"]).to eq(User.count)
|
||||
expect(response.parsed_body["user_count"]).to eq(User.count)
|
||||
|
||||
CategoryUser.create!(category_id: category_id, notification_level: tracking, user: user)
|
||||
|
||||
|
@ -191,7 +191,7 @@ describe Admin::SiteSettingsController do
|
|||
default_categories_watching: category_id
|
||||
}
|
||||
|
||||
expect(JSON.parse(response.body)["user_count"]).to eq(User.count - 1)
|
||||
expect(response.parsed_body["user_count"]).to eq(User.count - 1)
|
||||
|
||||
SiteSetting.setting(:default_categories_watching, "")
|
||||
end
|
||||
|
@ -203,7 +203,7 @@ describe Admin::SiteSettingsController do
|
|||
default_tags_watching: tag.name
|
||||
}
|
||||
|
||||
expect(JSON.parse(response.body)["user_count"]).to eq(User.count)
|
||||
expect(response.parsed_body["user_count"]).to eq(User.count)
|
||||
|
||||
TagUser.create!(tag_id: tag.id, notification_level: tracking, user: user)
|
||||
|
||||
|
@ -211,7 +211,7 @@ describe Admin::SiteSettingsController do
|
|||
default_tags_watching: tag.name
|
||||
}
|
||||
|
||||
expect(JSON.parse(response.body)["user_count"]).to eq(User.count - 1)
|
||||
expect(response.parsed_body["user_count"]).to eq(User.count - 1)
|
||||
|
||||
SiteSetting.setting(:default_tags_watching, "")
|
||||
end
|
||||
|
|
|
@ -48,35 +48,35 @@ RSpec.describe Admin::SiteTextsController do
|
|||
it 'returns json' do
|
||||
get "/admin/customize/site_texts.json", params: { q: 'title' }
|
||||
expect(response.status).to eq(200)
|
||||
expect(JSON.parse(response.body)['site_texts']).to include(include("id" => "title"))
|
||||
expect(response.parsed_body['site_texts']).to include(include("id" => "title"))
|
||||
end
|
||||
|
||||
it 'sets has_more to true if more than 50 results were found' do
|
||||
get "/admin/customize/site_texts.json", params: { q: 'e' }
|
||||
expect(response.status).to eq(200)
|
||||
expect(JSON.parse(response.body)['site_texts'].size).to eq(50)
|
||||
expect(JSON.parse(response.body)['extras']['has_more']).to be_truthy
|
||||
expect(response.parsed_body['site_texts'].size).to eq(50)
|
||||
expect(response.parsed_body['extras']['has_more']).to be_truthy
|
||||
end
|
||||
|
||||
it 'works with pages' do
|
||||
texts = Set.new
|
||||
|
||||
get "/admin/customize/site_texts.json", params: { q: 'e' }
|
||||
JSON.parse(response.body)['site_texts'].each { |text| texts << text['id'] }
|
||||
response.parsed_body['site_texts'].each { |text| texts << text['id'] }
|
||||
expect(texts.size).to eq(50)
|
||||
|
||||
get "/admin/customize/site_texts.json", params: { q: 'e', page: 1 }
|
||||
JSON.parse(response.body)['site_texts'].each { |text| texts << text['id'] }
|
||||
response.parsed_body['site_texts'].each { |text| texts << text['id'] }
|
||||
expect(texts.size).to eq(100)
|
||||
end
|
||||
|
||||
it 'works with locales' do
|
||||
get "/admin/customize/site_texts.json", params: { q: 'yes_value', locale: 'en' }
|
||||
value = JSON.parse(response.body)['site_texts'].find { |text| text['id'] == 'js.yes_value' }['value']
|
||||
value = response.parsed_body['site_texts'].find { |text| text['id'] == 'js.yes_value' }['value']
|
||||
expect(value).to eq(I18n.with_locale(:en) { I18n.t('js.yes_value') })
|
||||
|
||||
get "/admin/customize/site_texts.json", params: { q: 'yes_value', locale: 'de' }
|
||||
value = JSON.parse(response.body)['site_texts'].find { |text| text['id'] == 'js.yes_value' }['value']
|
||||
value = response.parsed_body['site_texts'].find { |text| text['id'] == 'js.yes_value' }['value']
|
||||
expect(value).to eq(I18n.with_locale(:de) { I18n.t('js.yes_value') })
|
||||
end
|
||||
|
||||
|
@ -99,7 +99,7 @@ RSpec.describe Admin::SiteTextsController do
|
|||
].each do |search_term|
|
||||
get "/admin/customize/site_texts.json", params: { q: search_term }
|
||||
expect(response.status).to eq(200)
|
||||
expect(JSON.parse(response.body)['site_texts']).to include(include("id" => "title", "value" => value))
|
||||
expect(response.parsed_body['site_texts']).to include(include("id" => "title", "value" => value))
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -114,7 +114,7 @@ RSpec.describe Admin::SiteTextsController do
|
|||
].each do |search_term|
|
||||
get "/admin/customize/site_texts.json", params: { q: search_term }
|
||||
expect(response.status).to eq(200)
|
||||
expect(JSON.parse(response.body)['site_texts']).to include(include("id" => "embed.loading", "value" => value))
|
||||
expect(response.parsed_body['site_texts']).to include(include("id" => "embed.loading", "value" => value))
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -125,11 +125,11 @@ RSpec.describe Admin::SiteTextsController do
|
|||
|
||||
get "/admin/customize/site_texts.json", params: { q: 'missing_plural_key' }
|
||||
expect(response.status).to eq(200)
|
||||
expect(JSON.parse(response.body)['site_texts']).to be_empty
|
||||
expect(response.parsed_body['site_texts']).to be_empty
|
||||
|
||||
get "/admin/customize/site_texts.json", params: { q: 'another_missing_key' }
|
||||
expect(response.status).to eq(200)
|
||||
expect(JSON.parse(response.body)['site_texts']).to be_empty
|
||||
expect(response.parsed_body['site_texts']).to be_empty
|
||||
end
|
||||
|
||||
context 'plural keys' do
|
||||
|
@ -205,7 +205,7 @@ RSpec.describe Admin::SiteTextsController do
|
|||
get "/admin/customize/site_texts/js.topic.list.json"
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
json = ::JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
|
||||
site_text = json['site_text']
|
||||
|
||||
|
@ -217,7 +217,7 @@ RSpec.describe Admin::SiteTextsController do
|
|||
get "/admin/customize/site_texts/js.emoji_picker.food_&_drink.json"
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
json = ::JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
|
||||
site_text = json['site_text']
|
||||
|
||||
|
@ -239,14 +239,14 @@ RSpec.describe Admin::SiteTextsController do
|
|||
|
||||
get "/admin/customize/site_texts/#{key}.json"
|
||||
expect(response.status).to eq(200)
|
||||
json = JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json['site_text']['overridden']).to eq(true)
|
||||
|
||||
TranslationOverride.destroy_all
|
||||
|
||||
get "/admin/customize/site_texts/#{key}.json"
|
||||
expect(response.status).to eq(200)
|
||||
json = JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json['site_text']['overridden']).to eq(false)
|
||||
end
|
||||
|
||||
|
@ -265,7 +265,7 @@ RSpec.describe Admin::SiteTextsController do
|
|||
get "/admin/customize/site_texts/#{id}.json"
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
json = ::JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json).to be_present
|
||||
|
||||
site_text = json['site_text']
|
||||
|
@ -312,7 +312,7 @@ RSpec.describe Admin::SiteTextsController do
|
|||
|
||||
expect(response.status).to eq(404)
|
||||
|
||||
json = JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json['error_type']).to eq('not_found')
|
||||
end
|
||||
|
||||
|
@ -323,7 +323,7 @@ RSpec.describe Admin::SiteTextsController do
|
|||
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
json = ::JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
site_text = json['site_text']
|
||||
|
||||
expect(site_text['id']).to eq('js.emoji_picker.animals_&_nature')
|
||||
|
@ -337,7 +337,7 @@ RSpec.describe Admin::SiteTextsController do
|
|||
|
||||
expect(response.status).to eq(403)
|
||||
|
||||
json = ::JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json['error_type']).to eq('invalid_access')
|
||||
expect(json['errors'].size).to eq(1)
|
||||
expect(json['errors'].first).to eq(I18n.t('email_template_cant_be_modified'))
|
||||
|
@ -352,7 +352,7 @@ RSpec.describe Admin::SiteTextsController do
|
|||
|
||||
expect(response.status).to eq(422)
|
||||
|
||||
body = JSON.parse(response.body)
|
||||
body = response.parsed_body
|
||||
|
||||
expect(body['message']).to eq(I18n.t(
|
||||
'activerecord.errors.models.translation_overrides.attributes.value.invalid_interpolation_keys',
|
||||
|
@ -390,7 +390,7 @@ RSpec.describe Admin::SiteTextsController do
|
|||
put "/admin/customize/site_texts/title.json", params: { site_text: { value: 'hello' } }
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
json = ::JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
|
||||
site_text = json['site_text']
|
||||
|
||||
|
@ -401,7 +401,7 @@ RSpec.describe Admin::SiteTextsController do
|
|||
delete "/admin/customize/site_texts/title.json"
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
json = ::JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
|
||||
site_text = json['site_text']
|
||||
|
||||
|
@ -422,24 +422,24 @@ RSpec.describe Admin::SiteTextsController do
|
|||
|
||||
get "/admin/customize/site_texts/title.json"
|
||||
expect(response.status).to eq(200)
|
||||
json = ::JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json['site_text']['value']).to eq(ru_title)
|
||||
|
||||
get "/admin/customize/site_texts/js.topic.read_more_MF.json"
|
||||
expect(response.status).to eq(200)
|
||||
json = ::JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json['site_text']['value']).to eq(ru_mf_text)
|
||||
|
||||
SiteSetting.default_locale = :en
|
||||
|
||||
get "/admin/customize/site_texts/title.json"
|
||||
expect(response.status).to eq(200)
|
||||
json = ::JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json['site_text']['value']).to_not eq(ru_title)
|
||||
|
||||
get "/admin/customize/site_texts/js.topic.read_more_MF.json"
|
||||
expect(response.status).to eq(200)
|
||||
json = ::JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json['site_text']['value']).to_not eq(ru_mf_text)
|
||||
end
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ describe Admin::StaffActionLogsController do
|
|||
|
||||
get "/admin/logs/staff_action_logs.json", params: { action_id: UserHistory.actions[:delete_topic] }
|
||||
|
||||
json = JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
expect(json["staff_action_logs"].length).to eq(1)
|
||||
|
@ -38,14 +38,14 @@ describe Admin::StaffActionLogsController do
|
|||
|
||||
get "/admin/logs/staff_action_logs.json", params: { limit: 3 }
|
||||
|
||||
json = JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(response.status).to eq(200)
|
||||
expect(json["staff_action_logs"].length).to eq(3)
|
||||
expect(json["staff_action_logs"][0]["new_value"]).to eq("value 4")
|
||||
|
||||
get "/admin/logs/staff_action_logs.json", params: { limit: 3, page: 1 }
|
||||
|
||||
json = JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(response.status).to eq(200)
|
||||
expect(json["staff_action_logs"].length).to eq(1)
|
||||
expect(json["staff_action_logs"][0]["new_value"]).to eq("value 1")
|
||||
|
@ -59,7 +59,7 @@ describe Admin::StaffActionLogsController do
|
|||
it 'Uses the custom_staff id' do
|
||||
get "/admin/logs/staff_action_logs.json", params: {}
|
||||
|
||||
json = JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
action = json['extras']['user_history_actions'].first
|
||||
|
||||
expect(action['id']).to eq plugin_extended_action.to_s
|
||||
|
@ -84,7 +84,7 @@ describe Admin::StaffActionLogsController do
|
|||
get "/admin/logs/staff_action_logs/#{record.id}/diff.json"
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
parsed = JSON.parse(response.body)
|
||||
parsed = response.parsed_body
|
||||
expect(parsed["side_by_side"]).to include("up")
|
||||
expect(parsed["side_by_side"]).to include("down")
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ describe Admin::ThemesController do
|
|||
it 'can generate key pairs' do
|
||||
post "/admin/themes/generate_key_pair.json"
|
||||
expect(response.status).to eq(200)
|
||||
json = JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json["private_key"]).to include("RSA PRIVATE KEY")
|
||||
expect(json["public_key"]).to include("ssh-rsa ")
|
||||
end
|
||||
|
@ -35,12 +35,12 @@ describe Admin::ThemesController do
|
|||
upload = Upload.find_by(original_filename: "fake.woff2")
|
||||
|
||||
expect(upload.id).not_to be_nil
|
||||
expect(JSON.parse(response.body)["upload_id"]).to eq(upload.id)
|
||||
expect(response.parsed_body["upload_id"]).to eq(upload.id)
|
||||
end
|
||||
|
||||
context "when trying to upload an existing file" do
|
||||
let(:uploaded_file) { Upload.find_by(original_filename: "fake.woff2") }
|
||||
let(:response_json) { JSON.parse(response.body) }
|
||||
let(:response_json) { response.parsed_body }
|
||||
|
||||
before do
|
||||
post "/admin/themes/upload_asset.json", params: { file: upload }
|
||||
|
@ -77,7 +77,7 @@ describe Admin::ThemesController do
|
|||
expect(response.status).to eq(201)
|
||||
end.to change { Theme.count }.by (1)
|
||||
|
||||
json = ::JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
|
||||
expect(json["theme"]["name"]).to eq("Awesome Theme")
|
||||
expect(json["theme"]["theme_fields"].length).to eq(3)
|
||||
|
@ -110,7 +110,7 @@ describe Admin::ThemesController do
|
|||
post "/admin/themes/import.json", params: { theme: theme_json_file }
|
||||
expect(response.status).to eq(201)
|
||||
|
||||
json = ::JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
|
||||
expect(json["theme"]["name"]).to eq("Sam's Simple Theme")
|
||||
expect(json["theme"]["theme_fields"].length).to eq(2)
|
||||
|
@ -124,7 +124,7 @@ describe Admin::ThemesController do
|
|||
post "/admin/themes/import.json", params: { theme: theme_archive }
|
||||
end.to change { Theme.count }.by (1)
|
||||
expect(response.status).to eq(201)
|
||||
json = ::JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
|
||||
expect(json["theme"]["name"]).to eq("Header Icons")
|
||||
expect(json["theme"]["theme_fields"].length).to eq(5)
|
||||
|
@ -139,7 +139,7 @@ describe Admin::ThemesController do
|
|||
post "/admin/themes/import.json", params: { bundle: theme_archive }
|
||||
end.to change { Theme.count }.by (0)
|
||||
expect(response.status).to eq(201)
|
||||
json = ::JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
|
||||
expect(json["theme"]["name"]).to eq("Header Icons")
|
||||
expect(json["theme"]["theme_fields"].length).to eq(5)
|
||||
|
@ -157,7 +157,7 @@ describe Admin::ThemesController do
|
|||
end.to change { Theme.count }.by (0)
|
||||
end
|
||||
expect(response.status).to eq(201)
|
||||
json = ::JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
|
||||
# Ensure only one refresh message is sent.
|
||||
# More than 1 is wasteful, and can trigger unusual race conditions in the client
|
||||
|
@ -179,7 +179,7 @@ describe Admin::ThemesController do
|
|||
post "/admin/themes/import.json", params: { bundle: theme_archive, theme_id: nil }
|
||||
end.to change { Theme.count }.by (1)
|
||||
expect(response.status).to eq(201)
|
||||
json = ::JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
|
||||
expect(json["theme"]["name"]).to eq("Header Icons")
|
||||
expect(json["theme"]["id"]).not_to eq(existing_theme.id)
|
||||
|
@ -213,7 +213,7 @@ describe Admin::ThemesController do
|
|||
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
json = ::JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
|
||||
expect(json["extras"]["color_schemes"].length).to eq(2)
|
||||
theme_json = json["themes"].find { |t| t["id"] == theme.id }
|
||||
|
@ -233,7 +233,7 @@ describe Admin::ThemesController do
|
|||
|
||||
expect(response.status).to eq(201)
|
||||
|
||||
json = ::JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
|
||||
expect(json["theme"]["theme_fields"].length).to eq(1)
|
||||
expect(UserHistory.where(action: UserHistory.actions[:change_theme]).count).to eq(1)
|
||||
|
@ -293,7 +293,7 @@ describe Admin::ThemesController do
|
|||
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
json = ::JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
|
||||
fields = json["theme"]["theme_fields"].sort { |a, b| a["value"] <=> b["value"] }
|
||||
|
||||
|
@ -329,7 +329,7 @@ describe Admin::ThemesController do
|
|||
|
||||
# Response correct
|
||||
expect(response.status).to eq(200)
|
||||
json = ::JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json["theme"]["translations"][0]["value"]).to eq("overridenstring")
|
||||
|
||||
# Database correct
|
||||
|
@ -347,7 +347,7 @@ describe Admin::ThemesController do
|
|||
}
|
||||
# Response correct
|
||||
expect(response.status).to eq(200)
|
||||
json = ::JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json["theme"]["translations"][0]["value"]).to eq("defaultstring")
|
||||
|
||||
# Database correct
|
||||
|
@ -380,7 +380,7 @@ describe Admin::ThemesController do
|
|||
}
|
||||
}
|
||||
expect(response.status).to eq(200)
|
||||
json = JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json["theme"]["enabled"]).to eq(false)
|
||||
expect(UserHistory.where(
|
||||
context: child.id.to_s,
|
||||
|
@ -415,7 +415,7 @@ describe Admin::ThemesController do
|
|||
}
|
||||
}
|
||||
expect(response.status).to eq(200)
|
||||
json = JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
|
||||
expect(UserHistory.where(
|
||||
context: child.id.to_s,
|
||||
|
@ -441,7 +441,7 @@ describe Admin::ThemesController do
|
|||
theme: { remote_update: true }
|
||||
}
|
||||
expect(response.status).to eq(422)
|
||||
expect(JSON.parse(response.body)["errors"].first).to eq("error message")
|
||||
expect(response.parsed_body["errors"].first).to eq("error message")
|
||||
end
|
||||
|
||||
it 'returns the right error message' do
|
||||
|
@ -452,7 +452,7 @@ describe Admin::ThemesController do
|
|||
}
|
||||
|
||||
expect(response.status).to eq(400)
|
||||
expect(JSON.parse(response.body)["errors"].first).to include(I18n.t("themes.errors.component_no_default"))
|
||||
expect(response.parsed_body["errors"].first).to include(I18n.t("themes.errors.component_no_default"))
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -512,7 +512,7 @@ describe Admin::ThemesController do
|
|||
}
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
expect(JSON.parse(response.body)["bg"]).to eq("green")
|
||||
expect(response.parsed_body["bg"]).to eq("green")
|
||||
|
||||
theme.reload
|
||||
expect(theme.included_settings[:bg]).to eq("green")
|
||||
|
|
|
@ -49,7 +49,7 @@ describe Admin::UserFieldsController do
|
|||
it "returns a list of user fields" do
|
||||
get "/admin/customize/user_fields.json"
|
||||
expect(response.status).to eq(200)
|
||||
json = ::JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json['user_fields']).to be_present
|
||||
end
|
||||
end
|
||||
|
|
|
@ -19,14 +19,14 @@ RSpec.describe Admin::UsersController do
|
|||
it 'returns success with JSON' do
|
||||
get "/admin/users/list.json"
|
||||
expect(response.status).to eq(200)
|
||||
expect(JSON.parse(response.body)).to be_present
|
||||
expect(response.parsed_body).to be_present
|
||||
end
|
||||
|
||||
context 'when showing emails' do
|
||||
it "returns email for all the users" do
|
||||
get "/admin/users/list.json", params: { show_emails: "true" }
|
||||
expect(response.status).to eq(200)
|
||||
data = ::JSON.parse(response.body)
|
||||
data = response.parsed_body
|
||||
data.each do |user|
|
||||
expect(user["email"]).to be_present
|
||||
end
|
||||
|
@ -582,7 +582,7 @@ RSpec.describe Admin::UsersController do
|
|||
it "returns an api response that the user can't be deleted because it has posts" do
|
||||
delete "/admin/users/#{delete_me.id}.json"
|
||||
expect(response.status).to eq(403)
|
||||
json = ::JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json['deleted']).to eq(false)
|
||||
end
|
||||
|
||||
|
@ -608,7 +608,7 @@ RSpec.describe Admin::UsersController do
|
|||
it "returns success" do
|
||||
put "/admin/users/#{reg_user.id}/activate.json"
|
||||
expect(response.status).to eq(200)
|
||||
json = ::JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json['success']).to eq("OK")
|
||||
reg_user.reload
|
||||
expect(reg_user.active).to eq(true)
|
||||
|
@ -634,7 +634,7 @@ RSpec.describe Admin::UsersController do
|
|||
it "returns success" do
|
||||
put "/admin/users/#{reg_user.id}/deactivate.json"
|
||||
expect(response.status).to eq(200)
|
||||
json = ::JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json['success']).to eq("OK")
|
||||
reg_user.reload
|
||||
expect(reg_user.active).to eq(false)
|
||||
|
@ -647,7 +647,7 @@ RSpec.describe Admin::UsersController do
|
|||
it "returns success" do
|
||||
post "/admin/users/#{reg_user.id}/log_out.json"
|
||||
expect(response.status).to eq(200)
|
||||
json = ::JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json['success']).to eq("OK")
|
||||
end
|
||||
|
||||
|
@ -765,7 +765,7 @@ RSpec.describe Admin::UsersController do
|
|||
|
||||
get "/admin/users/ip-info.json", params: { ip: ip }
|
||||
expect(response.status).to eq(200)
|
||||
expect(JSON.parse(response.body).symbolize_keys).to eq(
|
||||
expect(response.parsed_body.symbolize_keys).to eq(
|
||||
city: "London",
|
||||
country: "United Kingdom",
|
||||
country_code: "GB",
|
||||
|
@ -848,7 +848,7 @@ RSpec.describe Admin::UsersController do
|
|||
|
||||
post "/admin/users/sync_sso.json", params: Rack::Utils.parse_query(sso.payload)
|
||||
expect(response.status).to eq(403)
|
||||
expect(JSON.parse(response.body)["message"]).to include("Primary email can't be blank")
|
||||
expect(response.parsed_body["message"]).to include("Primary email can't be blank")
|
||||
end
|
||||
|
||||
it 'should return the right message if the signature is invalid' do
|
||||
|
@ -860,8 +860,8 @@ RSpec.describe Admin::UsersController do
|
|||
correct_payload = Rack::Utils.parse_query(sso.payload)
|
||||
post "/admin/users/sync_sso.json", params: correct_payload.merge(sig: "someincorrectsignature")
|
||||
expect(response.status).to eq(422)
|
||||
expect(JSON.parse(response.body)["message"]).to include(I18n.t('sso.login_error'))
|
||||
expect(JSON.parse(response.body)["message"]).not_to include(correct_payload["sig"])
|
||||
expect(response.parsed_body["message"]).to include(I18n.t('sso.login_error'))
|
||||
expect(response.parsed_body["message"]).not_to include(correct_payload["sig"])
|
||||
end
|
||||
|
||||
it "returns 404 if the external id does not exist" do
|
||||
|
@ -871,7 +871,7 @@ RSpec.describe Admin::UsersController do
|
|||
sso.external_id = ""
|
||||
post "/admin/users/sync_sso.json", params: Rack::Utils.parse_query(sso.payload)
|
||||
expect(response.status).to eq(422)
|
||||
expect(JSON.parse(response.body)["message"]).to include(I18n.t('sso.blank_id_error'))
|
||||
expect(response.parsed_body["message"]).to include(I18n.t('sso.blank_id_error'))
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -975,7 +975,7 @@ RSpec.describe Admin::UsersController do
|
|||
it 'returns how many posts were deleted' do
|
||||
put "/admin/users/#{user.id}/delete_posts_batch.json"
|
||||
expect(response.status).to eq(200)
|
||||
expect(JSON.parse(response.body)["posts_deleted"]).to eq(3)
|
||||
expect(response.parsed_body["posts_deleted"]).to eq(3)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -983,7 +983,7 @@ RSpec.describe Admin::UsersController do
|
|||
it "returns correct json" do
|
||||
put "/admin/users/#{user.id}/delete_posts_batch.json"
|
||||
expect(response.status).to eq(200)
|
||||
expect(JSON.parse(response.body)["posts_deleted"]).to eq(0)
|
||||
expect(response.parsed_body["posts_deleted"]).to eq(0)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -25,13 +25,13 @@ describe Admin::VersionsController do
|
|||
it 'should return the currently available version' do
|
||||
get "/admin/version_check.json"
|
||||
expect(response.status).to eq(200)
|
||||
json = JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json['latest_version']).to eq('1.2.33')
|
||||
end
|
||||
|
||||
it "should return the installed version" do
|
||||
get "/admin/version_check.json"
|
||||
json = JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(response.status).to eq(200)
|
||||
expect(json['installed_version']).to eq(Discourse::VERSION::STRING)
|
||||
end
|
||||
|
|
|
@ -34,7 +34,7 @@ describe Admin::WebHooksController do
|
|||
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
json = ::JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json["web_hook"]["payload_url"]).to eq("https://meta.discourse.org/")
|
||||
expect(UserHistory.where(acting_user_id: admin.id, action: UserHistory.actions[:web_hook_create]).count).to eq(1)
|
||||
end
|
||||
|
@ -54,7 +54,7 @@ describe Admin::WebHooksController do
|
|||
}
|
||||
|
||||
expect(response.status).to eq(422)
|
||||
response_body = JSON.parse(response.body)
|
||||
response_body = response.parsed_body
|
||||
|
||||
expect(response_body["errors"]).to be_present
|
||||
end
|
||||
|
|
|
@ -232,7 +232,7 @@ RSpec.describe ApplicationController do
|
|||
|
||||
expect(log).not_to include('exception app middleware')
|
||||
|
||||
expect(JSON.parse(response.body)).to eq(
|
||||
expect(response.parsed_body).to eq(
|
||||
"status" => 400,
|
||||
"error" => "Bad Request"
|
||||
)
|
||||
|
@ -245,7 +245,7 @@ RSpec.describe ApplicationController do
|
|||
get "/search/query.json", params: { trem: "misspelled term" }
|
||||
|
||||
expect(response.status).to eq(400)
|
||||
expect(JSON.parse(response.body)).to eq(
|
||||
expect(response.parsed_body).to eq(
|
||||
"errors" => ["param is missing or the value is empty: term"]
|
||||
)
|
||||
end
|
||||
|
|
|
@ -52,7 +52,7 @@ RSpec.describe Users::AssociateAccountsController do
|
|||
# Request associate info
|
||||
uri = URI.parse(response.redirect_url)
|
||||
get "#{uri.path}.json"
|
||||
data = JSON.parse(response.body)
|
||||
data = response.parsed_body
|
||||
expect(data["provider_name"]).to eq("google_oauth2")
|
||||
expect(data["account_description"]).to eq("someemail@test.com")
|
||||
|
||||
|
@ -64,7 +64,7 @@ RSpec.describe Users::AssociateAccountsController do
|
|||
# Back to first user
|
||||
sign_in(user)
|
||||
get "#{uri.path}.json"
|
||||
data = JSON.parse(response.body)
|
||||
data = response.parsed_body
|
||||
expect(data["provider_name"]).to eq("google_oauth2")
|
||||
|
||||
# Make the connection
|
||||
|
|
|
@ -15,7 +15,7 @@ describe BadgesController do
|
|||
get "/badges.json"
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
parsed = JSON.parse(response.body)
|
||||
parsed = response.parsed_body
|
||||
expect(parsed["badges"].length).to eq(Badge.enabled.count)
|
||||
end
|
||||
end
|
||||
|
@ -24,7 +24,7 @@ describe BadgesController do
|
|||
it "should return a badge" do
|
||||
get "/badges/#{badge.id}.json"
|
||||
expect(response.status).to eq(200)
|
||||
parsed = JSON.parse(response.body)
|
||||
parsed = response.parsed_body
|
||||
expect(parsed["badge"]).to be_present
|
||||
end
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ describe BookmarksController do
|
|||
}
|
||||
|
||||
expect(response.status).to eq(400)
|
||||
expect(JSON.parse(response.body)['errors']).to include(
|
||||
expect(response.parsed_body['errors']).to include(
|
||||
I18n.t("bookmarks.errors.already_bookmarked_post")
|
||||
)
|
||||
end
|
||||
|
@ -39,7 +39,7 @@ describe BookmarksController do
|
|||
}
|
||||
|
||||
expect(response.status).to eq(400)
|
||||
expect(JSON.parse(response.body)['errors'].first).to include(
|
||||
expect(response.parsed_body['errors'].first).to include(
|
||||
I18n.t("bookmarks.errors.time_must_be_provided")
|
||||
)
|
||||
end
|
||||
|
@ -60,7 +60,7 @@ describe BookmarksController do
|
|||
delete "/bookmarks/#{bookmark.id}.json"
|
||||
|
||||
expect(response.status).to eq(404)
|
||||
expect(JSON.parse(response.body)['errors'].first).to include(
|
||||
expect(response.parsed_body['errors'].first).to include(
|
||||
I18n.t("not_found")
|
||||
)
|
||||
end
|
||||
|
@ -73,7 +73,7 @@ describe BookmarksController do
|
|||
delete "/bookmarks/#{bookmark.id}.json"
|
||||
|
||||
expect(response.status).to eq(403)
|
||||
expect(JSON.parse(response.body)['errors'].first).to include(
|
||||
expect(response.parsed_body['errors'].first).to include(
|
||||
I18n.t("invalid_access")
|
||||
)
|
||||
end
|
||||
|
|
|
@ -129,7 +129,7 @@ describe CategoriesController do
|
|||
}
|
||||
|
||||
expect(response.status).to eq(422)
|
||||
expect(JSON.parse(response.body)['errors']).to be_present
|
||||
expect(response.parsed_body['errors']).to be_present
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -156,7 +156,7 @@ describe CategoriesController do
|
|||
}
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
cat_json = ::JSON.parse(response.body)['category']
|
||||
cat_json = response.parsed_body['category']
|
||||
expect(cat_json).to be_present
|
||||
expect(cat_json['reviewable_by_group_name']).to eq(group.name)
|
||||
expect(cat_json['name']).to eq('hello')
|
||||
|
@ -497,21 +497,21 @@ describe CategoriesController do
|
|||
SiteSetting.categories_topics = 5
|
||||
|
||||
get '/categories_and_latest.json'
|
||||
expect(JSON.parse(response.body)['topic_list']['topics'].size).to eq(5)
|
||||
expect(response.parsed_body['topic_list']['topics'].size).to eq(5)
|
||||
end
|
||||
|
||||
it 'works when SiteSetting.categories_topics is null' do
|
||||
SiteSetting.categories_topics = 0
|
||||
|
||||
get '/categories_and_latest.json'
|
||||
json = JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json['category_list']['categories'].size).to eq(2) # 'Uncategorized' and category
|
||||
expect(json['topic_list']['topics'].size).to eq(5)
|
||||
|
||||
Fabricate(:category, parent_category: category)
|
||||
|
||||
get '/categories_and_latest.json'
|
||||
json = JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json['category_list']['categories'].size).to eq(2)
|
||||
expect(json['topic_list']['topics'].size).to eq(5)
|
||||
|
||||
|
@ -519,7 +519,7 @@ describe CategoriesController do
|
|||
Fabricate(:category)
|
||||
|
||||
get '/categories_and_latest.json'
|
||||
json = JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json['category_list']['categories'].size).to eq(4)
|
||||
expect(json['topic_list']['topics'].size).to eq(6)
|
||||
end
|
||||
|
|
|
@ -17,7 +17,7 @@ describe CategoryHashtagsController do
|
|||
get "/category_hashtags/check.json", params: { category_slugs: [category.slug, 'none'] }
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
expect(JSON.parse(response.body)).to eq(
|
||||
expect(response.parsed_body).to eq(
|
||||
"valid" => [{ "slug" => category.hashtag_slug, "url" => category.url_with_id }]
|
||||
)
|
||||
end
|
||||
|
@ -29,7 +29,7 @@ describe CategoryHashtagsController do
|
|||
get "/category_hashtags/check.json", params: { category_slugs: [private_category.slug] }
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
expect(JSON.parse(response.body)).to eq("valid" => [])
|
||||
expect(response.parsed_body).to eq("valid" => [])
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -44,7 +44,7 @@ describe CategoryHashtagsController do
|
|||
params: { category_slugs: [private_category.slug] }
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
expect(JSON.parse(response.body)).to eq(
|
||||
expect(response.parsed_body).to eq(
|
||||
"valid" => [{ "slug" => private_category.hashtag_slug, "url" => private_category.url_with_id }]
|
||||
)
|
||||
end
|
||||
|
|
|
@ -27,7 +27,7 @@ describe ComposerMessagesController do
|
|||
|
||||
get "/composer_messages.json", params: args
|
||||
expect(response.status).to eq(200)
|
||||
json = JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json["composer_messages"].first["id"]).to eq("reviving_old")
|
||||
end
|
||||
end
|
||||
|
|
|
@ -40,7 +40,7 @@ describe DirectoryItemsController do
|
|||
it "succeeds with a valid value" do
|
||||
get '/directory_items.json', params: { period: 'all' }
|
||||
expect(response.status).to eq(200)
|
||||
json = ::JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
|
||||
expect(json).to be_present
|
||||
expect(json['directory_items']).to be_present
|
||||
|
@ -63,7 +63,7 @@ describe DirectoryItemsController do
|
|||
get '/directory_items.json', params: { period: 'all', name: 'eviltrout' }
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
json = ::JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json).to be_present
|
||||
expect(json['directory_items'].length).to eq(1)
|
||||
expect(json['meta']['total_rows_directory_items']).to eq(1)
|
||||
|
@ -74,7 +74,7 @@ describe DirectoryItemsController do
|
|||
get '/directory_items.json', params: { period: 'all', name: 'stage_user' }
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
json = ::JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json).to be_present
|
||||
expect(json['directory_items'].length).to eq(1)
|
||||
expect(json['meta']['total_rows_directory_items']).to eq(1)
|
||||
|
@ -85,7 +85,7 @@ describe DirectoryItemsController do
|
|||
get '/directory_items.json', params: { period: 'all', exclude_usernames: "stage_user,eviltrout" }
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
json = ::JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json).to be_present
|
||||
expect(json['directory_items'].length).to eq(2)
|
||||
expect(json['meta']['total_rows_directory_items']).to eq(2)
|
||||
|
@ -97,7 +97,7 @@ describe DirectoryItemsController do
|
|||
get '/directory_items.json', params: { period: 'all', group: group.name }
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
json = ::JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json).to be_present
|
||||
expect(json['directory_items'].length).to eq(2)
|
||||
expect(json['meta']['total_rows_directory_items']).to eq(2)
|
||||
|
|
|
@ -33,7 +33,7 @@ describe DraftController do
|
|||
|
||||
get "/draft.json", params: { draft_key: 'hello' }
|
||||
expect(response.status).to eq(200)
|
||||
json = ::JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json['draft']).to eq('test')
|
||||
|
||||
get "/draft.json"
|
||||
|
@ -54,7 +54,7 @@ describe DraftController do
|
|||
}.to_json
|
||||
}
|
||||
|
||||
expect(JSON.parse(response.body)['conflict_user']).to eq(nil)
|
||||
expect(response.parsed_body['conflict_user']).to eq(nil)
|
||||
|
||||
post "/draft.json", params: {
|
||||
draft_key: "topic",
|
||||
|
@ -66,7 +66,7 @@ describe DraftController do
|
|||
}.to_json
|
||||
}
|
||||
|
||||
json = JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
|
||||
expect(json['conflict_user']['id']).to eq(post.last_editor.id)
|
||||
expect(json['conflict_user']).to include('avatar_template')
|
||||
|
@ -94,7 +94,7 @@ describe DraftController do
|
|||
}
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
json = JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json["draft_sequence"]).to eq(1)
|
||||
end
|
||||
|
||||
|
@ -110,7 +110,7 @@ describe DraftController do
|
|||
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
json = JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json["draft_sequence"]).to eq(0)
|
||||
|
||||
post "/draft.json", params: {
|
||||
|
@ -121,7 +121,7 @@ describe DraftController do
|
|||
}
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
json = JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json["draft_sequence"]).to eq(1)
|
||||
|
||||
expect(DraftSequence.current(user, "abc")).to eq(1)
|
||||
|
@ -134,7 +134,7 @@ describe DraftController do
|
|||
}
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
json = JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json["draft_sequence"]).to eq(1)
|
||||
|
||||
post "/draft.json", params: {
|
||||
|
@ -145,7 +145,7 @@ describe DraftController do
|
|||
}
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
json = JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json["draft_sequence"]).to eq(2)
|
||||
end
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@ describe DraftsController do
|
|||
Draft.set(user, 'xxx', 0, '{}')
|
||||
get "/drafts.json", params: { username: user.username }
|
||||
expect(response.status).to eq(200)
|
||||
parsed = JSON.parse(response.body)
|
||||
parsed = response.parsed_body
|
||||
expect(parsed["drafts"].length).to eq(1)
|
||||
end
|
||||
|
||||
|
@ -23,7 +23,7 @@ describe DraftsController do
|
|||
Draft.clear(user, 'xxx', 0)
|
||||
get "/drafts.json", params: { username: user.username }
|
||||
expect(response.status).to eq(200)
|
||||
parsed = JSON.parse(response.body)
|
||||
parsed = response.parsed_body
|
||||
expect(parsed["drafts"].length).to eq(0)
|
||||
end
|
||||
|
||||
|
@ -45,13 +45,13 @@ describe DraftsController do
|
|||
sign_in(topic_user)
|
||||
get "/drafts.json", params: { username: topic_user.username }
|
||||
expect(response.status).to eq(200)
|
||||
parsed = JSON.parse(response.body)
|
||||
parsed = response.parsed_body
|
||||
expect(parsed["drafts"].first["title"]).to eq(topic.title)
|
||||
|
||||
sign_in(other_user)
|
||||
get "/drafts.json", params: { username: other_user.username }
|
||||
expect(response.status).to eq(200)
|
||||
parsed = JSON.parse(response.body)
|
||||
parsed = response.parsed_body
|
||||
expect(parsed["drafts"].first["title"]).to eq(nil)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -52,7 +52,7 @@ describe EmbedController do
|
|||
params: { embed_url: topic_embed.embed_url },
|
||||
headers: { HTTP_API_KEY: api_key.key, HTTP_API_USERNAME: "system" }
|
||||
|
||||
json = JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json['topic_id']).to eq(topic_embed.topic.id)
|
||||
expect(json['post_id']).to eq(topic_embed.post.id)
|
||||
expect(json['topic_slug']).to eq(topic_embed.topic.slug)
|
||||
|
@ -65,7 +65,7 @@ describe EmbedController do
|
|||
params: { embed_url: "http://nope.com" },
|
||||
headers: { HTTP_API_KEY: api_key.key, HTTP_API_USERNAME: "system" }
|
||||
|
||||
json = JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json["error_type"]).to eq("not_found")
|
||||
end
|
||||
end
|
||||
|
|
|
@ -22,7 +22,7 @@ describe GroupsController do
|
|||
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
body = JSON.parse(response.body)
|
||||
body = response.parsed_body
|
||||
|
||||
expect(body["groups"].size).to eq(36)
|
||||
expect(body["total_rows_groups"]).to eq(50)
|
||||
|
@ -32,7 +32,7 @@ describe GroupsController do
|
|||
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
body = JSON.parse(response.body)
|
||||
body = response.parsed_body
|
||||
|
||||
expect(body["groups"].size).to eq(14)
|
||||
expect(body["total_rows_groups"]).to eq(50)
|
||||
|
@ -79,7 +79,7 @@ describe GroupsController do
|
|||
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
body = JSON.parse(response.body)
|
||||
body = response.parsed_body
|
||||
|
||||
expect(body["groups"].first["id"]).to eq(testing_group.id)
|
||||
expect(body["load_more_groups"]).to eq("/groups?filter=test&page=1")
|
||||
|
@ -100,7 +100,7 @@ describe GroupsController do
|
|||
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
body = JSON.parse(response.body)
|
||||
body = response.parsed_body
|
||||
|
||||
expect(body["groups"].map { |g| g["id"] }).to eq([
|
||||
other_group.id, group.id, moderator_group_id
|
||||
|
@ -114,7 +114,7 @@ describe GroupsController do
|
|||
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
body = JSON.parse(response.body)
|
||||
body = response.parsed_body
|
||||
|
||||
expect(body["groups"].map { |g| g["id"] }).to eq([
|
||||
other_group.id, group.id, moderator_group_id
|
||||
|
@ -130,7 +130,7 @@ describe GroupsController do
|
|||
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
body = JSON.parse(response.body)
|
||||
body = response.parsed_body
|
||||
|
||||
expect(body["groups"].map { |g| g["id"] }).to eq([
|
||||
moderator_group_id, group.id, other_group.id
|
||||
|
@ -144,7 +144,7 @@ describe GroupsController do
|
|||
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
body = JSON.parse(response.body)
|
||||
body = response.parsed_body
|
||||
|
||||
expect(body["groups"].map { |g| g["id"] }).to eq([
|
||||
moderator_group_id, group.id, other_group.id
|
||||
|
@ -163,7 +163,7 @@ describe GroupsController do
|
|||
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
body = JSON.parse(response.body)
|
||||
body = response.parsed_body
|
||||
|
||||
group_ids = body["groups"].map { |g| g["id"] }
|
||||
|
||||
|
@ -209,7 +209,7 @@ describe GroupsController do
|
|||
get "/groups.json", params: { username: u.username }
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
group_names = JSON.parse(response.body)["groups"].map { |g| g["name"] }
|
||||
group_names = response.parsed_body["groups"].map { |g| g["name"] }
|
||||
expect(group_names).to contain_exactly("0_0")
|
||||
|
||||
# logged in user
|
||||
|
@ -217,7 +217,7 @@ describe GroupsController do
|
|||
get "/groups.json", params: { username: u.username }
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
group_names = JSON.parse(response.body)["groups"].map { |g| g["name"] }
|
||||
group_names = response.parsed_body["groups"].map { |g| g["name"] }
|
||||
expect(group_names).to contain_exactly("0_0", "0_1", "1_0", "1_1")
|
||||
|
||||
# member of the group
|
||||
|
@ -225,7 +225,7 @@ describe GroupsController do
|
|||
get "/groups.json", params: { username: u.username }
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
group_names = JSON.parse(response.body)["groups"].map { |g| g["name"] }
|
||||
group_names = response.parsed_body["groups"].map { |g| g["name"] }
|
||||
expect(group_names).to contain_exactly("0_0", "0_1", "0_2", "1_0", "1_1", "1_2", "2_0", "2_1", "2_2")
|
||||
|
||||
# owner
|
||||
|
@ -233,7 +233,7 @@ describe GroupsController do
|
|||
get "/groups.json", params: { username: u.username }
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
group_names = JSON.parse(response.body)["groups"].map { |g| g["name"] }
|
||||
group_names = response.parsed_body["groups"].map { |g| g["name"] }
|
||||
expect(group_names).to contain_exactly("0_0", "0_1", "0_4", "1_0", "1_1", "1_4", "2_4", "3_4", "4_0", "4_1", "4_2", "4_3", "4_4")
|
||||
|
||||
# moderator
|
||||
|
@ -241,7 +241,7 @@ describe GroupsController do
|
|||
get "/groups.json", params: { username: u.username }
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
group_names = JSON.parse(response.body)["groups"].map { |g| g["name"] }
|
||||
group_names = response.parsed_body["groups"].map { |g| g["name"] }
|
||||
expect(group_names).to contain_exactly("0_0", "0_1", "0_3", "1_0", "1_1", "1_3", "3_0", "3_1", "3_3")
|
||||
|
||||
# admin
|
||||
|
@ -249,7 +249,7 @@ describe GroupsController do
|
|||
get "/groups.json", params: { username: u.username }
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
group_names = JSON.parse(response.body)["groups"].map { |g| g["name"] }
|
||||
group_names = response.parsed_body["groups"].map { |g| g["name"] }
|
||||
all_group_names = levels.product(levels).map { |a, b| "#{a}_#{b}" }
|
||||
expect(group_names).to contain_exactly(*all_group_names)
|
||||
end
|
||||
|
@ -270,7 +270,7 @@ describe GroupsController do
|
|||
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
body = JSON.parse(response.body)
|
||||
body = response.parsed_body
|
||||
|
||||
group_ids = body["groups"].map { |g| g["id"] }
|
||||
group_body = body["groups"].find { |g| g["id"] == group.id }
|
||||
|
@ -292,7 +292,7 @@ describe GroupsController do
|
|||
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
body = JSON.parse(response.body)
|
||||
body = response.parsed_body
|
||||
group_ids = body["groups"].map { |g| g["id"] }
|
||||
|
||||
expect(body["total_rows_groups"]).to eq(expected_group_ids.count)
|
||||
|
@ -360,7 +360,7 @@ describe GroupsController do
|
|||
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
body = JSON.parse(response.body)
|
||||
body = response.parsed_body
|
||||
|
||||
expect(body['group']['id']).to eq(group.id)
|
||||
expect(body['extras']["visible_group_names"]).to eq([group.name])
|
||||
|
@ -373,7 +373,7 @@ describe GroupsController do
|
|||
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
body = JSON.parse(response.body)
|
||||
body = response.parsed_body
|
||||
|
||||
expect(body['group']['id']).to eq(group.id)
|
||||
|
||||
|
@ -409,7 +409,7 @@ describe GroupsController do
|
|||
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
body = JSON.parse(response.body)['group']
|
||||
body = response.parsed_body['group']
|
||||
|
||||
expect(body["id"]).to eq(group.id)
|
||||
end
|
||||
|
@ -441,7 +441,7 @@ describe GroupsController do
|
|||
get "/groups/#{group.name}/posts.json"
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
expect(JSON.parse(response.body).first["id"]).to eq(post.id)
|
||||
expect(response.parsed_body.first["id"]).to eq(post.id)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -492,7 +492,7 @@ describe GroupsController do
|
|||
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
members = JSON.parse(response.body)["members"]
|
||||
members = response.parsed_body["members"]
|
||||
|
||||
expect(members.map { |m| m['username'] }).to eq(usernames[0..2])
|
||||
|
||||
|
@ -500,12 +500,12 @@ describe GroupsController do
|
|||
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
members = JSON.parse(response.body)["members"]
|
||||
members = response.parsed_body["members"]
|
||||
|
||||
expect(members.map { |m| m['username'] }).to eq(usernames[3..5])
|
||||
|
||||
get "/groups/#{group.name}/members.json", params: { order: 'added_at', desc: true }
|
||||
members = JSON.parse(response.body)["members"]
|
||||
members = response.parsed_body["members"]
|
||||
|
||||
expect(members.last['added_at']).to eq(first_user.created_at.as_json)
|
||||
end
|
||||
|
@ -549,7 +549,7 @@ describe GroupsController do
|
|||
get "/groups/#{group.name}/mentionable.json"
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
body = JSON.parse(response.body)
|
||||
body = response.parsed_body
|
||||
expect(body["mentionable"]).to eq(false)
|
||||
|
||||
group.update!(
|
||||
|
@ -560,7 +560,7 @@ describe GroupsController do
|
|||
get "/groups/#{group.name}/mentionable.json"
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
body = JSON.parse(response.body)
|
||||
body = response.parsed_body
|
||||
expect(body["mentionable"]).to eq(true)
|
||||
|
||||
group.update!(
|
||||
|
@ -571,7 +571,7 @@ describe GroupsController do
|
|||
get "/groups/#{group.name}/mentionable.json"
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
body = JSON.parse(response.body)
|
||||
body = response.parsed_body
|
||||
expect(body["mentionable"]).to eq(true)
|
||||
end
|
||||
end
|
||||
|
@ -583,7 +583,7 @@ describe GroupsController do
|
|||
get "/groups/#{group.name}/messageable.json"
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
body = JSON.parse(response.body)
|
||||
body = response.parsed_body
|
||||
expect(body["messageable"]).to eq(false)
|
||||
|
||||
group.update!(
|
||||
|
@ -594,7 +594,7 @@ describe GroupsController do
|
|||
get "/groups/#{group.name}/messageable.json"
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
body = JSON.parse(response.body)
|
||||
body = response.parsed_body
|
||||
expect(body["messageable"]).to eq(true)
|
||||
end
|
||||
end
|
||||
|
@ -855,7 +855,7 @@ describe GroupsController do
|
|||
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
members = JSON.parse(response.body)["members"]
|
||||
members = response.parsed_body["members"]
|
||||
|
||||
expect(members.map { |m| m["id"] }).to eq([user1.id, user2.id, user3.id])
|
||||
|
||||
|
@ -863,7 +863,7 @@ describe GroupsController do
|
|||
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
members = JSON.parse(response.body)["members"]
|
||||
members = response.parsed_body["members"]
|
||||
|
||||
expect(members.map { |m| m["id"] }).to eq([user2.id, user1.id, user3.id])
|
||||
|
||||
|
@ -873,7 +873,7 @@ describe GroupsController do
|
|||
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
members = JSON.parse(response.body)["members"]
|
||||
members = response.parsed_body["members"]
|
||||
|
||||
expect(members.map { |m| m["id"] }).to eq([user2.id, user1.id, user3.id])
|
||||
end
|
||||
|
@ -883,7 +883,7 @@ describe GroupsController do
|
|||
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
members = JSON.parse(response.body)["members"]
|
||||
members = response.parsed_body["members"]
|
||||
|
||||
expect(members.map { |m| m["id"] })
|
||||
.to contain_exactly(user1.id, user2.id, user3.id)
|
||||
|
@ -897,7 +897,7 @@ describe GroupsController do
|
|||
|
||||
get "/groups/#{group.name}/members.json", params: { requesters: true }
|
||||
|
||||
members = JSON.parse(response.body)["members"]
|
||||
members = response.parsed_body["members"]
|
||||
expect(members.length).to eq(1)
|
||||
expect(members.first["username"]).to eq(user4.username)
|
||||
expect(members.first["reason"]).to eq(request4.reason)
|
||||
|
@ -912,7 +912,7 @@ describe GroupsController do
|
|||
get "/groups/#{group.name}/members.json", params: { filter: email }
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
members = JSON.parse(response.body)["members"]
|
||||
members = response.parsed_body["members"]
|
||||
expect(members).to eq([])
|
||||
end
|
||||
end
|
||||
|
@ -934,7 +934,7 @@ describe GroupsController do
|
|||
get "/groups/#{group.name}/members.json", params: { filter: filter }
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
members = JSON.parse(response.body)["members"]
|
||||
members = response.parsed_body["members"]
|
||||
expect(members.map { |m| m["id"] }).to contain_exactly(*ids)
|
||||
end
|
||||
end
|
||||
|
@ -947,7 +947,7 @@ describe GroupsController do
|
|||
get "/groups/#{group.name}/members.json", params: { filter: filter }
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
members = JSON.parse(response.body)["members"]
|
||||
members = response.parsed_body["members"]
|
||||
expect(members.map { |m| m["id"] }).to contain_exactly(user1.id)
|
||||
end
|
||||
end
|
||||
|
@ -1089,7 +1089,7 @@ describe GroupsController do
|
|||
|
||||
expect(response.status).to eq(422)
|
||||
|
||||
expect(JSON.parse(response.body)["errors"]).to include(I18n.t(
|
||||
expect(response.parsed_body["errors"]).to include(I18n.t(
|
||||
"groups.errors.member_already_exist",
|
||||
username: "alice, bob",
|
||||
count: 2
|
||||
|
@ -1102,7 +1102,7 @@ describe GroupsController do
|
|||
|
||||
expect(response.status).to eq(422)
|
||||
|
||||
expect(JSON.parse(response.body)["errors"]).to include(I18n.t(
|
||||
expect(response.parsed_body["errors"]).to include(I18n.t(
|
||||
"groups.errors.member_already_exist",
|
||||
username: user.username,
|
||||
count: 1
|
||||
|
@ -1119,7 +1119,7 @@ describe GroupsController do
|
|||
|
||||
expect(response.status).to eq(400)
|
||||
|
||||
body = JSON.parse(response.body)
|
||||
body = response.parsed_body
|
||||
|
||||
expect(body["error_type"]).to eq("invalid_parameters")
|
||||
end
|
||||
|
@ -1365,7 +1365,7 @@ describe GroupsController do
|
|||
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
result = JSON.parse(response.body)["logs"].find { |entry| entry["subject"] == "public_exit" }
|
||||
result = response.parsed_body["logs"].find { |entry| entry["subject"] == "public_exit" }
|
||||
|
||||
expect(result["action"]).to eq(GroupHistory.actions[1].to_s)
|
||||
expect(result["subject"]).to eq('public_exit')
|
||||
|
@ -1397,7 +1397,7 @@ describe GroupsController do
|
|||
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
result = JSON.parse(response.body)["logs"].first
|
||||
result = response.parsed_body["logs"].first
|
||||
|
||||
expect(result["action"]).to eq(GroupHistory.actions[3].to_s)
|
||||
end
|
||||
|
@ -1420,7 +1420,7 @@ describe GroupsController do
|
|||
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
logs = JSON.parse(response.body)["logs"]
|
||||
logs = response.parsed_body["logs"]
|
||||
|
||||
expect(logs.count).to eq(1)
|
||||
expect(logs.first["action"]).to eq(GroupHistory.actions[2].to_s)
|
||||
|
@ -1471,7 +1471,7 @@ describe GroupsController do
|
|||
|
||||
post = Post.last
|
||||
topic = post.topic
|
||||
body = JSON.parse(response.body)
|
||||
body = response.parsed_body
|
||||
|
||||
expect(body['relative_url']).to eq(topic.relative_url)
|
||||
expect(post.topic.custom_fields['requested_group_id'].to_i).to eq(group.id)
|
||||
|
@ -1520,7 +1520,7 @@ describe GroupsController do
|
|||
get '/groups/search.json'
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
groups = JSON.parse(response.body)
|
||||
groups = response.parsed_body
|
||||
|
||||
expected_ids = Group::AUTO_GROUPS.map { |name, id| id }
|
||||
expected_ids.delete(Group::AUTO_GROUPS[:everyone])
|
||||
|
@ -1532,7 +1532,7 @@ describe GroupsController do
|
|||
get "/groups/search.json?term=#{term}"
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
groups = JSON.parse(response.body)
|
||||
groups = response.parsed_body
|
||||
|
||||
expect(groups.length).to eq(1)
|
||||
expect(groups.first['id']).to eq(group.id)
|
||||
|
@ -1541,7 +1541,7 @@ describe GroupsController do
|
|||
get "/groups/search.json?term=KingOfTheNorth"
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
groups = JSON.parse(response.body)
|
||||
groups = response.parsed_body
|
||||
|
||||
expect(groups).to eq([])
|
||||
end
|
||||
|
@ -1558,7 +1558,7 @@ describe GroupsController do
|
|||
get "/groups/search.json?term=north"
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
groups = JSON.parse(response.body)
|
||||
groups = response.parsed_body
|
||||
|
||||
expect(groups.length).to eq(1)
|
||||
expect(groups.first['id']).to eq(hidden_group.id)
|
||||
|
@ -1572,7 +1572,7 @@ describe GroupsController do
|
|||
get '/groups/search.json?ignore_automatic=true'
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
groups = JSON.parse(response.body)
|
||||
groups = response.parsed_body
|
||||
|
||||
expect(groups.length).to eq(2)
|
||||
|
||||
|
@ -1626,7 +1626,7 @@ describe GroupsController do
|
|||
get "/groups/check-name.json", params: { group_name: 'test' }
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
expect(JSON.parse(response.body)["available"]).to eq(true)
|
||||
expect(response.parsed_body["available"]).to eq(true)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -15,7 +15,7 @@ describe InlineOneboxController do
|
|||
it "returns empty JSON for empty input" do
|
||||
get "/inline-onebox.json", params: { urls: [] }
|
||||
expect(response.status).to eq(200)
|
||||
json = JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json['inline-oneboxes']).to eq([])
|
||||
end
|
||||
|
||||
|
@ -25,7 +25,7 @@ describe InlineOneboxController do
|
|||
it "returns information for a valid link" do
|
||||
get "/inline-onebox.json", params: { urls: [ topic.url ] }
|
||||
expect(response.status).to eq(200)
|
||||
json = JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
onebox = json['inline-oneboxes'][0]
|
||||
|
||||
expect(onebox).to be_present
|
||||
|
|
|
@ -94,7 +94,7 @@ describe InvitesController do
|
|||
invite = Invite.invite_by_email("invite@example.com", user)
|
||||
post "/invites.json", params: { email: invite.email }
|
||||
expect(response.status).to eq(422)
|
||||
json = JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json["failed"]).to be_present
|
||||
end
|
||||
|
||||
|
@ -129,7 +129,7 @@ describe InvitesController do
|
|||
sign_in(Fabricate(:admin))
|
||||
post "/invites.json", params: { email: "test@mailinator.com" }
|
||||
expect(response.status).to eq(422)
|
||||
json = JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json["errors"]).to be_present
|
||||
end
|
||||
end
|
||||
|
@ -208,7 +208,7 @@ describe InvitesController do
|
|||
it "redirects to the root and doesn't change the session" do
|
||||
put "/invites/show/doesntexist.json"
|
||||
expect(response.status).to eq(200)
|
||||
json = JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json["success"]).to eq(false)
|
||||
expect(json["message"]).to eq(I18n.t('invite.not_found_json'))
|
||||
expect(session[:current_user_id]).to be_blank
|
||||
|
@ -221,7 +221,7 @@ describe InvitesController do
|
|||
invite.update_attribute(:email, "John Doe <john.doe@example.com>")
|
||||
put "/invites/show/#{invite.invite_key}.json"
|
||||
expect(response.status).to eq(200)
|
||||
json = JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json["success"]).to eq(false)
|
||||
expect(json["message"]).to eq(I18n.t('invite.error_message'))
|
||||
expect(session[:current_user_id]).to be_blank
|
||||
|
@ -243,7 +243,7 @@ describe InvitesController do
|
|||
put "/invites/show/#{invite.invite_key}.json"
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
json = JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json["success"]).to eq(false)
|
||||
expect(json["message"]).to eq(I18n.t('invite.not_found_json'))
|
||||
expect(session[:current_user_id]).to be_blank
|
||||
|
@ -286,7 +286,7 @@ describe InvitesController do
|
|||
it 'redirects to the first topic the user was invited to' do
|
||||
put "/invites/show/#{invite.invite_key}.json"
|
||||
expect(response.status).to eq(200)
|
||||
json = JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json["success"]).to eq(true)
|
||||
expect(json["redirect_to"]).to eq(topic.relative_url)
|
||||
end
|
||||
|
@ -306,7 +306,7 @@ describe InvitesController do
|
|||
it "doesn't log in the user if there's a validation error" do
|
||||
put "/invites/show/#{invite.invite_key}.json", params: { password: "password" }
|
||||
expect(response.status).to eq(200)
|
||||
json = JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json["success"]).to eq(false)
|
||||
expect(json["errors"]["password"]).to be_present
|
||||
end
|
||||
|
@ -317,7 +317,7 @@ describe InvitesController do
|
|||
user.send_welcome_message = true
|
||||
put "/invites/show/#{invite.invite_key}.json"
|
||||
expect(response.status).to eq(200)
|
||||
expect(JSON.parse(response.body)["success"]).to eq(true)
|
||||
expect(response.parsed_body["success"]).to eq(true)
|
||||
|
||||
expect(Jobs::SendSystemMessage.jobs.size).to eq(1)
|
||||
end
|
||||
|
@ -371,7 +371,7 @@ describe InvitesController do
|
|||
end.to change { UserAuthToken.count }.by(1)
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
expect(JSON.parse(response.body)["success"]).to eq(true)
|
||||
expect(response.parsed_body["success"]).to eq(true)
|
||||
|
||||
expect(Jobs::InvitePasswordInstructionsEmail.jobs.size).to eq(0)
|
||||
expect(Jobs::CriticalUserEmail.jobs.size).to eq(0)
|
||||
|
@ -391,8 +391,8 @@ describe InvitesController do
|
|||
end.not_to change { UserAuthToken.count }
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
expect(JSON.parse(response.body)["success"]).to eq(true)
|
||||
expect(JSON.parse(response.body)["message"]).to eq(I18n.t("invite.confirm_email"))
|
||||
expect(response.parsed_body["success"]).to eq(true)
|
||||
expect(response.parsed_body["message"]).to eq(I18n.t("invite.confirm_email"))
|
||||
|
||||
invited_user = User.find_by_email(invite.email)
|
||||
expect(invited_user.active).to eq(false)
|
||||
|
@ -526,7 +526,7 @@ describe InvitesController do
|
|||
|
||||
expect(response.status).to eq(422)
|
||||
expect(Jobs::BulkInvite.jobs.size).to eq(1)
|
||||
json = ::JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json["errors"][0]).to eq(I18n.t("bulk_invite.max_rows", max_bulk_invites: SiteSetting.max_bulk_invites))
|
||||
end
|
||||
end
|
||||
|
|
|
@ -68,7 +68,7 @@ RSpec.describe ListController do
|
|||
|
||||
get "/latest.json", params: { topic_ids: "#{p.topic_id}" }
|
||||
expect(response.status).to eq(200)
|
||||
parsed = JSON.parse(response.body)
|
||||
parsed = response.parsed_body
|
||||
expect(parsed["topic_list"]["topics"].length).to eq(1)
|
||||
end
|
||||
|
||||
|
@ -90,11 +90,11 @@ RSpec.describe ListController do
|
|||
TopTopic.refresh!
|
||||
|
||||
get "/categories_and_top.json"
|
||||
data = JSON.parse(response.body)
|
||||
data = response.parsed_body
|
||||
expect(data["topic_list"]["topics"].length).to eq(1)
|
||||
|
||||
get "/categories_and_latest.json"
|
||||
data = JSON.parse(response.body)
|
||||
data = response.parsed_body
|
||||
expect(data["topic_list"]["topics"].length).to eq(2)
|
||||
end
|
||||
end
|
||||
|
@ -169,7 +169,7 @@ RSpec.describe ListController do
|
|||
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
expect(JSON.parse(response.body)["topic_list"]["topics"].first["id"])
|
||||
expect(response.parsed_body["topic_list"]["topics"].first["id"])
|
||||
.to eq(topic.id)
|
||||
end
|
||||
end
|
||||
|
@ -184,7 +184,7 @@ RSpec.describe ListController do
|
|||
get "/topics/private-messages-group/#{user.username}/#{UrlHelper.encode_component(unicode_group.name)}.json"
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
expect(JSON.parse(response.body)["topic_list"]["topics"].first["id"])
|
||||
expect(response.parsed_body["topic_list"]["topics"].first["id"])
|
||||
.to eq(topic.id)
|
||||
end
|
||||
end
|
||||
|
@ -217,7 +217,7 @@ RSpec.describe ListController do
|
|||
get "/topics/groups/#{group.name}.json"
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
expect(JSON.parse(response.body)["topic_list"]).to be_present
|
||||
expect(response.parsed_body["topic_list"]).to be_present
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -286,7 +286,7 @@ RSpec.describe ListController do
|
|||
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
topics = JSON.parse(response.body)["topic_list"]["topics"]
|
||||
topics = response.parsed_body["topic_list"]["topics"]
|
||||
|
||||
expect(topics.map { |topic| topic["id"] }).to contain_exactly(
|
||||
topic.id, topic2.id
|
||||
|
@ -384,7 +384,7 @@ RSpec.describe ListController do
|
|||
it 'uses the correct category' do
|
||||
get "/c/#{other_category.slug}/l/latest.json"
|
||||
expect(response.status).to eq(200)
|
||||
body = JSON.parse(response.body)
|
||||
body = response.parsed_body
|
||||
expect(body["topic_list"]["topics"].first["category_id"])
|
||||
.to eq(other_category.id)
|
||||
end
|
||||
|
@ -429,7 +429,7 @@ RSpec.describe ListController do
|
|||
category.update!(default_view: 'top', default_top_period: 'monthly')
|
||||
get "/c/#{category.slug}.json"
|
||||
expect(response.status).to eq(200)
|
||||
json = JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json["topic_list"]["for_period"]).to eq("monthly")
|
||||
end
|
||||
|
||||
|
@ -437,7 +437,7 @@ RSpec.describe ListController do
|
|||
category.update!(default_view: nil)
|
||||
get "/c/#{category.slug}.json"
|
||||
expect(response.status).to eq(200)
|
||||
json = JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json["topic_list"]["for_period"]).to be_blank
|
||||
end
|
||||
|
||||
|
@ -445,7 +445,7 @@ RSpec.describe ListController do
|
|||
category.update!(default_view: '')
|
||||
get "/c/#{category.slug}.json"
|
||||
expect(response.status).to eq(200)
|
||||
json = JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json["topic_list"]["for_period"]).to be_blank
|
||||
end
|
||||
|
||||
|
@ -453,7 +453,7 @@ RSpec.describe ListController do
|
|||
category.update!(default_view: 'latest')
|
||||
get "/c/#{category.slug}.json"
|
||||
expect(response.status).to eq(200)
|
||||
json = JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json["topic_list"]["for_period"]).to be_blank
|
||||
end
|
||||
end
|
||||
|
@ -502,7 +502,7 @@ RSpec.describe ListController do
|
|||
it "should respond with a list" do
|
||||
get "/topics/created-by/#{user.username}.json"
|
||||
expect(response.status).to eq(200)
|
||||
json = JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json["topic_list"]["topics"].size).to eq(2)
|
||||
end
|
||||
|
||||
|
@ -510,7 +510,7 @@ RSpec.describe ListController do
|
|||
user.update!(username: "myname.test")
|
||||
get "/topics/created-by/#{user.username}", xhr: true
|
||||
expect(response.status).to eq(200)
|
||||
json = JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json["topic_list"]["topics"].size).to eq(2)
|
||||
end
|
||||
end
|
||||
|
@ -528,7 +528,7 @@ RSpec.describe ListController do
|
|||
sign_in(user)
|
||||
get "/topics/private-messages/#{user.username}.json"
|
||||
expect(response.status).to eq(200)
|
||||
json = JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json["topic_list"]["topics"].size).to eq(1)
|
||||
end
|
||||
end
|
||||
|
@ -549,7 +549,7 @@ RSpec.describe ListController do
|
|||
sign_in(user)
|
||||
get "/topics/private-messages-sent/#{user.username}.json"
|
||||
expect(response.status).to eq(200)
|
||||
json = JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json["topic_list"]["topics"].size).to eq(1)
|
||||
end
|
||||
end
|
||||
|
@ -572,7 +572,7 @@ RSpec.describe ListController do
|
|||
sign_in(user)
|
||||
get "/topics/private-messages-unread/#{user.username}.json"
|
||||
expect(response.status).to eq(200)
|
||||
json = JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json["topic_list"]["topics"].size).to eq(1)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
# rubocop:disable Discourse/NoJsonParseResponse
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
|
|
|
@ -125,14 +125,14 @@ describe NotificationsController do
|
|||
describe '#create' do
|
||||
it "can create notification" do
|
||||
create_notification(admin.id, 200, :to_not)
|
||||
expect(::JSON.parse(response.body)["id"]).to_not eq(nil)
|
||||
expect(response.parsed_body["id"]).to_not eq(nil)
|
||||
end
|
||||
end
|
||||
|
||||
describe '#update' do
|
||||
it "can update notification" do
|
||||
update_notification(8, 200, :to)
|
||||
expect(::JSON.parse(response.body)["topic_id"]).to eq(8)
|
||||
expect(response.parsed_body["topic_id"]).to eq(8)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -141,7 +141,7 @@ RSpec.describe Users::OmniauthCallbacksController do
|
|||
expect(response.location).to include("/auth/failure?message=csrf_detected")
|
||||
|
||||
get "/session/csrf.json"
|
||||
token = JSON.parse(response.body)["csrf"]
|
||||
token = response.parsed_body["csrf"]
|
||||
|
||||
post "/auth/google_oauth2", params: { authenticity_token: token }
|
||||
expect(response.status).to eq(302)
|
||||
|
|
|
@ -108,7 +108,7 @@ RSpec.describe PostActionsController do
|
|||
|
||||
expect(response.status).to eq(422)
|
||||
|
||||
expect(JSON.parse(response.body)["errors"].first).to eq(I18n.t(
|
||||
expect(response.parsed_body["errors"].first).to eq(I18n.t(
|
||||
:not_accepting_pms, username: user2.username
|
||||
))
|
||||
end
|
||||
|
|
|
@ -25,7 +25,7 @@ describe PostReadersController do
|
|||
it 'returns an empty list when nobody has read the topic' do
|
||||
get '/post_readers.json', params: { id: @post.id }
|
||||
|
||||
readers = JSON.parse(response.body)['post_readers']
|
||||
readers = response.parsed_body['post_readers']
|
||||
|
||||
expect(readers).to be_empty
|
||||
end
|
||||
|
@ -34,7 +34,7 @@ describe PostReadersController do
|
|||
TopicUser.create!(user: reader, topic: @group_message, last_read_post_number: 3)
|
||||
|
||||
get '/post_readers.json', params: { id: @post.id }
|
||||
reader_data = JSON.parse(response.body)['post_readers'].first
|
||||
reader_data = response.parsed_body['post_readers'].first
|
||||
|
||||
assert_reader_is_correctly_serialized(reader_data, reader, @post)
|
||||
end
|
||||
|
@ -43,7 +43,7 @@ describe PostReadersController do
|
|||
TopicUser.create!(user: reader, topic: @group_message, last_read_post_number: 4)
|
||||
|
||||
get '/post_readers.json', params: { id: @post.id }
|
||||
reader_data = JSON.parse(response.body)['post_readers'].first
|
||||
reader_data = response.parsed_body['post_readers'].first
|
||||
|
||||
assert_reader_is_correctly_serialized(reader_data, reader, @post)
|
||||
end
|
||||
|
@ -52,7 +52,7 @@ describe PostReadersController do
|
|||
TopicUser.create!(user: reader, topic: @group_message, last_read_post_number: 1)
|
||||
|
||||
get '/post_readers.json', params: { id: @post.id }
|
||||
readers = JSON.parse(response.body)['post_readers']
|
||||
readers = response.parsed_body['post_readers']
|
||||
|
||||
expect(readers).to be_empty
|
||||
end
|
||||
|
@ -62,7 +62,7 @@ describe PostReadersController do
|
|||
TopicUser.create!(user: reader, topic: @group_message, last_read_post_number: nil)
|
||||
|
||||
get '/post_readers.json', params: { id: @post.id }
|
||||
readers = JSON.parse(response.body)['post_readers']
|
||||
readers = response.parsed_body['post_readers']
|
||||
|
||||
expect(readers).to be_empty
|
||||
end
|
||||
|
@ -72,7 +72,7 @@ describe PostReadersController do
|
|||
reader.update(staged: true)
|
||||
|
||||
get '/post_readers.json', params: { id: @post.id }
|
||||
readers = JSON.parse(response.body)['post_readers']
|
||||
readers = response.parsed_body['post_readers']
|
||||
|
||||
expect(readers).to be_empty
|
||||
end
|
||||
|
@ -83,7 +83,7 @@ describe PostReadersController do
|
|||
TopicUser.create!(user: non_staff_user, topic: @group_message, last_read_post_number: 4)
|
||||
|
||||
get '/post_readers.json', params: { id: @post.id }
|
||||
readers = JSON.parse(response.body)['post_readers']
|
||||
readers = response.parsed_body['post_readers']
|
||||
|
||||
expect(readers).to be_empty
|
||||
end
|
||||
|
@ -94,7 +94,7 @@ describe PostReadersController do
|
|||
TopicUser.create!(user: admin, topic: @group_message, last_read_post_number: 4)
|
||||
|
||||
get '/post_readers.json', params: { id: @post.id }
|
||||
reader_data = JSON.parse(response.body)['post_readers'].first
|
||||
reader_data = response.parsed_body['post_readers'].first
|
||||
|
||||
assert_reader_is_correctly_serialized(reader_data, admin, @post)
|
||||
end
|
||||
|
@ -103,7 +103,7 @@ describe PostReadersController do
|
|||
TopicUser.create!(user: Discourse.system_user, topic: @group_message, last_read_post_number: 4)
|
||||
|
||||
get '/post_readers.json', params: { id: @post.id }
|
||||
readers = JSON.parse(response.body)['post_readers']
|
||||
readers = response.parsed_body['post_readers']
|
||||
|
||||
expect(readers).to be_empty
|
||||
end
|
||||
|
|
|
@ -81,7 +81,7 @@ describe PostsController do
|
|||
new_post = create_post
|
||||
|
||||
get "/posts/#{new_post.id}.json"
|
||||
parsed = JSON.parse(response.body)
|
||||
parsed = response.parsed_body
|
||||
|
||||
expect(parsed["topic_slug"]).to eq(new_post.topic.slug)
|
||||
expect(parsed["moderator"]).to eq(false)
|
||||
|
@ -107,7 +107,7 @@ describe PostsController do
|
|||
_third_post = Fabricate(:post, topic: first_post.topic, created_at: 3.days.ago)
|
||||
|
||||
get "/posts/by-date/#{second_post.topic_id}/#{(second_post.created_at - 2.days).strftime("%Y-%m-%d")}.json"
|
||||
json = JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
expect(json["id"]).to eq(second_post.id)
|
||||
|
@ -115,7 +115,7 @@ describe PostsController do
|
|||
|
||||
it 'returns no post if date is > at last created post' do
|
||||
get "/posts/by-date/#{post.topic_id}/2245-11-11.json"
|
||||
_json = JSON.parse(response.body)
|
||||
_json = response.parsed_body
|
||||
expect(response.status).to eq(404)
|
||||
end
|
||||
end
|
||||
|
@ -135,7 +135,7 @@ describe PostsController do
|
|||
get "/posts/#{child.id}/reply-history.json"
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
json = JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json[0]['id']).to eq(parent.id)
|
||||
expect(json[0]['user_custom_fields']['hello']).to eq('world')
|
||||
expect(json[0]['user_custom_fields']['hidden']).to be_blank
|
||||
|
@ -158,7 +158,7 @@ describe PostsController do
|
|||
get "/posts/#{parent.id}/replies.json"
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
json = JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json[0]['id']).to eq(child.id)
|
||||
expect(json[0]['user_custom_fields']['hello']).to eq('world')
|
||||
expect(json[0]['user_custom_fields']['hidden']).to be_blank
|
||||
|
@ -324,7 +324,7 @@ describe PostsController do
|
|||
put "/posts/#{post.id}.json", params: update_params
|
||||
|
||||
expect(response.status).to eq(422)
|
||||
expect(JSON.parse(response.body)['errors']).to include(I18n.t('too_late_to_edit'))
|
||||
expect(response.parsed_body['errors']).to include(I18n.t('too_late_to_edit'))
|
||||
end
|
||||
|
||||
it 'does not allow TL2 to update when edit time limit expired' do
|
||||
|
@ -338,7 +338,7 @@ describe PostsController do
|
|||
put "/posts/#{post.id}.json", params: update_params
|
||||
|
||||
expect(response.status).to eq(422)
|
||||
expect(JSON.parse(response.body)['errors']).to include(I18n.t('too_late_to_edit'))
|
||||
expect(response.parsed_body['errors']).to include(I18n.t('too_late_to_edit'))
|
||||
end
|
||||
|
||||
it 'passes the image sizes through' do
|
||||
|
@ -477,7 +477,7 @@ describe PostsController do
|
|||
end
|
||||
it "marks topic_bookmaked as true" do
|
||||
delete "/posts/#{post.id}/bookmark.json"
|
||||
expect(JSON.parse(response.body)['topic_bookmarked']).to eq(true)
|
||||
expect(response.parsed_body['topic_bookmarked']).to eq(true)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -671,7 +671,7 @@ describe PostsController do
|
|||
|
||||
expect(response.status).to eq(400)
|
||||
|
||||
expect(JSON.parse(response.body)["errors"]).to include(
|
||||
expect(response.parsed_body["errors"]).to include(
|
||||
I18n.t("invalid_params", message: "category")
|
||||
)
|
||||
end
|
||||
|
@ -698,7 +698,7 @@ describe PostsController do
|
|||
}
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
parsed = ::JSON.parse(response.body)
|
||||
parsed = response.parsed_body
|
||||
|
||||
expect(parsed["action"]).to eq("enqueued")
|
||||
|
||||
|
@ -737,7 +737,7 @@ describe PostsController do
|
|||
}
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
parsed = ::JSON.parse(response.body)
|
||||
parsed = response.parsed_body
|
||||
|
||||
expect(parsed["action"]).not_to be_present
|
||||
|
||||
|
@ -756,7 +756,7 @@ describe PostsController do
|
|||
}
|
||||
|
||||
expect(response).not_to be_successful
|
||||
parsed = ::JSON.parse(response.body)
|
||||
parsed = response.parsed_body
|
||||
expect(parsed["action"]).not_to eq("enqueued")
|
||||
end
|
||||
|
||||
|
@ -769,7 +769,7 @@ describe PostsController do
|
|||
}
|
||||
|
||||
expect(response).not_to be_successful
|
||||
parsed = ::JSON.parse(response.body)
|
||||
parsed = response.parsed_body
|
||||
expect(parsed["action"]).not_to eq("enqueued")
|
||||
end
|
||||
end
|
||||
|
@ -783,7 +783,7 @@ describe PostsController do
|
|||
}
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
parsed = ::JSON.parse(response.body)
|
||||
parsed = response.parsed_body
|
||||
|
||||
expect(parsed["action"]).to eq("enqueued")
|
||||
reviewable = ReviewableQueuedPost.find_by(created_by: user)
|
||||
|
@ -820,7 +820,7 @@ describe PostsController do
|
|||
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
parsed = ::JSON.parse(response.body)
|
||||
parsed = response.parsed_body
|
||||
post = Post.find(parsed['id'])
|
||||
|
||||
expect(post.topic.topic_allowed_users.length).to eq(1)
|
||||
|
@ -835,7 +835,7 @@ describe PostsController do
|
|||
}
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
parsed = ::JSON.parse(response.body)
|
||||
parsed = response.parsed_body
|
||||
expect(parsed['post']).to be_present
|
||||
expect(parsed['post']['cooked']).to be_present
|
||||
end
|
||||
|
@ -884,7 +884,7 @@ describe PostsController do
|
|||
}
|
||||
|
||||
expect(response.status).to eq(422)
|
||||
json = JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json['errors']).to be_present
|
||||
end
|
||||
|
||||
|
@ -983,7 +983,7 @@ describe PostsController do
|
|||
}
|
||||
|
||||
expect(response.status).to eq(422)
|
||||
expect(JSON.parse(response.body)["errors"]).to include(
|
||||
expect(response.parsed_body["errors"]).to include(
|
||||
I18n.t("activerecord.errors.models.topic.attributes.base.no_user_selected")
|
||||
)
|
||||
end
|
||||
|
@ -1004,7 +1004,7 @@ describe PostsController do
|
|||
}
|
||||
|
||||
expect(response.status).to eq(422)
|
||||
expect(JSON.parse(response.body)["errors"]).to include(
|
||||
expect(response.parsed_body["errors"]).to include(
|
||||
I18n.t("create_pm_on_existing_topic")
|
||||
)
|
||||
end
|
||||
|
@ -1027,7 +1027,7 @@ describe PostsController do
|
|||
meta_data: { xyz: 'abc' }
|
||||
}
|
||||
|
||||
expect(JSON.parse(response.body)["errors"]).to include(I18n.t(:spamming_host))
|
||||
expect(response.parsed_body["errors"]).to include(I18n.t(:spamming_host))
|
||||
end
|
||||
|
||||
context "allow_uncategorized_topics is false" do
|
||||
|
@ -1102,7 +1102,7 @@ describe PostsController do
|
|||
shared_draft: 'true'
|
||||
}
|
||||
expect(response.status).to eq(200)
|
||||
result = JSON.parse(response.body)
|
||||
result = response.parsed_body
|
||||
topic = Topic.find(result['topic_id'])
|
||||
expect(topic.category_id).to eq(shared_category.id)
|
||||
expect(topic.shared_draft.category_id).to eq(destination_category.id)
|
||||
|
@ -1394,13 +1394,13 @@ describe PostsController do
|
|||
it "fails when revision is blank" do
|
||||
put "/posts/#{post_id}/revisions/#{blank_post_revision.number}/revert.json"
|
||||
expect(response.status).to eq(422)
|
||||
expect(JSON.parse(response.body)['errors']).to include(I18n.t('revert_version_same'))
|
||||
expect(response.parsed_body['errors']).to include(I18n.t('revert_version_same'))
|
||||
end
|
||||
|
||||
it "fails when revised version is same as current version" do
|
||||
put "/posts/#{post_id}/revisions/#{same_post_revision.number}/revert.json"
|
||||
expect(response.status).to eq(422)
|
||||
expect(JSON.parse(response.body)['errors']).to include(I18n.t('revert_version_same'))
|
||||
expect(response.parsed_body['errors']).to include(I18n.t('revert_version_same'))
|
||||
end
|
||||
|
||||
it "works!" do
|
||||
|
@ -1435,7 +1435,7 @@ describe PostsController do
|
|||
TopicEmbed.expects(:expanded_for).with(post).returns("full content")
|
||||
get "/posts/#{post.id}/expand-embed.json"
|
||||
expect(response.status).to eq(200)
|
||||
expect(::JSON.parse(response.body)['cooked']).to eq("full content")
|
||||
expect(response.parsed_body['cooked']).to eq("full content")
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -1472,7 +1472,7 @@ describe PostsController do
|
|||
get "/posts/#{user.username}/flagged.json"
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
expect(JSON.parse(response.body).length).to eq(2)
|
||||
expect(response.parsed_body.length).to eq(2)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -1507,7 +1507,7 @@ describe PostsController do
|
|||
get "/posts/#{user.username}/deleted.json"
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
data = JSON.parse(response.body)
|
||||
data = response.parsed_body
|
||||
expect(data.length).to eq(0)
|
||||
end
|
||||
|
||||
|
@ -1521,7 +1521,7 @@ describe PostsController do
|
|||
get "/posts/#{user.username}/deleted.json"
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
data = JSON.parse(response.body)
|
||||
data = response.parsed_body
|
||||
expect(data.length).to eq(0)
|
||||
end
|
||||
|
||||
|
@ -1537,7 +1537,7 @@ describe PostsController do
|
|||
get "/posts/#{user.username}/deleted.json"
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
data = JSON.parse(response.body)
|
||||
data = response.parsed_body
|
||||
expect(data.length).to eq(1)
|
||||
expect(data[0]["id"]).to eq(post_deleted_by_admin.id)
|
||||
expect(data[0]["deleted_by"]["id"]).to eq(admin.id)
|
||||
|
@ -1650,7 +1650,7 @@ describe PostsController do
|
|||
get "/private-posts.json"
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
json = ::JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
post_ids = json['private_posts'].map { |p| p['id'] }
|
||||
|
||||
expect(post_ids).to include private_post.id
|
||||
|
@ -1683,7 +1683,7 @@ describe PostsController do
|
|||
get "/posts.json"
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
json = ::JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
post_ids = json['latest_posts'].map { |p| p['id'] }
|
||||
|
||||
expect(post_ids).to include public_post.id
|
||||
|
@ -1699,7 +1699,7 @@ describe PostsController do
|
|||
get "/posts/#{post.id}/cooked.json"
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
json = ::JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
|
||||
expect(json).to be_present
|
||||
expect(json['cooked']).to eq('WAt')
|
||||
|
@ -1725,7 +1725,7 @@ describe PostsController do
|
|||
get "/posts/#{post.id}/raw-email.json"
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
json = ::JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json['raw_email']).to eq('email_content')
|
||||
end
|
||||
end
|
||||
|
|
|
@ -48,7 +48,7 @@ describe ReviewablesController do
|
|||
it "returns empty JSON when nothing to review" do
|
||||
get "/review.json"
|
||||
expect(response.code).to eq("200")
|
||||
json = ::JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json['reviewables']).to eq([])
|
||||
end
|
||||
|
||||
|
@ -57,7 +57,7 @@ describe ReviewablesController do
|
|||
|
||||
get "/review.json"
|
||||
expect(response.code).to eq("200")
|
||||
json = ::JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json['reviewables']).to be_present
|
||||
|
||||
json_review = json['reviewables'][0]
|
||||
|
@ -79,14 +79,14 @@ describe ReviewablesController do
|
|||
it "supports filtering by score" do
|
||||
get "/review.json?min_score=1000"
|
||||
expect(response.code).to eq("200")
|
||||
json = ::JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json['reviewables']).to be_blank
|
||||
end
|
||||
|
||||
it "supports offsets" do
|
||||
get "/review.json?offset=100"
|
||||
expect(response.code).to eq("200")
|
||||
json = ::JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json['reviewables']).to be_blank
|
||||
end
|
||||
|
||||
|
@ -94,7 +94,7 @@ describe ReviewablesController do
|
|||
Fabricate(:reviewable)
|
||||
get "/review.json?type=ReviewableUser"
|
||||
expect(response.code).to eq("200")
|
||||
json = ::JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json['reviewables']).to be_present
|
||||
end
|
||||
|
||||
|
@ -108,23 +108,23 @@ describe ReviewablesController do
|
|||
|
||||
get "/review.json?type=ReviewableUser&status=pending"
|
||||
expect(response.code).to eq("200")
|
||||
json = ::JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json['reviewables']).to be_blank
|
||||
|
||||
Fabricate(:reviewable, status: Reviewable.statuses[:approved])
|
||||
get "/review.json?type=ReviewableUser&status=approved"
|
||||
expect(response.code).to eq("200")
|
||||
json = ::JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json['reviewables']).to be_present
|
||||
|
||||
get "/review.json?type=ReviewableUser&status=reviewed"
|
||||
expect(response.code).to eq("200")
|
||||
json = ::JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json['reviewables']).to be_present
|
||||
|
||||
get "/review.json?type=ReviewableUser&status=all"
|
||||
expect(response.code).to eq("200")
|
||||
json = ::JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json['reviewables']).to be_present
|
||||
end
|
||||
|
||||
|
@ -138,18 +138,18 @@ describe ReviewablesController do
|
|||
r = Fabricate(:reviewable)
|
||||
get "/review.json?category_id=#{other_category.id}"
|
||||
expect(response.code).to eq("200")
|
||||
json = ::JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json['reviewables']).to be_blank
|
||||
|
||||
get "/review.json?category_id=#{r.category_id}"
|
||||
expect(response.code).to eq("200")
|
||||
json = ::JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json['reviewables']).to be_present
|
||||
|
||||
# By default all categories are returned
|
||||
get "/review.json"
|
||||
expect(response.code).to eq("200")
|
||||
json = ::JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json['reviewables']).to be_present
|
||||
end
|
||||
|
||||
|
@ -162,7 +162,7 @@ describe ReviewablesController do
|
|||
|
||||
get "/review.json"
|
||||
expect(response.code).to eq("200")
|
||||
json = ::JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
|
||||
json_review = json['reviewables'][0]
|
||||
expect(json_review['id']).to eq(reviewable.id)
|
||||
|
@ -173,7 +173,7 @@ describe ReviewablesController do
|
|||
let(:from) { 3.days.ago.strftime('%F') }
|
||||
let(:to) { 1.day.ago.strftime('%F') }
|
||||
|
||||
let(:reviewables) { ::JSON.parse(response.body)['reviewables'] }
|
||||
let(:reviewables) { response.parsed_body['reviewables'] }
|
||||
|
||||
it 'returns an empty array when no reviewable matches the date range' do
|
||||
reviewable = Fabricate(:reviewable)
|
||||
|
@ -231,7 +231,7 @@ describe ReviewablesController do
|
|||
get "/review/#{reviewable.id}.json"
|
||||
expect(response.code).to eq("200")
|
||||
|
||||
json = ::JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json['reviewable']['id']).to eq(reviewable.id)
|
||||
end
|
||||
|
||||
|
@ -264,7 +264,7 @@ describe ReviewablesController do
|
|||
it "returns the conversation" do
|
||||
get "/review/#{reviewable.id}.json"
|
||||
expect(response.code).to eq("200")
|
||||
json = ::JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
|
||||
score = json['reviewable_scores'][0]
|
||||
conversation_id = score['reviewable_conversation_id']
|
||||
|
@ -298,7 +298,7 @@ describe ReviewablesController do
|
|||
get "/review/#{reviewable.id}/explain.json"
|
||||
expect(response.code).to eq("200")
|
||||
|
||||
json = ::JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json['reviewable_explanation']['id']).to eq(reviewable.id)
|
||||
expect(json['reviewable_explanation']['total_score']).to eq(reviewable.score)
|
||||
end
|
||||
|
@ -337,7 +337,7 @@ describe ReviewablesController do
|
|||
version = qp.version
|
||||
put "/review/#{qp.id}/perform/approve_post.json?version=#{version}"
|
||||
expect(response.code).to eq("422")
|
||||
result = ::JSON.parse(response.body)
|
||||
result = response.parsed_body
|
||||
expect(result['errors']).to be_present
|
||||
expect(qp.reload.version).to eq(version)
|
||||
end
|
||||
|
@ -345,7 +345,7 @@ describe ReviewablesController do
|
|||
it "requires a version parameter" do
|
||||
put "/review/#{reviewable.id}/perform/approve_user.json"
|
||||
expect(response.code).to eq("422")
|
||||
result = ::JSON.parse(response.body)
|
||||
result = response.parsed_body
|
||||
expect(result['errors']).to be_present
|
||||
end
|
||||
|
||||
|
@ -354,7 +354,7 @@ describe ReviewablesController do
|
|||
|
||||
put "/review/#{reviewable.id}/perform/approve_user.json?version=#{reviewable.version}"
|
||||
expect(response.code).to eq("200")
|
||||
json = ::JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json['reviewable_perform_result']['success']).to eq(true)
|
||||
expect(json['reviewable_perform_result']['version']).to eq(1)
|
||||
expect(json['reviewable_perform_result']['transition_to']).to eq('approved')
|
||||
|
@ -394,7 +394,7 @@ describe ReviewablesController do
|
|||
it "fails when the version is wrong" do
|
||||
put "/review/#{reviewable.id}/perform/approve_user.json?version=#{reviewable.version + 1}"
|
||||
expect(response.code).to eq("409")
|
||||
json = ::JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json['errors']).to be_present
|
||||
end
|
||||
end
|
||||
|
@ -410,7 +410,7 @@ describe ReviewablesController do
|
|||
it "returns empty json for no reviewables" do
|
||||
get "/review/topics.json"
|
||||
expect(response.code).to eq("200")
|
||||
json = ::JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json['reviewable_topics']).to be_blank
|
||||
end
|
||||
|
||||
|
@ -422,7 +422,7 @@ describe ReviewablesController do
|
|||
|
||||
get "/review/topics.json"
|
||||
expect(response.code).to eq("200")
|
||||
json = ::JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
json_topic = json['reviewable_topics'].find { |rt| rt['id'] == post0.topic_id }
|
||||
expect(json_topic['claimed_by_id']).to eq(moderator.id)
|
||||
|
||||
|
@ -439,7 +439,7 @@ describe ReviewablesController do
|
|||
get "/review/topics.json"
|
||||
expect(response.code).to eq("200")
|
||||
|
||||
json = ::JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json['reviewable_topics']).to be_present
|
||||
|
||||
json_topic = json['reviewable_topics'].find { |rt| rt['id'] == post0.topic_id }
|
||||
|
@ -456,7 +456,7 @@ describe ReviewablesController do
|
|||
it "renders the settings as JSON" do
|
||||
get "/review/settings.json"
|
||||
expect(response.code).to eq("200")
|
||||
json = ::JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json['reviewable_settings']).to be_present
|
||||
expect(json['reviewable_score_types']).to be_present
|
||||
end
|
||||
|
@ -552,7 +552,7 @@ describe ReviewablesController do
|
|||
)
|
||||
expect(history).to be_present
|
||||
|
||||
json = ::JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json['payload']['raw']).to eq('new raw content')
|
||||
expect(json['version'] > 0).to eq(true)
|
||||
end
|
||||
|
@ -580,7 +580,7 @@ describe ReviewablesController do
|
|||
expect(reviewable_topic.payload['tags']).to eq(['t2', 't3', 't1'])
|
||||
expect(reviewable_topic.category_id).to eq(new_category_id)
|
||||
|
||||
json = ::JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json['payload']['raw']).to eq('new topic op')
|
||||
expect(json['payload']['title']).to eq('new topic title')
|
||||
expect(json['payload']['extra']).to be_blank
|
||||
|
|
|
@ -6,7 +6,7 @@ RSpec.describe RobotsTxtController do
|
|||
describe '#builder' do
|
||||
it "returns json information for building a robots.txt" do
|
||||
get "/robots-builder.json"
|
||||
json = ::JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json).to be_present
|
||||
expect(json['header']).to be_present
|
||||
expect(json['agents']).to be_present
|
||||
|
@ -17,7 +17,7 @@ RSpec.describe RobotsTxtController do
|
|||
|
||||
get "/robots-builder.json"
|
||||
expect(response.status).to eq(200)
|
||||
json = ::JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json['header']).to be_present
|
||||
expect(json['agents']).to be_present
|
||||
expect(json['overridden']).to eq("something")
|
||||
|
|
|
@ -68,7 +68,7 @@ describe SearchController do
|
|||
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
data = JSON.parse(response.body)
|
||||
data = response.parsed_body
|
||||
|
||||
expect(data["posts"]).to be_empty
|
||||
expect(data["grouped_search_result"]["error"]).not_to be_empty
|
||||
|
@ -93,7 +93,7 @@ describe SearchController do
|
|||
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
data = JSON.parse(response.body)
|
||||
data = response.parsed_body
|
||||
|
||||
expect(data['posts'].length).to eq(1)
|
||||
expect(data['posts'][0]['id']).to eq(awesome_post.id)
|
||||
|
@ -108,7 +108,7 @@ describe SearchController do
|
|||
}
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
data = JSON.parse(response.body)
|
||||
data = response.parsed_body
|
||||
|
||||
expect(data['posts'][0]['id']).to eq(user_post.id)
|
||||
expect(data['users']).to be_blank
|
||||
|
@ -118,7 +118,7 @@ describe SearchController do
|
|||
}
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
data = JSON.parse(response.body)
|
||||
data = response.parsed_body
|
||||
|
||||
expect(data['posts']).to be_blank
|
||||
expect(data['users'][0]['id']).to eq(user.id)
|
||||
|
@ -135,7 +135,7 @@ describe SearchController do
|
|||
}
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
data = JSON.parse(response.body)
|
||||
data = response.parsed_body
|
||||
|
||||
expect(data['topics'][0]['id']).to eq(awesome_post.topic_id)
|
||||
end
|
||||
|
@ -149,7 +149,7 @@ describe SearchController do
|
|||
}
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
data = JSON.parse(response.body)
|
||||
data = response.parsed_body
|
||||
|
||||
expect(data['topics'][0]['id']).to eq(user_post.topic_id)
|
||||
end
|
||||
|
@ -164,7 +164,7 @@ describe SearchController do
|
|||
expect(response.status).to eq(200)
|
||||
expect(SearchLog.where(term: 'wookie')).to be_present
|
||||
|
||||
json = JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
search_log_id = json['grouped_search_result']['search_log_id']
|
||||
expect(search_log_id).to be_present
|
||||
|
||||
|
@ -257,7 +257,7 @@ describe SearchController do
|
|||
it "sort posts with search priority when search term is empty" do
|
||||
get "/search.json", params: { q: 'status:open' }
|
||||
expect(response.status).to eq(200)
|
||||
data = JSON.parse(response.body)
|
||||
data = response.parsed_body
|
||||
post1 = data["posts"].find { |e| e["id"] == old_very_hight_priority_post.id }
|
||||
post2 = data["posts"].find { |e| e["id"] == low_priority_post.id }
|
||||
expect(data["posts"][0]["id"]).to eq(old_very_hight_priority_post.id)
|
||||
|
@ -267,7 +267,7 @@ describe SearchController do
|
|||
it "sort posts with search priority when no order query" do
|
||||
get "/search.json", params: { q: 'status:open Priority Post' }
|
||||
expect(response.status).to eq(200)
|
||||
data = JSON.parse(response.body)
|
||||
data = response.parsed_body
|
||||
expect(data["posts"][0]["id"]).to eq(old_very_hight_priority_post.id)
|
||||
expect(data["posts"][1]["id"]).to eq(hight_priority_post.id)
|
||||
expect(data["posts"][2]["id"]).to eq(low_priority_post.id)
|
||||
|
@ -276,7 +276,7 @@ describe SearchController do
|
|||
it "doesn't sort posts with search piority when query with order" do
|
||||
get "/search.json", params: { q: 'status:open order:latest Priority Post' }
|
||||
expect(response.status).to eq(200)
|
||||
data = JSON.parse(response.body)
|
||||
data = response.parsed_body
|
||||
expect(data["posts"][0]["id"]).to eq(hight_priority_post.id)
|
||||
expect(data["posts"][1]["id"]).to eq(low_priority_post.id)
|
||||
expect(data["posts"][2]["id"]).to eq(old_very_hight_priority_post.id)
|
||||
|
|
|
@ -60,8 +60,8 @@ RSpec.describe SessionController do
|
|||
it 'returns information' do
|
||||
get "/session/email-login/#{email_token.token}.json"
|
||||
|
||||
expect(JSON.parse(response.body)["can_login"]).to eq(true)
|
||||
expect(JSON.parse(response.body)["second_factor_required"]).to eq(nil)
|
||||
expect(response.parsed_body["can_login"]).to eq(true)
|
||||
expect(response.parsed_body["second_factor_required"]).to eq(nil)
|
||||
|
||||
# Does not log in the user
|
||||
expect(session[:current_user_id]).to be_nil
|
||||
|
@ -90,7 +90,7 @@ RSpec.describe SessionController do
|
|||
it "includes that information in the response" do
|
||||
get "/session/email-login/#{email_token.token}.json"
|
||||
|
||||
response_body_parsed = JSON.parse(response.body)
|
||||
response_body_parsed = response.parsed_body
|
||||
expect(response_body_parsed["can_login"]).to eq(true)
|
||||
expect(response_body_parsed["second_factor_required"]).to eq(true)
|
||||
expect(response_body_parsed["backup_codes_enabled"]).to eq(true)
|
||||
|
@ -103,7 +103,7 @@ RSpec.describe SessionController do
|
|||
it "includes that information in the response" do
|
||||
get "/session/email-login/#{email_token.token}.json"
|
||||
|
||||
response_body_parsed = JSON.parse(response.body)
|
||||
response_body_parsed = response.parsed_body
|
||||
expect(response_body_parsed["can_login"]).to eq(true)
|
||||
expect(response_body_parsed["security_key_required"]).to eq(true)
|
||||
expect(response_body_parsed["second_factor_required"]).to eq(nil)
|
||||
|
@ -148,7 +148,7 @@ RSpec.describe SessionController do
|
|||
post "/session/email-login/adasdad.json"
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
expect(JSON.parse(response.body)["error"]).to eq(
|
||||
expect(response.parsed_body["error"]).to eq(
|
||||
I18n.t('email_login.invalid_token')
|
||||
)
|
||||
end
|
||||
|
@ -161,7 +161,7 @@ RSpec.describe SessionController do
|
|||
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
expect(JSON.parse(response.body)["error"]).to eq(
|
||||
expect(response.parsed_body["error"]).to eq(
|
||||
I18n.t('email_login.invalid_token')
|
||||
)
|
||||
end
|
||||
|
@ -172,7 +172,7 @@ RSpec.describe SessionController do
|
|||
it 'returns success' do
|
||||
post "/session/email-login/#{email_token.token}.json"
|
||||
|
||||
expect(JSON.parse(response.body)["success"]).to eq("OK")
|
||||
expect(response.parsed_body["success"]).to eq("OK")
|
||||
expect(session[:current_user_id]).to eq(user.id)
|
||||
end
|
||||
|
||||
|
@ -201,7 +201,7 @@ RSpec.describe SessionController do
|
|||
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
expect(JSON.parse(response.body)["error"]).to eq(I18n.t("login.not_approved"))
|
||||
expect(response.parsed_body["error"]).to eq(I18n.t("login.not_approved"))
|
||||
expect(session[:current_user_id]).to eq(nil)
|
||||
end
|
||||
|
||||
|
@ -221,7 +221,7 @@ RSpec.describe SessionController do
|
|||
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
expect(JSON.parse(response.body)["error"]).to eq(
|
||||
expect(response.parsed_body["error"]).to eq(
|
||||
I18n.t("login.admin_not_allowed_from_ip_address", username: user.username)
|
||||
)
|
||||
expect(session[:current_user_id]).to eq(nil)
|
||||
|
@ -245,7 +245,7 @@ RSpec.describe SessionController do
|
|||
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
expect(JSON.parse(response.body)["error"]).to eq(
|
||||
expect(response.parsed_body["error"]).to eq(
|
||||
I18n.t("login.not_allowed_from_ip_address", username: user.username)
|
||||
)
|
||||
expect(session[:current_user_id]).to eq(nil)
|
||||
|
@ -270,7 +270,7 @@ RSpec.describe SessionController do
|
|||
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
expect(JSON.parse(response.body)["error"]).to eq(
|
||||
expect(response.parsed_body["error"]).to eq(
|
||||
I18n.t("login.suspended", date: I18n.l(user.suspended_till, format: :date_only)
|
||||
))
|
||||
expect(session[:current_user_id]).to eq(nil)
|
||||
|
@ -290,7 +290,7 @@ RSpec.describe SessionController do
|
|||
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
expect(JSON.parse(response.body)["error"]).to eq(
|
||||
expect(response.parsed_body["error"]).to eq(
|
||||
I18n.t("login.invalid_second_factor_code")
|
||||
)
|
||||
expect(session[:current_user_id]).to eq(nil)
|
||||
|
@ -304,7 +304,7 @@ RSpec.describe SessionController do
|
|||
}
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
expect(JSON.parse(response.body)["error"]).to eq(
|
||||
expect(response.parsed_body["error"]).to eq(
|
||||
I18n.t("login.invalid_second_factor_code")
|
||||
)
|
||||
expect(session[:current_user_id]).to eq(nil)
|
||||
|
@ -320,7 +320,7 @@ RSpec.describe SessionController do
|
|||
second_factor_method: UserSecondFactor.methods[:totp]
|
||||
}
|
||||
|
||||
expect(JSON.parse(response.body)["success"]).to eq("OK")
|
||||
expect(response.parsed_body["success"]).to eq("OK")
|
||||
expect(session[:current_user_id]).to eq(user.id)
|
||||
end
|
||||
end
|
||||
|
@ -331,7 +331,7 @@ RSpec.describe SessionController do
|
|||
second_factor_method: UserSecondFactor.methods[:backup_codes]
|
||||
}
|
||||
|
||||
expect(JSON.parse(response.body)["success"]).to eq("OK")
|
||||
expect(response.parsed_body["success"]).to eq("OK")
|
||||
expect(session[:current_user_id]).to eq(user.id)
|
||||
end
|
||||
end
|
||||
|
@ -346,7 +346,7 @@ RSpec.describe SessionController do
|
|||
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
expect(JSON.parse(response.body)["error"]).to eq(
|
||||
expect(response.parsed_body["error"]).to eq(
|
||||
I18n.t("login.invalid_second_factor_code")
|
||||
)
|
||||
expect(session[:current_user_id]).to eq(nil)
|
||||
|
@ -381,7 +381,7 @@ RSpec.describe SessionController do
|
|||
|
||||
expect(response.status).to eq(200)
|
||||
expect(session[:current_user_id]).to eq(nil)
|
||||
response_body = JSON.parse(response.body)
|
||||
response_body = response.parsed_body
|
||||
expect(response_body['error']).to eq(I18n.t(
|
||||
'login.not_enabled_second_factor_method'
|
||||
))
|
||||
|
@ -402,7 +402,7 @@ RSpec.describe SessionController do
|
|||
|
||||
expect(response.status).to eq(200)
|
||||
expect(session[:current_user_id]).to eq(nil)
|
||||
response_body = JSON.parse(response.body)
|
||||
response_body = response.parsed_body
|
||||
expect(response_body["failed"]).to eq("FAILED")
|
||||
expect(response_body['error']).to eq(I18n.t(
|
||||
'webauthn.validation.not_found_error'
|
||||
|
@ -447,7 +447,7 @@ RSpec.describe SessionController do
|
|||
|
||||
expect(response.status).to eq(200)
|
||||
expect(session[:current_user_id]).to eq(nil)
|
||||
response_body = JSON.parse(response.body)
|
||||
response_body = response.parsed_body
|
||||
expect(response_body['error']).to eq(I18n.t(
|
||||
'login.invalid_second_factor_code'
|
||||
))
|
||||
|
@ -461,7 +461,7 @@ RSpec.describe SessionController do
|
|||
|
||||
expect(response.status).to eq(200)
|
||||
expect(session[:current_user_id]).to eq(nil)
|
||||
response_body = JSON.parse(response.body)
|
||||
response_body = response.parsed_body
|
||||
expect(response_body['error']).to eq(I18n.t(
|
||||
'login.invalid_second_factor_code'
|
||||
))
|
||||
|
@ -491,7 +491,7 @@ RSpec.describe SessionController do
|
|||
get "/session/#{user.username}/become.json"
|
||||
|
||||
expect(response.status).to eq(403)
|
||||
expect(JSON.parse(response.body)["error_type"]).to eq("invalid_access")
|
||||
expect(response.parsed_body["error_type"]).to eq("invalid_access")
|
||||
expect(session[:current_user_id]).to be_blank
|
||||
end
|
||||
|
||||
|
@ -1226,7 +1226,7 @@ RSpec.describe SessionController do
|
|||
}
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
expect(::JSON.parse(response.body)['error']).to eq(
|
||||
expect(response.parsed_body['error']).to eq(
|
||||
I18n.t("login.incorrect_username_email_or_password")
|
||||
)
|
||||
end
|
||||
|
@ -1240,7 +1240,7 @@ RSpec.describe SessionController do
|
|||
}
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
expect(::JSON.parse(response.body)['error']).to eq(
|
||||
expect(response.parsed_body['error']).to eq(
|
||||
I18n.t("login.incorrect_username_email_or_password")
|
||||
)
|
||||
end
|
||||
|
@ -1258,7 +1258,7 @@ RSpec.describe SessionController do
|
|||
}
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
expect(JSON.parse(response.body)['error']).to eq(I18n.t('login.suspended_with_reason',
|
||||
expect(response.parsed_body['error']).to eq(I18n.t('login.suspended_with_reason',
|
||||
date: I18n.l(user.suspended_till, format: :date_only),
|
||||
reason: Rack::Utils.escape_html(user.suspend_reason)
|
||||
))
|
||||
|
@ -1275,7 +1275,7 @@ RSpec.describe SessionController do
|
|||
}
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
expect(JSON.parse(response.body)['error']).to eq(I18n.t('login.not_activated'))
|
||||
expect(response.parsed_body['error']).to eq(I18n.t('login.not_activated'))
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -1342,7 +1342,7 @@ RSpec.describe SessionController do
|
|||
|
||||
expect(response.status).to eq(200)
|
||||
expect(session[:current_user_id]).to eq(nil)
|
||||
response_body = JSON.parse(response.body)
|
||||
response_body = response.parsed_body
|
||||
expect(response_body["failed"]).to eq("FAILED")
|
||||
expect(response_body['error']).to eq(I18n.t(
|
||||
'login.invalid_security_key'
|
||||
|
@ -1366,7 +1366,7 @@ RSpec.describe SessionController do
|
|||
|
||||
expect(response.status).to eq(200)
|
||||
expect(session[:current_user_id]).to eq(nil)
|
||||
response_body = JSON.parse(response.body)
|
||||
response_body = response.parsed_body
|
||||
expect(response_body["failed"]).to eq("FAILED")
|
||||
expect(response_body['error']).to eq(I18n.t(
|
||||
'webauthn.validation.not_found_error'
|
||||
|
@ -1407,9 +1407,9 @@ RSpec.describe SessionController do
|
|||
|
||||
expect(response.status).to eq(200)
|
||||
expect(session[:current_user_id]).to eq(nil)
|
||||
response_body = JSON.parse(response.body)
|
||||
response_body = response.parsed_body
|
||||
expect(response_body["failed"]).to eq("FAILED")
|
||||
expect(JSON.parse(response.body)['error']).to eq(I18n.t(
|
||||
expect(response.parsed_body['error']).to eq(I18n.t(
|
||||
'login.not_enabled_second_factor_method'
|
||||
))
|
||||
end
|
||||
|
@ -1428,7 +1428,7 @@ RSpec.describe SessionController do
|
|||
}
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
expect(JSON.parse(response.body)['error']).to eq(I18n.t(
|
||||
expect(response.parsed_body['error']).to eq(I18n.t(
|
||||
'login.invalid_second_factor_method'
|
||||
))
|
||||
end
|
||||
|
@ -1445,7 +1445,7 @@ RSpec.describe SessionController do
|
|||
}
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
expect(JSON.parse(response.body)['error']).to eq(I18n.t(
|
||||
expect(response.parsed_body['error']).to eq(I18n.t(
|
||||
'login.invalid_second_factor_code'
|
||||
))
|
||||
end
|
||||
|
@ -1460,7 +1460,7 @@ RSpec.describe SessionController do
|
|||
}
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
expect(JSON.parse(response.body)['error']).to eq(I18n.t(
|
||||
expect(response.parsed_body['error']).to eq(I18n.t(
|
||||
'login.invalid_second_factor_code'
|
||||
))
|
||||
end
|
||||
|
@ -1553,7 +1553,7 @@ RSpec.describe SessionController do
|
|||
login: username, password: 'myawesomepassword'
|
||||
}
|
||||
expect(response.status).to eq(200)
|
||||
expect(::JSON.parse(response.body)['error']).not_to be_present
|
||||
expect(response.parsed_body['error']).not_to be_present
|
||||
end
|
||||
|
||||
it "strips spaces from the email" do
|
||||
|
@ -1561,7 +1561,7 @@ RSpec.describe SessionController do
|
|||
login: email, password: 'myawesomepassword'
|
||||
}
|
||||
expect(response.status).to eq(200)
|
||||
expect(::JSON.parse(response.body)['error']).not_to be_present
|
||||
expect(response.parsed_body['error']).not_to be_present
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -1585,7 +1585,7 @@ RSpec.describe SessionController do
|
|||
|
||||
it "shows the 'not approved' error message" do
|
||||
expect(response.status).to eq(200)
|
||||
expect(JSON.parse(response.body)['error']).to eq(
|
||||
expect(response.parsed_body['error']).to eq(
|
||||
I18n.t('login.not_approved')
|
||||
)
|
||||
end
|
||||
|
@ -1635,7 +1635,7 @@ RSpec.describe SessionController do
|
|||
}
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
expect(JSON.parse(response.body)['error']).to be_present
|
||||
expect(response.parsed_body['error']).to be_present
|
||||
expect(session[:current_user_id]).not_to eq(user.id)
|
||||
end
|
||||
|
||||
|
@ -1670,7 +1670,7 @@ RSpec.describe SessionController do
|
|||
it "shows the 'not activated' error message" do
|
||||
post_login
|
||||
expect(response.status).to eq(200)
|
||||
expect(JSON.parse(response.body)['error']).to eq(
|
||||
expect(response.parsed_body['error']).to eq(
|
||||
I18n.t 'login.not_activated'
|
||||
)
|
||||
end
|
||||
|
@ -1681,7 +1681,7 @@ RSpec.describe SessionController do
|
|||
it "shows the 'not approved' error message" do
|
||||
post_login
|
||||
expect(response.status).to eq(200)
|
||||
expect(JSON.parse(response.body)['error']).to eq(
|
||||
expect(response.parsed_body['error']).to eq(
|
||||
I18n.t 'login.not_approved'
|
||||
)
|
||||
end
|
||||
|
@ -1707,7 +1707,7 @@ RSpec.describe SessionController do
|
|||
}
|
||||
|
||||
expect(response.status).to eq(429)
|
||||
json = JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json["error_type"]).to eq("rate_limit")
|
||||
end
|
||||
|
||||
|
@ -1732,7 +1732,7 @@ RSpec.describe SessionController do
|
|||
}
|
||||
|
||||
expect(response.status).to eq(429)
|
||||
json = JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json["error_type"]).to eq("rate_limit")
|
||||
end
|
||||
end
|
||||
|
@ -1936,7 +1936,7 @@ RSpec.describe SessionController do
|
|||
it "returns the JSON for the user" do
|
||||
get "/session/current.json"
|
||||
expect(response.status).to eq(200)
|
||||
json = ::JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json['current_user']).to be_present
|
||||
expect(json['current_user']['id']).to eq(user.id)
|
||||
end
|
||||
|
|
|
@ -33,7 +33,7 @@ describe SimilarTopicsController do
|
|||
|
||||
get "/topics/similar_to.json", params: { title: title, raw: raw }
|
||||
expect(response.status).to eq(200)
|
||||
json = ::JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json["similar_topics"].size).to eq(0)
|
||||
end
|
||||
|
||||
|
@ -51,7 +51,7 @@ describe SimilarTopicsController do
|
|||
get "/topics/similar_to.json", params: { title: title, raw: raw }
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
similar_topics = ::JSON.parse(response.body)["similar_topics"]
|
||||
similar_topics = response.parsed_body["similar_topics"]
|
||||
expect(similar_topics.size).to eq(1)
|
||||
expect(similar_topics.first["topic_id"]).to eq(topic.id)
|
||||
end
|
||||
|
@ -69,7 +69,7 @@ describe SimilarTopicsController do
|
|||
get "/topics/similar_to.json", params: { title: title, raw: raw }
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
similar_topics = ::JSON.parse(response.body)["similar_topics"].map { |topic| topic["topic_id"] }
|
||||
similar_topics = response.parsed_body["similar_topics"].map { |topic| topic["topic_id"] }
|
||||
expect(similar_topics.size).to eq(2)
|
||||
expect(similar_topics).to include(topic.id)
|
||||
expect(similar_topics).to include(private_topic.id)
|
||||
|
@ -85,7 +85,7 @@ describe SimilarTopicsController do
|
|||
get "/topics/similar_to.json", params: { title: title, raw: raw }
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
json = ::JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json["similar_topics"].size).to eq(0)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -17,7 +17,7 @@ describe SiteController do
|
|||
Theme.clear_default!
|
||||
|
||||
get "/site/basic-info.json"
|
||||
json = JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
|
||||
expected_url = UrlHelper.absolute(upload.url)
|
||||
|
||||
|
@ -38,7 +38,7 @@ describe SiteController do
|
|||
SiteSetting.share_anonymized_statistics = true
|
||||
|
||||
get "/site/statistics.json"
|
||||
json = JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
expect(json["topic_count"]).to be_present
|
||||
|
@ -74,7 +74,7 @@ describe SiteController do
|
|||
SiteSetting.selectable_avatars_enabled = false
|
||||
|
||||
get "/site/selectable-avatars.json"
|
||||
json = JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
expect(json).to eq([])
|
||||
|
@ -84,7 +84,7 @@ describe SiteController do
|
|||
SiteSetting.selectable_avatars_enabled = true
|
||||
|
||||
get "/site/selectable-avatars.json"
|
||||
json = JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
expect(json).to contain_exactly("https://www.discourse.org", "https://meta.discourse.org")
|
||||
|
|
|
@ -316,7 +316,7 @@ describe StaticController do
|
|||
it "redirects to the root" do
|
||||
post "/login.json", params: { redirect: ["/foo"] }
|
||||
expect(response.status).to eq(400)
|
||||
json = JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json["errors"]).to be_present
|
||||
expect(json["errors"]).to include(
|
||||
I18n.t("invalid_params", message: "redirect")
|
||||
|
|
|
@ -76,7 +76,7 @@ describe SvgSpriteController do
|
|||
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
data = JSON.parse(response.body)
|
||||
data = response.parsed_body
|
||||
expect(data.length).to eq(200)
|
||||
expect(data[0]["id"]).to eq("ad")
|
||||
end
|
||||
|
@ -88,7 +88,7 @@ describe SvgSpriteController do
|
|||
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
data = JSON.parse(response.body)
|
||||
data = response.parsed_body
|
||||
expect(data.length).to eq(1)
|
||||
expect(data[0]["id"]).to eq("fab-500px")
|
||||
end
|
||||
|
|
|
@ -34,7 +34,7 @@ RSpec.describe TagGroupsController do
|
|||
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
tag_groups = JSON.parse(response.body)["tag_groups"]
|
||||
tag_groups = response.parsed_body["tag_groups"]
|
||||
|
||||
expect(tag_groups.count).to eq(1)
|
||||
expect(tag_groups.first["id"]).to eq(tag_group.id)
|
||||
|
|
|
@ -3,17 +3,10 @@
|
|||
require 'rails_helper'
|
||||
|
||||
describe TagsController do
|
||||
define_method(:get_json_body) do
|
||||
::JSON.parse(response.body)
|
||||
end
|
||||
|
||||
let(:json) { get_json_body }
|
||||
|
||||
fab!(:user) { Fabricate(:user) }
|
||||
fab!(:admin) { Fabricate(:admin) }
|
||||
fab!(:regular_user) { Fabricate(:trust_level_4) }
|
||||
fab!(:moderator) { Fabricate(:moderator) }
|
||||
|
||||
fab!(:category) { Fabricate(:category) }
|
||||
fab!(:subcategory) { Fabricate(:category, parent_category_id: category.id) }
|
||||
|
||||
|
@ -33,7 +26,7 @@ describe TagsController do
|
|||
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
tags = json["tags"]
|
||||
tags = response.parsed_body["tags"]
|
||||
expect(tags.length).to eq(1)
|
||||
expect(tags[0]['text']).to eq("topic-test")
|
||||
end
|
||||
|
@ -48,9 +41,9 @@ describe TagsController do
|
|||
get "/tags.json"
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
tags = json["tags"]
|
||||
tags = response.parsed_body["tags"]
|
||||
expect(tags.length).to eq(0)
|
||||
group = json.dig('extras', 'tag_groups')&.first
|
||||
group = response.parsed_body.dig('extras', 'tag_groups')&.first
|
||||
expect(group).to be_present
|
||||
expect(group['tags'].length).to eq(2)
|
||||
expect(group['tags'].map { |t| t['id'] }).to contain_exactly(test_tag.name, topic_tag.name)
|
||||
|
@ -71,7 +64,7 @@ describe TagsController do
|
|||
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
tags = json["tags"]
|
||||
tags = response.parsed_body["tags"]
|
||||
expect(tags.length).to eq(2)
|
||||
end
|
||||
|
||||
|
@ -135,7 +128,7 @@ describe TagsController do
|
|||
it "should produce the topic inside the category and not the topic outside of it" do
|
||||
get "/tags/c/#{category.slug}/#{tag.name}.json"
|
||||
|
||||
topic_ids = json['topic_list']['topics'].map { |x| x['id'] }
|
||||
topic_ids = response.parsed_body['topic_list']['topics'].map { |x| x['id'] }
|
||||
expect(topic_ids).to include(topic_in_category.id)
|
||||
expect(topic_ids).to_not include(topic_out_of_category.id)
|
||||
expect(topic_ids).to_not include(topic_in_category_without_tag.id)
|
||||
|
@ -168,7 +161,7 @@ describe TagsController do
|
|||
it "should produce the topic inside the subcategory and not the topic outside of it" do
|
||||
get "/tags/c/#{category.slug}/#{subcategory.slug}/#{tag.name}.json"
|
||||
|
||||
topic_ids = json['topic_list']['topics'].map { |x| x['id'] }
|
||||
topic_ids = response.parsed_body['topic_list']['topics'].map { |x| x['id'] }
|
||||
expect(topic_ids).to include(topic_in_subcategory.id)
|
||||
expect(topic_ids).to_not include(topic_out_of_subcategory.id)
|
||||
expect(topic_ids).to_not include(topic_in_subcategory_without_tag.id)
|
||||
|
@ -188,26 +181,26 @@ describe TagsController do
|
|||
it "can handle tag with no synonyms" do
|
||||
get "/tag/#{tag.name}/info.json"
|
||||
expect(response.status).to eq(200)
|
||||
expect(json.dig('tag_info', 'name')).to eq(tag.name)
|
||||
expect(json.dig('tag_info', 'synonyms')).to be_empty
|
||||
expect(json.dig('tag_info', 'category_ids')).to be_empty
|
||||
expect(json.dig('tag_info', 'category_restricted')).to eq(false)
|
||||
expect(response.parsed_body.dig('tag_info', 'name')).to eq(tag.name)
|
||||
expect(response.parsed_body.dig('tag_info', 'synonyms')).to be_empty
|
||||
expect(response.parsed_body.dig('tag_info', 'category_ids')).to be_empty
|
||||
expect(response.parsed_body.dig('tag_info', 'category_restricted')).to eq(false)
|
||||
end
|
||||
|
||||
it "can handle a synonym" do
|
||||
get "/tag/#{synonym.name}/info.json"
|
||||
expect(response.status).to eq(200)
|
||||
expect(json.dig('tag_info', 'name')).to eq(synonym.name)
|
||||
expect(json.dig('tag_info', 'synonyms')).to be_empty
|
||||
expect(json.dig('tag_info', 'category_ids')).to be_empty
|
||||
expect(json.dig('tag_info', 'category_restricted')).to eq(false)
|
||||
expect(response.parsed_body.dig('tag_info', 'name')).to eq(synonym.name)
|
||||
expect(response.parsed_body.dig('tag_info', 'synonyms')).to be_empty
|
||||
expect(response.parsed_body.dig('tag_info', 'category_ids')).to be_empty
|
||||
expect(response.parsed_body.dig('tag_info', 'category_restricted')).to eq(false)
|
||||
end
|
||||
|
||||
it "can return a tag's synonyms" do
|
||||
synonym
|
||||
get "/tag/#{tag.name}/info.json"
|
||||
expect(response.status).to eq(200)
|
||||
expect(json.dig('tag_info', 'synonyms').map { |t| t['text'] }).to eq([synonym.name])
|
||||
expect(response.parsed_body.dig('tag_info', 'synonyms').map { |t| t['text'] }).to eq([synonym.name])
|
||||
end
|
||||
|
||||
it "returns 404 if tag is staff-only" do
|
||||
|
@ -230,9 +223,9 @@ describe TagsController do
|
|||
category2.update!(tag_groups: [tag_group])
|
||||
staff_category = Fabricate(:private_category, group: Fabricate(:group), tags: [tag])
|
||||
get "/tag/#{tag.name}/info.json"
|
||||
expect(json.dig('tag_info', 'category_ids')).to contain_exactly(category.id, category2.id)
|
||||
expect(json['categories']).to be_present
|
||||
expect(json.dig('tag_info', 'category_restricted')).to eq(true)
|
||||
expect(response.parsed_body.dig('tag_info', 'category_ids')).to contain_exactly(category.id, category2.id)
|
||||
expect(response.parsed_body['categories']).to be_present
|
||||
expect(response.parsed_body.dig('tag_info', 'category_restricted')).to eq(true)
|
||||
end
|
||||
|
||||
context 'tag belongs to a tag group' do
|
||||
|
@ -241,13 +234,13 @@ describe TagsController do
|
|||
it "returns tag groups if tag groups are visible" do
|
||||
SiteSetting.tags_listed_by_group = true
|
||||
get "/tag/#{tag.name}/info.json"
|
||||
expect(json.dig('tag_info', 'tag_group_names')).to eq([tag_group.name])
|
||||
expect(response.parsed_body.dig('tag_info', 'tag_group_names')).to eq([tag_group.name])
|
||||
end
|
||||
|
||||
it "doesn't return tag groups if tag groups aren't visible" do
|
||||
SiteSetting.tags_listed_by_group = false
|
||||
get "/tag/#{tag.name}/info.json"
|
||||
expect(json['tag_info'].has_key?('tag_group_names')).to eq(false)
|
||||
expect(response.parsed_body['tag_info'].has_key?('tag_group_names')).to eq(false)
|
||||
end
|
||||
|
||||
context "restricted to a private category" do
|
||||
|
@ -262,24 +255,24 @@ describe TagsController do
|
|||
it "can return categories to users who can access them" do
|
||||
sign_in(admin)
|
||||
get "/tag/#{tag.name}/info.json"
|
||||
expect(json.dig('tag_info', 'category_ids')).to contain_exactly(private_category.id)
|
||||
expect(json['categories']).to be_present
|
||||
expect(json.dig('tag_info', 'category_restricted')).to eq(true)
|
||||
expect(response.parsed_body.dig('tag_info', 'category_ids')).to contain_exactly(private_category.id)
|
||||
expect(response.parsed_body['categories']).to be_present
|
||||
expect(response.parsed_body.dig('tag_info', 'category_restricted')).to eq(true)
|
||||
end
|
||||
|
||||
it "can indicate category restriction to users who can't access them" do
|
||||
sign_in(user)
|
||||
get "/tag/#{tag.name}/info.json"
|
||||
expect(json.dig('tag_info', 'category_ids')).to be_empty
|
||||
expect(json['categories']).to be_blank
|
||||
expect(json.dig('tag_info', 'category_restricted')).to eq(true)
|
||||
expect(response.parsed_body.dig('tag_info', 'category_ids')).to be_empty
|
||||
expect(response.parsed_body['categories']).to be_blank
|
||||
expect(response.parsed_body.dig('tag_info', 'category_restricted')).to eq(true)
|
||||
end
|
||||
|
||||
it "can indicate category restriction to anon" do
|
||||
get "/tag/#{tag.name}/info.json"
|
||||
expect(json.dig('tag_info', 'category_ids')).to be_empty
|
||||
expect(json['categories']).to be_blank
|
||||
expect(json.dig('tag_info', 'category_restricted')).to eq(true)
|
||||
expect(response.parsed_body.dig('tag_info', 'category_ids')).to be_empty
|
||||
expect(response.parsed_body['categories']).to be_blank
|
||||
expect(response.parsed_body.dig('tag_info', 'category_restricted')).to eq(true)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -293,7 +286,7 @@ describe TagsController do
|
|||
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
response_tag = json["valid"].first
|
||||
response_tag = response.parsed_body["valid"].first
|
||||
expect(response_tag["value"]).to eq(tag.name)
|
||||
end
|
||||
end
|
||||
|
@ -359,7 +352,7 @@ describe TagsController do
|
|||
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
tag = json['tags']
|
||||
tag = response.parsed_body['tags']
|
||||
expect(tag[0]["id"]).to eq('test')
|
||||
end
|
||||
end
|
||||
|
@ -374,7 +367,7 @@ describe TagsController do
|
|||
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
tag = json['tags']
|
||||
tag = response.parsed_body['tags']
|
||||
expect(tag[0]["id"]).to eq('test')
|
||||
end
|
||||
|
||||
|
@ -383,7 +376,7 @@ describe TagsController do
|
|||
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
tag = json['tags']
|
||||
tag = response.parsed_body['tags']
|
||||
expect(tag[0]["id"]).to eq('test')
|
||||
end
|
||||
end
|
||||
|
@ -408,7 +401,7 @@ describe TagsController do
|
|||
|
||||
context 'tagging enabled' do
|
||||
def parse_topic_ids
|
||||
get_json_body["topic_list"]["topics"]
|
||||
response.parsed_body["topic_list"]["topics"]
|
||||
.map { |topic| topic["id"] }
|
||||
end
|
||||
|
||||
|
@ -552,7 +545,7 @@ describe TagsController do
|
|||
tag_names.each { |name| Fabricate(:tag, name: name) }
|
||||
get "/tags/filter/search.json", params: { q: 'stu' }
|
||||
expect(response.status).to eq(200)
|
||||
expect(json["results"].map { |j| j["id"] }.sort).to eq(['stuff', 'stumped'])
|
||||
expect(response.parsed_body["results"].map { |j| j["id"] }.sort).to eq(['stuff', 'stumped'])
|
||||
end
|
||||
|
||||
it "returns tags ordered by topic_count, and prioritises exact matches" do
|
||||
|
@ -562,7 +555,7 @@ describe TagsController do
|
|||
|
||||
get '/tags/filter/search.json', params: { q: 'tag', limit: 2 }
|
||||
expect(response.status).to eq(200)
|
||||
expect(json['results'].map { |j| j['id'] }).to eq(['tag', 'tag2'])
|
||||
expect(response.parsed_body['results'].map { |j| j['id'] }).to eq(['tag', 'tag2'])
|
||||
end
|
||||
|
||||
context 'with category restriction' do
|
||||
|
@ -573,17 +566,17 @@ describe TagsController do
|
|||
nope = Fabricate(:tag, name: 'nope')
|
||||
get "/tags/filter/search.json", params: { q: nope.name, categoryId: category.id }
|
||||
expect(response.status).to eq(200)
|
||||
expect(json["results"].map { |j| j["id"] }.sort).to eq([])
|
||||
expect(json["forbidden"]).to be_present
|
||||
expect(json["forbidden_message"]).to eq(I18n.t("tags.forbidden.in_this_category", tag_name: nope.name))
|
||||
expect(response.parsed_body["results"].map { |j| j["id"] }.sort).to eq([])
|
||||
expect(response.parsed_body["forbidden"]).to be_present
|
||||
expect(response.parsed_body["forbidden_message"]).to eq(I18n.t("tags.forbidden.in_this_category", tag_name: nope.name))
|
||||
end
|
||||
|
||||
it "can say if given tag is restricted to different category" do
|
||||
category
|
||||
get "/tags/filter/search.json", params: { q: yup.name, categoryId: Fabricate(:category).id }
|
||||
expect(json["results"].map { |j| j["id"] }.sort).to eq([])
|
||||
expect(json["forbidden"]).to be_present
|
||||
expect(json["forbidden_message"]).to eq(I18n.t(
|
||||
expect(response.parsed_body["results"].map { |j| j["id"] }.sort).to eq([])
|
||||
expect(response.parsed_body["forbidden"]).to be_present
|
||||
expect(response.parsed_body["forbidden_message"]).to eq(I18n.t(
|
||||
"tags.forbidden.restricted_to",
|
||||
count: 1,
|
||||
tag_name: yup.name,
|
||||
|
@ -595,7 +588,7 @@ describe TagsController do
|
|||
nope = Fabricate(:tag, name: 'nope')
|
||||
get "/tags/filter/search.json", params: { categoryId: category.id }
|
||||
expect(response.status).to eq(200)
|
||||
expect(json["results"].map { |j| j["id"] }.sort).to eq([yup.name])
|
||||
expect(response.parsed_body["results"].map { |j| j["id"] }.sort).to eq([yup.name])
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -606,21 +599,21 @@ describe TagsController do
|
|||
it "can return synonyms" do
|
||||
get "/tags/filter/search.json", params: { q: 'plant' }
|
||||
expect(response.status).to eq(200)
|
||||
expect(json['results'].map { |j| j['id'] }).to contain_exactly('plant', 'plants')
|
||||
expect(response.parsed_body['results'].map { |j| j['id'] }).to contain_exactly('plant', 'plants')
|
||||
end
|
||||
|
||||
it "can omit synonyms" do
|
||||
get "/tags/filter/search.json", params: { q: 'plant', excludeSynonyms: 'true' }
|
||||
expect(response.status).to eq(200)
|
||||
expect(json['results'].map { |j| j['id'] }).to contain_exactly('plant')
|
||||
expect(response.parsed_body['results'].map { |j| j['id'] }).to contain_exactly('plant')
|
||||
end
|
||||
|
||||
it "can return a message about synonyms not being allowed" do
|
||||
get "/tags/filter/search.json", params: { q: 'plants', excludeSynonyms: 'true' }
|
||||
expect(response.status).to eq(200)
|
||||
expect(json["results"].map { |j| j["id"] }.sort).to eq([])
|
||||
expect(json["forbidden"]).to be_present
|
||||
expect(json["forbidden_message"]).to eq(I18n.t("tags.forbidden.synonym", tag_name: tag.name))
|
||||
expect(response.parsed_body["results"].map { |j| j["id"] }.sort).to eq([])
|
||||
expect(response.parsed_body["forbidden"]).to be_present
|
||||
expect(response.parsed_body["forbidden_message"]).to eq(I18n.t("tags.forbidden.synonym", tag_name: tag.name))
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -628,7 +621,7 @@ describe TagsController do
|
|||
yup, nope = Fabricate(:tag, name: 'yup'), Fabricate(:tag, name: 'nope')
|
||||
get "/tags/filter/search.json", params: { q: 'N/ope' }
|
||||
expect(response.status).to eq(200)
|
||||
expect(json["results"].map { |j| j["id"] }.sort).to eq(["nope"])
|
||||
expect(response.parsed_body["results"].map { |j| j["id"] }.sort).to eq(["nope"])
|
||||
end
|
||||
|
||||
it "can return tags that are in secured categories but are allowed to be used" do
|
||||
|
@ -636,7 +629,7 @@ describe TagsController do
|
|||
Fabricate(:topic, category: c, tags: [Fabricate(:tag, name: "cooltag")])
|
||||
get "/tags/filter/search.json", params: { q: "cool" }
|
||||
expect(response.status).to eq(200)
|
||||
expect(json["results"].map { |j| j["id"] }).to eq(['cooltag'])
|
||||
expect(response.parsed_body["results"].map { |j| j["id"] }).to eq(['cooltag'])
|
||||
end
|
||||
|
||||
it "supports Chinese and Russian" do
|
||||
|
@ -645,13 +638,11 @@ describe TagsController do
|
|||
|
||||
get "/tags/filter/search.json", params: { q: '房' }
|
||||
expect(response.status).to eq(200)
|
||||
json = get_json_body
|
||||
expect(json["results"].map { |j| j["id"] }).to eq(['房地产'])
|
||||
expect(response.parsed_body["results"].map { |j| j["id"] }).to eq(['房地产'])
|
||||
|
||||
get "/tags/filter/search.json", params: { q: 'тема' }
|
||||
expect(response.status).to eq(200)
|
||||
json = get_json_body
|
||||
expect(json["results"].map { |j| j["id"] }).to eq(['тема-в-разработке'])
|
||||
expect(response.parsed_body["results"].map { |j| j["id"] }).to eq(['тема-в-разработке'])
|
||||
end
|
||||
|
||||
it "can return all the results" do
|
||||
|
@ -659,10 +650,10 @@ describe TagsController do
|
|||
tag_group2 = Fabricate(:tag_group, tag_names: ['common1', 'common2'])
|
||||
category = Fabricate(:category, tag_groups: [tag_group1])
|
||||
get "/tags/filter/search.json", params: { q: '', limit: 5, categoryId: category.id, filterForInput: 'true' }
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
json = get_json_body
|
||||
expect_same_tag_names(
|
||||
json["results"].map { |j| j["id"] },
|
||||
response.parsed_body["results"].map { |j| j["id"] },
|
||||
['common1', 'common2', 'group1tag', 'group1tag2']
|
||||
)
|
||||
end
|
||||
|
@ -688,7 +679,7 @@ describe TagsController do
|
|||
it 'returns a tag not found message' do
|
||||
delete "/tag/doesntexists.json"
|
||||
expect(response).not_to be_successful
|
||||
expect(json['error_type']).to eq('not_found')
|
||||
expect(response.parsed_body['error_type']).to eq('not_found')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -720,7 +711,7 @@ describe TagsController do
|
|||
it 'returns the correct unused tags' do
|
||||
get "/tags/unused.json"
|
||||
expect(response.status).to eq(200)
|
||||
expect(json["tags"]).to contain_exactly("unused1", "unused2")
|
||||
expect(response.parsed_body["tags"]).to contain_exactly("unused1", "unused2")
|
||||
end
|
||||
|
||||
it 'deletes the correct tags' do
|
||||
|
@ -817,9 +808,8 @@ describe TagsController do
|
|||
tag3 = Fabricate(:tag)
|
||||
post "/tag/#{tag3.name}/synonyms.json", params: { synonyms: [tag.name] }
|
||||
expect(response.status).to eq(200)
|
||||
json = JSON.parse(response.body)
|
||||
expect(json['failed']).to be_present
|
||||
expect(json.dig('failed_tags', tag.name)).to be_present
|
||||
expect(response.parsed_body['failed']).to be_present
|
||||
expect(response.parsed_body.dig('failed_tags', tag.name)).to be_present
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -21,7 +21,7 @@ RSpec.describe TopicsController do
|
|||
get "/t/#{topic.id}/wordpress.json", params: { best: 3 }
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
json = ::JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
|
||||
# The JSON has the data the wordpress plugin needs
|
||||
expect(json['id']).to eq(topic.id)
|
||||
|
@ -92,7 +92,7 @@ RSpec.describe TopicsController do
|
|||
}
|
||||
expect(response.status).to eq(422)
|
||||
|
||||
result = ::JSON.parse(response.body)
|
||||
result = response.parsed_body
|
||||
|
||||
expect(result['errors']).to be_present
|
||||
end
|
||||
|
@ -112,7 +112,7 @@ RSpec.describe TopicsController do
|
|||
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
result = ::JSON.parse(response.body)
|
||||
result = response.parsed_body
|
||||
|
||||
expect(result['success']).to eq(true)
|
||||
expect(result['url']).to eq(Topic.last.relative_url)
|
||||
|
@ -135,7 +135,7 @@ RSpec.describe TopicsController do
|
|||
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
result = JSON.parse(response.body)
|
||||
result = response.parsed_body
|
||||
|
||||
expect(result['success']).to eq(true)
|
||||
expect(result['url']).to eq(Topic.last.relative_url)
|
||||
|
@ -150,7 +150,7 @@ RSpec.describe TopicsController do
|
|||
post_ids: [p2.id]
|
||||
}
|
||||
expect(response.status).to eq(200)
|
||||
result = ::JSON.parse(response.body)
|
||||
result = response.parsed_body
|
||||
expect(result['success']).to eq(false)
|
||||
expect(result['url']).to be_blank
|
||||
end
|
||||
|
@ -174,7 +174,7 @@ RSpec.describe TopicsController do
|
|||
p1.reload
|
||||
p2.reload
|
||||
|
||||
new_topic_id = JSON.parse(response.body)["url"].split("/").last.to_i
|
||||
new_topic_id = response.parsed_body["url"].split("/").last.to_i
|
||||
new_topic = Topic.find(new_topic_id)
|
||||
expect(p1.topic.id).to eq(new_topic.id)
|
||||
expect(p2.topic.id).to eq(new_topic.id)
|
||||
|
@ -200,7 +200,7 @@ RSpec.describe TopicsController do
|
|||
}
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
result = ::JSON.parse(response.body)
|
||||
result = response.parsed_body
|
||||
expect(result['success']).to eq(true)
|
||||
expect(result['url']).to be_present
|
||||
end
|
||||
|
@ -238,7 +238,7 @@ RSpec.describe TopicsController do
|
|||
}
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
result = ::JSON.parse(response.body)
|
||||
result = response.parsed_body
|
||||
expect(result['success']).to eq(false)
|
||||
expect(result['url']).to be_blank
|
||||
end
|
||||
|
@ -264,7 +264,7 @@ RSpec.describe TopicsController do
|
|||
}
|
||||
|
||||
expect(response.status).to eq(403)
|
||||
result = ::JSON.parse(response.body)
|
||||
result = response.parsed_body
|
||||
expect(result['errors']).to be_present
|
||||
end
|
||||
|
||||
|
@ -285,7 +285,7 @@ RSpec.describe TopicsController do
|
|||
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
result = ::JSON.parse(response.body)
|
||||
result = response.parsed_body
|
||||
|
||||
expect(result['success']).to eq(true)
|
||||
expect(result['url']).to eq(Topic.last.relative_url)
|
||||
|
@ -308,7 +308,7 @@ RSpec.describe TopicsController do
|
|||
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
result = JSON.parse(response.body)
|
||||
result = response.parsed_body
|
||||
|
||||
expect(result['success']).to eq(true)
|
||||
expect(result['url']).to eq(Topic.last.relative_url)
|
||||
|
@ -324,7 +324,7 @@ RSpec.describe TopicsController do
|
|||
archetype: 'private_message'
|
||||
}
|
||||
expect(response.status).to eq(200)
|
||||
result = ::JSON.parse(response.body)
|
||||
result = response.parsed_body
|
||||
expect(result['success']).to eq(false)
|
||||
expect(result['url']).to be_blank
|
||||
end
|
||||
|
@ -353,7 +353,7 @@ RSpec.describe TopicsController do
|
|||
}
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
result = ::JSON.parse(response.body)
|
||||
result = response.parsed_body
|
||||
expect(result['success']).to eq(true)
|
||||
expect(result['url']).to be_present
|
||||
end
|
||||
|
@ -367,7 +367,7 @@ RSpec.describe TopicsController do
|
|||
}
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
result = ::JSON.parse(response.body)
|
||||
result = response.parsed_body
|
||||
expect(result['success']).to eq(false)
|
||||
expect(result['url']).to be_blank
|
||||
end
|
||||
|
@ -409,7 +409,7 @@ RSpec.describe TopicsController do
|
|||
}
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
result = ::JSON.parse(response.body)
|
||||
result = response.parsed_body
|
||||
expect(result['success']).to eq(true)
|
||||
expect(result['url']).to be_present
|
||||
end
|
||||
|
@ -453,7 +453,7 @@ RSpec.describe TopicsController do
|
|||
}
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
result = ::JSON.parse(response.body)
|
||||
result = response.parsed_body
|
||||
expect(result['success']).to eq(true)
|
||||
expect(result['url']).to be_present
|
||||
end
|
||||
|
@ -697,7 +697,7 @@ RSpec.describe TopicsController do
|
|||
expect(topic.reload.closed).to eq(false)
|
||||
expect(topic.topic_timers).to eq([])
|
||||
|
||||
body = JSON.parse(response.body)
|
||||
body = response.parsed_body
|
||||
|
||||
expect(body['topic_status_update']).to eq(nil)
|
||||
end
|
||||
|
@ -887,7 +887,7 @@ RSpec.describe TopicsController do
|
|||
it "returns JSON for the slug" do
|
||||
get "/t/id_for/#{topic.slug}.json"
|
||||
expect(response.status).to eq(200)
|
||||
json = ::JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json['topic_id']).to eq(topic.id)
|
||||
expect(json['url']).to eq(topic.url)
|
||||
expect(json['slug']).to eq(topic.slug)
|
||||
|
@ -953,7 +953,7 @@ RSpec.describe TopicsController do
|
|||
put "/t/#{topic.slug}/#{topic.id}.json"
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
expect(::JSON.parse(response.body)['basic_topic']).to be_present
|
||||
expect(response.parsed_body['basic_topic']).to be_present
|
||||
end
|
||||
|
||||
it "throws an error if it could not be saved" do
|
||||
|
@ -1164,7 +1164,7 @@ RSpec.describe TopicsController do
|
|||
|
||||
put "/t/#{topic.slug}/#{topic.id}.json", params: { category_id: restricted_category.id }
|
||||
|
||||
result = ::JSON.parse(response.body)
|
||||
result = response.parsed_body
|
||||
|
||||
expect(response.status).to eq(422)
|
||||
expect(result['errors']).to be_present
|
||||
|
@ -1177,7 +1177,7 @@ RSpec.describe TopicsController do
|
|||
|
||||
put "/t/#{topic.slug}/#{topic.id}.json", params: { category_id: restricted_category.id }
|
||||
|
||||
result = ::JSON.parse(response.body)
|
||||
result = response.parsed_body
|
||||
|
||||
expect(response.status).to eq(422)
|
||||
expect(result['errors']).to be_present
|
||||
|
@ -1215,7 +1215,7 @@ RSpec.describe TopicsController do
|
|||
category_id: category.id
|
||||
}
|
||||
|
||||
result = ::JSON.parse(response.body)
|
||||
result = response.parsed_body
|
||||
expect(response.status).to eq(422)
|
||||
expect(result['errors']).to be_present
|
||||
expect(result['errors'][0]).to include(tag2.name)
|
||||
|
@ -1229,7 +1229,7 @@ RSpec.describe TopicsController do
|
|||
category_id: category.id
|
||||
}
|
||||
|
||||
result = ::JSON.parse(response.body)
|
||||
result = response.parsed_body
|
||||
expect(response.status).to eq(200)
|
||||
expect(topic.reload.tags).to include(tag1)
|
||||
end
|
||||
|
@ -1242,7 +1242,7 @@ RSpec.describe TopicsController do
|
|||
category_id: category.id
|
||||
}
|
||||
|
||||
result = ::JSON.parse(response.body)
|
||||
result = response.parsed_body
|
||||
expect(response.status).to eq(200)
|
||||
expect(topic.reload.tags).to contain_exactly(tag3)
|
||||
end
|
||||
|
@ -1255,7 +1255,7 @@ RSpec.describe TopicsController do
|
|||
category_id: category.id
|
||||
}
|
||||
|
||||
result = ::JSON.parse(response.body)
|
||||
result = response.parsed_body
|
||||
expect(response.status).to eq(422)
|
||||
expect(result['errors']).to be_present
|
||||
expect(result['errors'][0]).not_to include(tag3.name)
|
||||
|
@ -1269,7 +1269,7 @@ RSpec.describe TopicsController do
|
|||
category_id: restricted_category.id
|
||||
}
|
||||
|
||||
result = ::JSON.parse(response.body)
|
||||
result = response.parsed_body
|
||||
expect(response.status).to eq(200)
|
||||
end
|
||||
end
|
||||
|
@ -1763,7 +1763,7 @@ RSpec.describe TopicsController do
|
|||
|
||||
context 'filters' do
|
||||
def extract_post_stream
|
||||
json = JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
json["post_stream"]["posts"].map { |post| post["id"] }
|
||||
end
|
||||
|
||||
|
@ -2070,7 +2070,7 @@ RSpec.describe TopicsController do
|
|||
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
body = JSON.parse(response.body)
|
||||
body = response.parsed_body
|
||||
|
||||
expect(body["post_ids"]).to eq([post2.id, post3.id])
|
||||
end
|
||||
|
@ -2089,7 +2089,7 @@ RSpec.describe TopicsController do
|
|||
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
body = JSON.parse(response.body)
|
||||
body = response.parsed_body
|
||||
|
||||
expect(body["post_ids"]).to eq([post2.id])
|
||||
end
|
||||
|
@ -2107,7 +2107,7 @@ RSpec.describe TopicsController do
|
|||
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
body = JSON.parse(response.body)
|
||||
body = response.parsed_body
|
||||
|
||||
expect(body["post_ids"]).to eq([post2.id])
|
||||
end
|
||||
|
@ -2131,14 +2131,14 @@ RSpec.describe TopicsController do
|
|||
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
body = JSON.parse(response.body)
|
||||
body = response.parsed_body
|
||||
|
||||
expect(body["post_stream"]["posts"].first["id"]).to eq(post.id)
|
||||
|
||||
expect(body["suggested_topics"]).to eq(nil)
|
||||
|
||||
get "/t/#{topic.id}/posts.json?include_suggested=true"
|
||||
body = JSON.parse(response.body)
|
||||
body = response.parsed_body
|
||||
|
||||
expect(body["suggested_topics"]).not_to eq(nil)
|
||||
end
|
||||
|
@ -2159,7 +2159,7 @@ RSpec.describe TopicsController do
|
|||
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
body = JSON.parse(response.body)
|
||||
body = response.parsed_body
|
||||
|
||||
expect(body["post_stream"]["posts"].first["id"]).to eq(post2.id)
|
||||
end
|
||||
|
@ -2180,7 +2180,7 @@ RSpec.describe TopicsController do
|
|||
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
body = JSON.parse(response.body)
|
||||
body = response.parsed_body
|
||||
|
||||
expect(body["post_stream"]["posts"].first["id"]).to eq(post2.id)
|
||||
end
|
||||
|
@ -2484,7 +2484,7 @@ RSpec.describe TopicsController do
|
|||
get "/topics/feature_stats.json", params: { category_id: 1 }
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
json = JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json["pinned_in_category_count"]).to eq(0)
|
||||
expect(json["pinned_globally_count"]).to eq(0)
|
||||
expect(json["banner_count"]).to eq(0)
|
||||
|
@ -2494,7 +2494,7 @@ RSpec.describe TopicsController do
|
|||
Fabricate(:topic, category_id: 1, archetype: Archetype.banner, visible: false)
|
||||
|
||||
get "/topics/feature_stats.json", params: { category_id: 1 }
|
||||
json = JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json["banner_count"]).to eq(1)
|
||||
end
|
||||
end
|
||||
|
@ -2510,7 +2510,7 @@ RSpec.describe TopicsController do
|
|||
post_ids: [first_post.id, second_post.id, random_post.id]
|
||||
}
|
||||
|
||||
json = JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
json.sort! { |a, b| a["post_id"] <=> b["post_id"] }
|
||||
|
||||
# no random post
|
||||
|
@ -2550,7 +2550,7 @@ RSpec.describe TopicsController do
|
|||
expect(topic.archetype).to eq(Archetype.private_message)
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
result = ::JSON.parse(response.body)
|
||||
result = response.parsed_body
|
||||
expect(result['success']).to eq(true)
|
||||
expect(result['url']).to be_present
|
||||
end
|
||||
|
@ -2579,7 +2579,7 @@ RSpec.describe TopicsController do
|
|||
expect(topic.category_id).to eq(category.id)
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
result = ::JSON.parse(response.body)
|
||||
result = response.parsed_body
|
||||
expect(result['success']).to eq(true)
|
||||
expect(result['url']).to be_present
|
||||
end
|
||||
|
@ -2630,7 +2630,7 @@ RSpec.describe TopicsController do
|
|||
}
|
||||
|
||||
expect(response.status).to eq(403)
|
||||
expect(JSON.parse(response.body)["error_type"]).to eq('invalid_access')
|
||||
expect(response.parsed_body["error_type"]).to eq('invalid_access')
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -2653,7 +2653,7 @@ RSpec.describe TopicsController do
|
|||
expect(topic_status_update.topic).to eq(topic)
|
||||
expect(topic_status_update.execute_at).to eq_time(24.hours.from_now)
|
||||
|
||||
json = JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
|
||||
expect(DateTime.parse(json['execute_at']))
|
||||
.to eq_time(DateTime.parse(topic_status_update.execute_at.to_s))
|
||||
|
@ -2673,7 +2673,7 @@ RSpec.describe TopicsController do
|
|||
expect(response.status).to eq(200)
|
||||
expect(topic.reload.public_topic_timer).to eq(nil)
|
||||
|
||||
json = JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
|
||||
expect(json['execute_at']).to eq(nil)
|
||||
expect(json['duration']).to eq(nil)
|
||||
|
@ -2694,7 +2694,7 @@ RSpec.describe TopicsController do
|
|||
expect(topic_status_update.execute_at).to eq_time(5.days.from_now)
|
||||
expect(topic_status_update.duration).to eq(5)
|
||||
|
||||
json = JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
|
||||
expect(DateTime.parse(json['execute_at']))
|
||||
.to eq_time(DateTime.parse(topic_status_update.execute_at.to_s))
|
||||
|
@ -2719,7 +2719,7 @@ RSpec.describe TopicsController do
|
|||
expect(topic_status_update.status_type)
|
||||
.to eq(TopicTimer.types[:publish_to_category])
|
||||
|
||||
json = JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
|
||||
expect(json['category_id']).to eq(topic.category_id)
|
||||
end
|
||||
|
@ -2812,7 +2812,7 @@ RSpec.describe TopicsController do
|
|||
|
||||
expect(response.status).to eq(422)
|
||||
|
||||
response_body = JSON.parse(response.body)
|
||||
response_body = response.parsed_body
|
||||
|
||||
expect(response_body["errors"]).to eq([
|
||||
I18n.t("topic_invite.failed_to_invite",
|
||||
|
@ -2853,7 +2853,7 @@ RSpec.describe TopicsController do
|
|||
user: user2.username
|
||||
}
|
||||
expect(response.status).to eq(422)
|
||||
expect(JSON.parse(response.body)["errors"]).to contain_exactly(
|
||||
expect(response.parsed_body["errors"]).to contain_exactly(
|
||||
I18n.t("pm_reached_recipients_limit", recipients_limit: SiteSetting.max_allowed_message_recipients)
|
||||
)
|
||||
end
|
||||
|
@ -2975,7 +2975,7 @@ RSpec.describe TopicsController do
|
|||
group: group.name
|
||||
}
|
||||
expect(response.status).to eq(422)
|
||||
expect(JSON.parse(response.body)["errors"]).to contain_exactly(
|
||||
expect(response.parsed_body["errors"]).to contain_exactly(
|
||||
I18n.t("pm_reached_recipients_limit", recipients_limit: SiteSetting.max_allowed_message_recipients)
|
||||
)
|
||||
end
|
||||
|
@ -3060,7 +3060,7 @@ RSpec.describe TopicsController do
|
|||
it "will publish the topic" do
|
||||
put "/t/#{topic.id}/publish.json", params: { destination_category_id: category.id }
|
||||
expect(response.status).to eq(200)
|
||||
json = ::JSON.parse(response.body)['basic_topic']
|
||||
json = response.parsed_body['basic_topic']
|
||||
|
||||
result = Topic.find(json['id'])
|
||||
expect(result.category_id).to eq(category.id)
|
||||
|
|
|
@ -36,7 +36,7 @@ describe UploadsController do
|
|||
it 'is successful with an image' do
|
||||
post "/uploads.json", params: { file: logo, type: "avatar" }
|
||||
expect(response.status).to eq 200
|
||||
expect(JSON.parse(response.body)["id"]).to be_present
|
||||
expect(response.parsed_body["id"]).to be_present
|
||||
expect(Jobs::CreateAvatarThumbnails.jobs.size).to eq(1)
|
||||
end
|
||||
|
||||
|
@ -47,7 +47,7 @@ describe UploadsController do
|
|||
expect(response.status).to eq 200
|
||||
|
||||
expect(Jobs::CreateAvatarThumbnails.jobs.size).to eq(0)
|
||||
id = JSON.parse(response.body)["id"]
|
||||
id = response.parsed_body["id"]
|
||||
expect(id).to be
|
||||
end
|
||||
|
||||
|
@ -65,7 +65,7 @@ describe UploadsController do
|
|||
HTTP_API_USERNAME: user.username.downcase
|
||||
}
|
||||
|
||||
json = ::JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
expect(Jobs::CreateAvatarThumbnails.jobs.size).to eq(1)
|
||||
|
@ -82,7 +82,7 @@ describe UploadsController do
|
|||
type: "profile_background",
|
||||
}
|
||||
|
||||
id = JSON.parse(response.body)["id"]
|
||||
id = response.parsed_body["id"]
|
||||
expect(Jobs::CreateAvatarThumbnails.jobs.size).to eq(0)
|
||||
expect(Upload.find(id).retain_hours).to eq(100)
|
||||
end
|
||||
|
@ -91,7 +91,7 @@ describe UploadsController do
|
|||
post "/uploads.json", params: { type: "composer" }
|
||||
|
||||
expect(Jobs::CreateAvatarThumbnails.jobs.size).to eq(0)
|
||||
message = JSON.parse(response.body)
|
||||
message = response.parsed_body
|
||||
expect(response.status).to eq 422
|
||||
expect(message["errors"]).to contain_exactly(I18n.t("upload.file_missing"))
|
||||
end
|
||||
|
@ -104,7 +104,7 @@ describe UploadsController do
|
|||
|
||||
expect(response.status).to eq(422)
|
||||
expect(Jobs::CreateAvatarThumbnails.jobs.size).to eq(0)
|
||||
errors = JSON.parse(response.body)["errors"]
|
||||
errors = response.parsed_body["errors"]
|
||||
expect(errors.first).to eq(I18n.t("upload.attachments.too_large", max_size_kb: 1))
|
||||
end
|
||||
|
||||
|
@ -140,7 +140,7 @@ describe UploadsController do
|
|||
}
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
id = JSON.parse(response.body)["id"]
|
||||
id = response.parsed_body["id"]
|
||||
expect(Upload.last.id).to eq(id)
|
||||
end
|
||||
|
||||
|
@ -155,7 +155,7 @@ describe UploadsController do
|
|||
}
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
id = JSON.parse(response.body)["id"]
|
||||
id = response.parsed_body["id"]
|
||||
|
||||
upload = Upload.last
|
||||
|
||||
|
@ -174,7 +174,7 @@ describe UploadsController do
|
|||
}
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
data = JSON.parse(response.body)
|
||||
data = response.parsed_body
|
||||
expect(data["id"]).to be_present
|
||||
end
|
||||
|
||||
|
@ -187,7 +187,7 @@ describe UploadsController do
|
|||
type: "composer",
|
||||
}
|
||||
|
||||
data = JSON.parse(response.body)
|
||||
data = response.parsed_body
|
||||
expect(data["errors"].first).to eq(I18n.t("upload.unauthorized", authorized_extensions: ''))
|
||||
end
|
||||
|
||||
|
@ -196,7 +196,7 @@ describe UploadsController do
|
|||
|
||||
expect(response.status).to eq(422)
|
||||
expect(Jobs::CreateAvatarThumbnails.jobs.size).to eq(0)
|
||||
message = JSON.parse(response.body)["errors"]
|
||||
message = response.parsed_body["errors"]
|
||||
expect(message).to contain_exactly(I18n.t("upload.images.size_not_found"))
|
||||
end
|
||||
end
|
||||
|
@ -214,7 +214,7 @@ describe UploadsController do
|
|||
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
url = JSON.parse(response.body)["url"]
|
||||
url = response.parsed_body["url"]
|
||||
upload = Upload.get_from_url(url)
|
||||
upload
|
||||
end
|
||||
|
@ -465,7 +465,7 @@ describe UploadsController do
|
|||
post "/uploads/lookup-urls.json", params: { short_urls: [upload.short_url] }
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
result = JSON.parse(response.body)
|
||||
result = response.parsed_body
|
||||
expect(result[0]["url"]).to match("secure-media-uploads")
|
||||
end
|
||||
|
||||
|
@ -600,7 +600,7 @@ describe UploadsController do
|
|||
post "/uploads/lookup-urls.json", params: { short_urls: [upload.short_url] }
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
result = JSON.parse(response.body)
|
||||
result = response.parsed_body
|
||||
expect(result[0]["url"]).to eq(upload.url)
|
||||
expect(result[0]["short_path"]).to eq(upload.short_path)
|
||||
end
|
||||
|
@ -623,7 +623,7 @@ describe UploadsController do
|
|||
post "/uploads/lookup-urls.json", params: { short_urls: [upload.short_url] }
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
result = JSON.parse(response.body)
|
||||
result = response.parsed_body
|
||||
expect(result[0]["url"]).to match("/secure-media-uploads")
|
||||
expect(result[0]["short_path"]).to eq(upload.short_path)
|
||||
end
|
||||
|
@ -635,7 +635,7 @@ describe UploadsController do
|
|||
post "/uploads/lookup-urls.json", params: { short_urls: [upload.short_url] }
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
result = JSON.parse(response.body)
|
||||
result = response.parsed_body
|
||||
expect(result[0]["url"]).to match("/secure-media-uploads")
|
||||
expect(result[0]["short_path"]).to eq(upload.short_path)
|
||||
end
|
||||
|
@ -679,7 +679,7 @@ describe UploadsController do
|
|||
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
result = JSON.parse(response.body)
|
||||
result = response.parsed_body
|
||||
|
||||
expect(result["original_filename"]).to eq(upload.original_filename)
|
||||
expect(result["width"]).to eq(upload.width)
|
||||
|
|
|
@ -26,7 +26,7 @@ describe UserActionsController do
|
|||
get "/user_actions.json", params: { username: post.user.username }
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
parsed = JSON.parse(response.body)
|
||||
parsed = response.parsed_body
|
||||
actions = parsed["user_actions"]
|
||||
expect(actions.length).to eq(1)
|
||||
action = actions[0]
|
||||
|
@ -50,7 +50,7 @@ describe UserActionsController do
|
|||
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
response_body = JSON.parse(response.body)
|
||||
response_body = response.parsed_body
|
||||
|
||||
expect(response_body["user_actions"].count).to eq(1)
|
||||
|
||||
|
@ -68,7 +68,7 @@ describe UserActionsController do
|
|||
}
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
parsed = JSON.parse(response.body)
|
||||
parsed = response.parsed_body
|
||||
|
||||
expect(parsed["no_results_help"]).to eq(I18n.t("user_activity.no_bookmarks.self"))
|
||||
end
|
||||
|
@ -83,7 +83,7 @@ describe UserActionsController do
|
|||
}
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
parsed = JSON.parse(response.body)
|
||||
parsed = response.parsed_body
|
||||
|
||||
expect(parsed["no_results_help"]).to eq(I18n.t("user_activity.no_bookmarks.others"))
|
||||
end
|
||||
|
|
|
@ -255,7 +255,7 @@ describe UserApiKeysController do
|
|||
SiteSetting.min_trust_level_for_user_api_key = 0
|
||||
post "/user-api-key.json", params: args
|
||||
expect(response.status).not_to eq(302)
|
||||
payload = JSON.parse(response.body)["payload"]
|
||||
payload = response.parsed_body["payload"]
|
||||
encrypted = Base64.decode64(payload)
|
||||
key = OpenSSL::PKey::RSA.new(private_key)
|
||||
parsed = JSON.parse(key.private_decrypt(encrypted))
|
||||
|
|
|
@ -15,7 +15,7 @@ describe UserBadgesController do
|
|||
get "/user_badges.json", params: { badge_id: badge.id }
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
parsed = JSON.parse(response.body)
|
||||
parsed = response.parsed_body
|
||||
expect(parsed["topics"]).to eq(nil)
|
||||
expect(parsed["badges"].length).to eq(1)
|
||||
expect(parsed["user_badge_info"]["user_badges"][0]["post_id"]).to eq(nil)
|
||||
|
@ -40,7 +40,7 @@ describe UserBadgesController do
|
|||
get "/user-badges/#{user.username}.json"
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
parsed = JSON.parse(response.body)
|
||||
parsed = response.parsed_body
|
||||
expect(parsed["user_badges"].length).to eq(1)
|
||||
end
|
||||
|
||||
|
@ -49,7 +49,7 @@ describe UserBadgesController do
|
|||
get "/user-badges/#{user.username}", xhr: true
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
parsed = JSON.parse(response.body)
|
||||
parsed = response.parsed_body
|
||||
expect(parsed["user_badges"].length).to eq(1)
|
||||
end
|
||||
|
||||
|
@ -57,7 +57,7 @@ describe UserBadgesController do
|
|||
get "/user_badges.json", params: { badge_id: badge.id }
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
parsed = JSON.parse(response.body)
|
||||
parsed = response.parsed_body
|
||||
expect(parsed["user_badge_info"]["user_badges"].length).to eq(1)
|
||||
end
|
||||
|
||||
|
@ -67,7 +67,7 @@ describe UserBadgesController do
|
|||
}
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
parsed = JSON.parse(response.body)
|
||||
parsed = response.parsed_body
|
||||
expect(parsed["user_badges"].first.has_key?('count')).to eq(true)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -12,7 +12,7 @@ describe UsersController do
|
|||
get '/u/hp.json'
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
json = JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
|
||||
params = {
|
||||
email: 'jane@jane.com',
|
||||
|
@ -179,7 +179,7 @@ describe UsersController do
|
|||
get "/u/password-reset/#{token}.json"
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
expect(JSON.parse(response.body)["message"]).to eq(I18n.t('password_reset.no_token'))
|
||||
expect(response.parsed_body["message"]).to eq(I18n.t('password_reset.no_token'))
|
||||
expect(session[:current_user_id]).to be_blank
|
||||
end
|
||||
end
|
||||
|
@ -204,7 +204,7 @@ describe UsersController do
|
|||
put "/u/password-reset/evil_trout!.json", params: { password: "awesomeSecretPassword" }
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
expect(JSON.parse(response.body)["message"]).to eq(I18n.t('password_reset.no_token'))
|
||||
expect(response.parsed_body["message"]).to eq(I18n.t('password_reset.no_token'))
|
||||
expect(session[:current_user_id]).to be_blank
|
||||
end
|
||||
end
|
||||
|
@ -488,7 +488,7 @@ describe UsersController do
|
|||
put "/u/password-reset/#{token}.json", params: { password: '' }
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
expect(JSON.parse(response.body)["errors"]).to be_present
|
||||
expect(response.parsed_body["errors"]).to be_present
|
||||
expect(session[:current_user_id]).to be_blank
|
||||
end
|
||||
|
||||
|
@ -496,7 +496,7 @@ describe UsersController do
|
|||
put "/u/password-reset/#{token}.json", params: { password: ('x' * (User.max_password_length + 1)) }
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
expect(JSON.parse(response.body)["errors"]).to be_present
|
||||
expect(response.parsed_body["errors"]).to be_present
|
||||
expect(session[:current_user_id]).to be_blank
|
||||
end
|
||||
|
||||
|
@ -504,7 +504,7 @@ describe UsersController do
|
|||
put "/u/password-reset/#{token}.json", params: { password: 'ksjafh928r' }
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
expect(JSON.parse(response.body)["errors"]).to be_blank
|
||||
expect(response.parsed_body["errors"]).to be_blank
|
||||
expect(session[:current_user_id]).to be_present
|
||||
end
|
||||
|
||||
|
@ -512,7 +512,7 @@ describe UsersController do
|
|||
SiteSetting.must_approve_users = true
|
||||
|
||||
put "/u/password-reset/#{token}.json", params: { password: 'ksjafh928r' }
|
||||
expect(JSON.parse(response.body)["errors"]).to be_blank
|
||||
expect(response.parsed_body["errors"]).to be_blank
|
||||
expect(session[:current_user_id]).to be_blank
|
||||
end
|
||||
end
|
||||
|
@ -585,7 +585,7 @@ describe UsersController do
|
|||
describe '#create' do
|
||||
def honeypot_magic(params)
|
||||
get '/u/hp.json'
|
||||
json = JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
params[:password_confirmation] = json["value"]
|
||||
params[:challenge] = json["challenge"].reverse
|
||||
params
|
||||
|
@ -635,13 +635,13 @@ describe UsersController do
|
|||
|
||||
post_user(invite_code: "abcd")
|
||||
expect(response.status).to eq(200)
|
||||
json = JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json["success"]).to eq(false)
|
||||
|
||||
# case insensitive and stripped of leading/ending spaces
|
||||
post_user(invite_code: " AbC deF ")
|
||||
expect(response.status).to eq(200)
|
||||
json = JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json["success"]).to eq(true)
|
||||
|
||||
end
|
||||
|
@ -694,7 +694,7 @@ describe UsersController do
|
|||
post_user
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
json = JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json['success']).to eq(false)
|
||||
expect(json['message']).to be_present
|
||||
end
|
||||
|
@ -702,7 +702,7 @@ describe UsersController do
|
|||
it 'creates a user correctly' do
|
||||
post_user
|
||||
expect(response.status).to eq(200)
|
||||
expect(JSON.parse(response.body)['active']).to be_falsey
|
||||
expect(response.parsed_body['active']).to be_falsey
|
||||
|
||||
# should save user_created_message in session
|
||||
expect(session["user_created_message"]).to be_present
|
||||
|
@ -722,7 +722,7 @@ describe UsersController do
|
|||
post_user
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
expect(JSON.parse(response.body)['active']).to be_falsey
|
||||
expect(response.parsed_body['active']).to be_falsey
|
||||
|
||||
# should save user_created_message in session
|
||||
expect(session["user_created_message"]).to be_present
|
||||
|
@ -745,7 +745,7 @@ describe UsersController do
|
|||
post_user
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
json = JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json['success']).to eq(false)
|
||||
expect(json['message']).to be_present
|
||||
end
|
||||
|
@ -759,7 +759,7 @@ describe UsersController do
|
|||
expect(response.status).to eq(200)
|
||||
expect(session["user_created_message"]).to be_present
|
||||
|
||||
json = JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json['active']).to be_falsey
|
||||
expect(json['message']).to eq(I18n.t("login.activate_email", email: post_user_params[:email]))
|
||||
end
|
||||
|
@ -770,7 +770,7 @@ describe UsersController do
|
|||
it "won't create the user as active" do
|
||||
post "/u.json", params: post_user_params.merge(active: true)
|
||||
expect(response.status).to eq(200)
|
||||
expect(JSON.parse(response.body)['active']).to be_falsey
|
||||
expect(response.parsed_body['active']).to be_falsey
|
||||
end
|
||||
|
||||
context "with a regular api key" do
|
||||
|
@ -782,7 +782,7 @@ describe UsersController do
|
|||
params: post_user_params.merge(active: true), headers: { HTTP_API_KEY: api_key.key }
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
expect(JSON.parse(response.body)['active']).to be_falsey
|
||||
expect(response.parsed_body['active']).to be_falsey
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -801,7 +801,7 @@ describe UsersController do
|
|||
expect(Jobs::SendSystemMessage.jobs.size).to eq(0)
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
json = JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
|
||||
new_user = User.find(json["user_id"])
|
||||
email_token = new_user.email_tokens.active.where(email: new_user.email).first
|
||||
|
@ -822,7 +822,7 @@ describe UsersController do
|
|||
post "/u.json", params: post_user_params.merge(active: true), headers: { HTTP_API_KEY: api_key.key }
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
json = JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
|
||||
new_user = User.find(json["user_id"])
|
||||
expect(json['active']).to be_truthy
|
||||
|
@ -837,7 +837,7 @@ describe UsersController do
|
|||
post "/u.json", params: post_user_params, headers: { HTTP_API_KEY: api_key.key }
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
json = JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
|
||||
new_user = User.find(json["user_id"])
|
||||
expect(json['active']).to eq(false)
|
||||
|
@ -850,7 +850,7 @@ describe UsersController do
|
|||
|
||||
post "/u.json", params: post_user_params.merge(active: true), headers: { HTTP_API_KEY: api_key.key }
|
||||
expect(response.status).to eq(200)
|
||||
expect(JSON.parse(response.body)['active']).to be_falsy
|
||||
expect(response.parsed_body['active']).to be_falsy
|
||||
end
|
||||
|
||||
it "won't set the new user's locale to the admin's locale" do
|
||||
|
@ -860,7 +860,7 @@ describe UsersController do
|
|||
post "/u.json", params: post_user_params.merge(active: true), headers: { HTTP_API_KEY: api_key.key }
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
json = JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
new_user = User.find(json["user_id"])
|
||||
expect(new_user.locale).not_to eq("fr")
|
||||
end
|
||||
|
@ -873,7 +873,7 @@ describe UsersController do
|
|||
post "/u.json", params: post_user_params.merge(active: true), headers: { HTTP_API_KEY: api_key.key }
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
json = JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
|
||||
new_user = User.find(json["user_id"])
|
||||
expect(json['active']).to be_truthy
|
||||
|
@ -945,7 +945,7 @@ describe UsersController do
|
|||
User.any_instance.expects(:enqueue_welcome_message)
|
||||
post_user
|
||||
expect(response.status).to eq(200)
|
||||
expect(JSON.parse(response.body)['message']).to eq(
|
||||
expect(response.parsed_body['message']).to eq(
|
||||
I18n.t 'login.active'
|
||||
)
|
||||
end
|
||||
|
@ -961,7 +961,7 @@ describe UsersController do
|
|||
User.any_instance.expects(:enqueue_welcome_message)
|
||||
post_user
|
||||
expect(response.status).to eq(200)
|
||||
expect(JSON.parse(response.body)['active']).to be_truthy
|
||||
expect(response.parsed_body['active']).to be_truthy
|
||||
end
|
||||
|
||||
it 'doesn\'t succeed when new registrations are disabled' do
|
||||
|
@ -970,7 +970,7 @@ describe UsersController do
|
|||
post_user
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
json = JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json['success']).to eq(false)
|
||||
expect(json['message']).to be_present
|
||||
end
|
||||
|
@ -1019,7 +1019,7 @@ describe UsersController do
|
|||
}
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
json = JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json['success']).to eq(false)
|
||||
expect(json['message']).to be_present
|
||||
end
|
||||
|
@ -1033,7 +1033,7 @@ describe UsersController do
|
|||
}
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
json = JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json['success']).to eq(true)
|
||||
end
|
||||
end
|
||||
|
@ -1042,7 +1042,7 @@ describe UsersController do
|
|||
it "creates user successfully but doesn't activate the account" do
|
||||
post_user
|
||||
expect(response.status).to eq(200)
|
||||
json = JSON::parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json["success"]).to eq(true)
|
||||
expect(User.find_by(username: @user.username).active).to eq(false)
|
||||
end
|
||||
|
@ -1057,7 +1057,7 @@ describe UsersController do
|
|||
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
json = JSON::parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json["success"]).to eq(true)
|
||||
|
||||
# should not change the session
|
||||
|
@ -1103,7 +1103,7 @@ describe UsersController do
|
|||
|
||||
it 'should report failed' do
|
||||
post "/u.json", params: create_params
|
||||
json = JSON::parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json["success"]).not_to eq(true)
|
||||
|
||||
# should not change the session
|
||||
|
@ -1253,7 +1253,7 @@ describe UsersController do
|
|||
)
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
result = ::JSON.parse(response.body)
|
||||
result = response.parsed_body
|
||||
expect(result["success"]).to eq(true)
|
||||
|
||||
created_user = User.find_by_email(staged.email)
|
||||
|
@ -1309,7 +1309,7 @@ describe UsersController do
|
|||
|
||||
expect(response.status).to eq(422)
|
||||
|
||||
body = JSON.parse(response.body)
|
||||
body = response.parsed_body
|
||||
|
||||
expect(body['errors'].first).to include(I18n.t(
|
||||
'user.username.short', min: User.username_length.begin
|
||||
|
@ -1328,7 +1328,7 @@ describe UsersController do
|
|||
it 'raises an error when the username clashes with an existing user route' do
|
||||
put "/u/#{user.username}/preferences/username.json", params: { new_username: 'account-created' }
|
||||
|
||||
body = JSON.parse(response.body)
|
||||
body = response.parsed_body
|
||||
|
||||
expect(body['errors'].first).to include(I18n.t('login.reserved_username'))
|
||||
end
|
||||
|
@ -1337,7 +1337,7 @@ describe UsersController do
|
|||
SiteSetting.reserved_usernames = 'reserved'
|
||||
|
||||
put "/u/#{user.username}/preferences/username.json", params: { new_username: 'reserved' }
|
||||
body = JSON.parse(response.body)
|
||||
body = response.parsed_body
|
||||
|
||||
expect(body['errors'].first).to include(I18n.t('login.reserved_username'))
|
||||
end
|
||||
|
@ -1370,7 +1370,7 @@ describe UsersController do
|
|||
it 'should return a JSON response with the updated username' do
|
||||
put "/u/#{user.username}/preferences/username.json", params: { new_username: new_username }
|
||||
|
||||
expect(::JSON.parse(response.body)['username']).to eq(new_username)
|
||||
expect(response.parsed_body['username']).to eq(new_username)
|
||||
end
|
||||
|
||||
it 'should respond with proper error message if sso_overrides_username is enabled' do
|
||||
|
@ -1383,7 +1383,7 @@ describe UsersController do
|
|||
put "/u/#{user.username}/preferences/username.json", params: { new_username: new_username }
|
||||
|
||||
expect(response.status).to eq(422)
|
||||
expect(::JSON.parse(response.body)['errors'].first).to include(I18n.t('errors.messages.sso_overrides_username'))
|
||||
expect(response.parsed_body['errors'].first).to include(I18n.t('errors.messages.sso_overrides_username'))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -1397,15 +1397,15 @@ describe UsersController do
|
|||
shared_examples 'when username is unavailable' do
|
||||
it 'should return available as false in the JSON and return a suggested username' do
|
||||
expect(response.status).to eq(200)
|
||||
expect(::JSON.parse(response.body)['available']).to eq(false)
|
||||
expect(::JSON.parse(response.body)['suggestion']).to be_present
|
||||
expect(response.parsed_body['available']).to eq(false)
|
||||
expect(response.parsed_body['suggestion']).to be_present
|
||||
end
|
||||
end
|
||||
|
||||
shared_examples 'when username is available' do
|
||||
it 'should return available in the JSON' do
|
||||
expect(response.status).to eq(200)
|
||||
expect(::JSON.parse(response.body)['available']).to eq(true)
|
||||
expect(response.parsed_body['available']).to eq(true)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -1432,8 +1432,8 @@ describe UsersController do
|
|||
shared_examples 'checking an invalid username' do
|
||||
it 'should not return an available key but should return an error message' do
|
||||
expect(response.status).to eq(200)
|
||||
expect(::JSON.parse(response.body)['available']).to eq(nil)
|
||||
expect(::JSON.parse(response.body)['errors']).to be_present
|
||||
expect(response.parsed_body['available']).to eq(nil)
|
||||
expect(response.parsed_body['errors']).to be_present
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -1445,7 +1445,7 @@ describe UsersController do
|
|||
|
||||
it 'should return the invalid characters message' do
|
||||
expect(response.status).to eq(200)
|
||||
expect(::JSON.parse(response.body)['errors']).to include(I18n.t(:'user.username.characters'))
|
||||
expect(response.parsed_body['errors']).to include(I18n.t(:'user.username.characters'))
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -1457,7 +1457,7 @@ describe UsersController do
|
|||
|
||||
it 'should return the "too long" message' do
|
||||
expect(response.status).to eq(200)
|
||||
expect(::JSON.parse(response.body)['errors']).to include(I18n.t(:'user.username.long', max: User.username_length.end))
|
||||
expect(response.parsed_body['errors']).to include(I18n.t(:'user.username.long', max: User.username_length.end))
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -1509,7 +1509,7 @@ describe UsersController do
|
|||
get "/u/#{user.username}/invited_count.json"
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
json = JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json).to be_present
|
||||
expect(json['counts']).to be_present
|
||||
end
|
||||
|
@ -1542,14 +1542,14 @@ describe UsersController do
|
|||
get "/u/#{inviter.username}/invited.json", params: { search: 'billybob' }
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
invites = JSON.parse(response.body)['invites']
|
||||
invites = response.parsed_body['invites']
|
||||
expect(invites.size).to eq(1)
|
||||
expect(invites.first).to include('email' => 'billybob@example.com')
|
||||
|
||||
get "/u/#{inviter.username}/invited.json", params: { search: invitee.username }
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
invites = JSON.parse(response.body)['invites']
|
||||
invites = response.parsed_body['invites']
|
||||
expect(invites.size).to eq(2)
|
||||
expect(invites[0]['email']).to be_present
|
||||
end
|
||||
|
@ -1565,13 +1565,13 @@ describe UsersController do
|
|||
get "/u/#{inviter.username}/invited.json", params: { search: 'billybob' }
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
invites = JSON.parse(response.body)['invites']
|
||||
invites = response.parsed_body['invites']
|
||||
expect(invites.size).to eq(0)
|
||||
|
||||
get "/u/#{inviter.username}/invited.json", params: { search: invitee.username }
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
invites = JSON.parse(response.body)['invites']
|
||||
invites = response.parsed_body['invites']
|
||||
expect(invites.size).to eq(2)
|
||||
expect(invites[0]['email']).to be_blank
|
||||
end
|
||||
|
@ -1587,7 +1587,7 @@ describe UsersController do
|
|||
get "/u/#{inviter.username}/invited.json", params: { search: 'billybob' }
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
invites = JSON.parse(response.body)['invites']
|
||||
invites = response.parsed_body['invites']
|
||||
expect(invites.size).to eq(1)
|
||||
expect(invites[0]['email']).to be_present
|
||||
end
|
||||
|
@ -1613,7 +1613,7 @@ describe UsersController do
|
|||
get "/u/#{inviter.username}/invited.json"
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
invites = JSON.parse(response.body)['invites']
|
||||
invites = response.parsed_body['invites']
|
||||
expect(invites.size).to eq(1)
|
||||
expect(invites.first).to include('email' => invite.email)
|
||||
end
|
||||
|
@ -1631,7 +1631,7 @@ describe UsersController do
|
|||
get "/u/#{inviter.username}/invited/pending.json"
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
invites = JSON.parse(response.body)['invites']
|
||||
invites = response.parsed_body['invites']
|
||||
expect(invites.size).to eq(1)
|
||||
expect(invites.first).to include("email" => invite.email)
|
||||
end
|
||||
|
@ -1664,7 +1664,7 @@ describe UsersController do
|
|||
get "/u/#{inviter.username}/invited.json"
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
invites = JSON.parse(response.body)['invites']
|
||||
invites = response.parsed_body['invites']
|
||||
expect(invites.size).to eq(1)
|
||||
expect(invites.first).to include('email' => invite.email)
|
||||
end
|
||||
|
@ -1931,7 +1931,7 @@ describe UsersController do
|
|||
it 'returns user JSON' do
|
||||
put "/u/#{user.username}.json"
|
||||
|
||||
json = JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json['user']['id']).to eq user.id
|
||||
end
|
||||
end
|
||||
|
@ -2035,7 +2035,7 @@ describe UsersController do
|
|||
post "/u/action/send_activation_email.json", params: { username: user.username }
|
||||
|
||||
expect(response.status).to eq(409)
|
||||
expect(JSON.parse(response.body)['errors']).to include(I18n.t(
|
||||
expect(response.parsed_body['errors']).to include(I18n.t(
|
||||
'activation.activated'
|
||||
))
|
||||
expect(session[SessionController::ACTIVATE_USER_KEY]).to eq(nil)
|
||||
|
@ -2477,7 +2477,7 @@ describe UsersController do
|
|||
get "/u/#{user.username}/emails.json"
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
json = JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json["email"]).to eq(user.email)
|
||||
expect(json["secondary_emails"]).to eq(user.secondary_emails)
|
||||
expect(json["associated_accounts"]).to eq([])
|
||||
|
@ -2490,7 +2490,7 @@ describe UsersController do
|
|||
get "/u/#{user.username}/emails.json"
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
json = JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json["email"]).to eq(user.email)
|
||||
expect(json["secondary_emails"]).to eq(user.secondary_emails)
|
||||
expect(json["associated_accounts"]).to eq([])
|
||||
|
@ -2503,7 +2503,7 @@ describe UsersController do
|
|||
get "/u/#{inactive_user.username}/emails.json"
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
json = JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json["email"]).to eq(inactive_user.email)
|
||||
expect(json["secondary_emails"]).to eq(inactive_user.secondary_emails)
|
||||
expect(json["associated_accounts"]).to eq([])
|
||||
|
@ -2525,7 +2525,7 @@ describe UsersController do
|
|||
get "/u/is_local_username.json", params: { username: user.username }
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
json = JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json["valid"][0]).to eq(user.username)
|
||||
end
|
||||
|
||||
|
@ -2533,7 +2533,7 @@ describe UsersController do
|
|||
sign_in(user)
|
||||
get "/u/is_local_username.json", params: { username: group.name }
|
||||
expect(response.status).to eq(200)
|
||||
json = JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json["valid_groups"]).to include(group.name)
|
||||
expect(json["mentionable_groups"].find { |g| g['name'] == group.name }).to be_present
|
||||
end
|
||||
|
@ -2542,7 +2542,7 @@ describe UsersController do
|
|||
sign_in(user)
|
||||
get "/u/is_local_username.json", params: { username: unmentionable.name }
|
||||
expect(response.status).to eq(200)
|
||||
json = JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json["valid_groups"]).to include(unmentionable.name)
|
||||
expect(json["mentionable_groups"]).to be_blank
|
||||
end
|
||||
|
@ -2551,7 +2551,7 @@ describe UsersController do
|
|||
get "/u/is_local_username.json", params: { usernames: [user.username, "system"] }
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
json = JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json["valid"].size).to eq(2)
|
||||
end
|
||||
|
||||
|
@ -2561,7 +2561,7 @@ describe UsersController do
|
|||
get "/u/is_local_username.json", params: { usernames: [staged.username] }
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
json = JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json["valid"].size).to eq(0)
|
||||
end
|
||||
|
||||
|
@ -2573,7 +2573,7 @@ describe UsersController do
|
|||
}
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
json = JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json["cannot_see"].size).to eq(1)
|
||||
end
|
||||
|
||||
|
@ -2585,7 +2585,7 @@ describe UsersController do
|
|||
}
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
json = JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json["cannot_see"].size).to eq(0)
|
||||
end
|
||||
|
||||
|
@ -2597,7 +2597,7 @@ describe UsersController do
|
|||
}
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
json = JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json["cannot_see"].size).to eq(1)
|
||||
end
|
||||
|
||||
|
@ -2609,7 +2609,7 @@ describe UsersController do
|
|||
}
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
json = JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json["cannot_see"].size).to eq(0)
|
||||
end
|
||||
end
|
||||
|
@ -2632,7 +2632,7 @@ describe UsersController do
|
|||
get "/u/#{user.username}/topic-tracking-state.json"
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
states = JSON.parse(response.body)
|
||||
states = response.parsed_body
|
||||
expect(states[0]["topic_id"]).to eq(topic.id)
|
||||
end
|
||||
end
|
||||
|
@ -2645,7 +2645,7 @@ describe UsersController do
|
|||
|
||||
get "/u/#{user.username_lower}/summary.json"
|
||||
expect(response.status).to eq(200)
|
||||
json = JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
|
||||
expect(json["user_summary"]["topic_count"]).to eq(1)
|
||||
expect(json["user_summary"]["post_count"]).to eq(0)
|
||||
|
@ -2903,7 +2903,7 @@ describe UsersController do
|
|||
it "returns success" do
|
||||
get "/u/#{user.username}.json"
|
||||
expect(response.status).to eq(200)
|
||||
parsed = JSON.parse(response.body)["user"]
|
||||
parsed = response.parsed_body["user"]
|
||||
|
||||
expect(parsed['username']).to eq(user.username)
|
||||
expect(parsed["profile_hidden"]).to be_blank
|
||||
|
@ -2915,7 +2915,7 @@ describe UsersController do
|
|||
|
||||
get "/u/#{user.username}.json"
|
||||
expect(response.status).to eq(200)
|
||||
parsed = JSON.parse(response.body)["user"]
|
||||
parsed = response.parsed_body["user"]
|
||||
|
||||
expect(parsed["username"]).to eq(user.username)
|
||||
expect(parsed["profile_hidden"]).to eq(true)
|
||||
|
@ -2956,7 +2956,7 @@ describe UsersController do
|
|||
expect(response.status).to eq(200)
|
||||
expect(response.headers['X-Robots-Tag']).to eq('noindex')
|
||||
|
||||
json = JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
|
||||
expect(json["user"]["has_title_badges"]).to eq(false)
|
||||
end
|
||||
|
@ -3010,7 +3010,7 @@ describe UsersController do
|
|||
it "returns fetch for a matching external_id" do
|
||||
get "/u/by-external/997.json"
|
||||
expect(response.status).to eq(200)
|
||||
expect(JSON.parse(response.body)["user"]["username"]).to eq(user.username)
|
||||
expect(response.parsed_body["user"]["username"]).to eq(user.username)
|
||||
end
|
||||
|
||||
it "returns not found when external_id doesn't match" do
|
||||
|
@ -3032,7 +3032,7 @@ describe UsersController do
|
|||
|
||||
it "includes only visible posts" do
|
||||
get "/u/#{admin.username}.json", params: { include_post_count_for: topic.id }
|
||||
topic_post_count = JSON.parse(response.body).dig("user", "topic_post_count")
|
||||
topic_post_count = response.parsed_body.dig("user", "topic_post_count")
|
||||
expect(topic_post_count[topic.id.to_s]).to eq(1)
|
||||
end
|
||||
|
||||
|
@ -3040,7 +3040,7 @@ describe UsersController do
|
|||
sign_in(admin)
|
||||
|
||||
get "/u/#{admin.username}.json", params: { include_post_count_for: topic.id }
|
||||
topic_post_count = JSON.parse(response.body).dig("user", "topic_post_count")
|
||||
topic_post_count = response.parsed_body.dig("user", "topic_post_count")
|
||||
expect(topic_post_count[topic.id.to_s]).to eq(2)
|
||||
end
|
||||
end
|
||||
|
@ -3074,7 +3074,7 @@ describe UsersController do
|
|||
it "returns success" do
|
||||
get "/u/#{user.username}/card.json"
|
||||
expect(response.status).to eq(200)
|
||||
parsed = JSON.parse(response.body)["user"]
|
||||
parsed = response.parsed_body["user"]
|
||||
|
||||
expect(parsed["username"]).to eq(user.username)
|
||||
expect(parsed["profile_hidden"]).to be_blank
|
||||
|
@ -3099,7 +3099,7 @@ describe UsersController do
|
|||
get "/u/#{user.username}/card.json"
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
json = JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
|
||||
expect(json["user"]["associated_accounts"]).to eq(nil) # Not serialized in card
|
||||
expect(json["user"]["username"]).to eq(user.username)
|
||||
|
@ -3125,7 +3125,7 @@ describe UsersController do
|
|||
it "returns success" do
|
||||
get "/user-cards.json?user_ids=#{user.id},#{user2.id}"
|
||||
expect(response.status).to eq(200)
|
||||
parsed = JSON.parse(response.body)["users"]
|
||||
parsed = response.parsed_body["users"]
|
||||
|
||||
expect(parsed.map { |u| u["username"] }).to contain_exactly(user.username, user2.username)
|
||||
end
|
||||
|
@ -3140,7 +3140,7 @@ describe UsersController do
|
|||
user2.user_option.update(hide_profile_and_presence: true)
|
||||
get "/user-cards.json?user_ids=#{user.id},#{user2.id}"
|
||||
expect(response.status).to eq(200)
|
||||
parsed = JSON.parse(response.body)["users"]
|
||||
parsed = response.parsed_body["users"]
|
||||
|
||||
expect(parsed.map { |u| u["username"] }).to contain_exactly(user.username)
|
||||
end
|
||||
|
@ -3221,14 +3221,14 @@ describe UsersController do
|
|||
it "searches when provided the term only" do
|
||||
get "/u/search/users.json", params: { term: user.name.split(" ").last }
|
||||
expect(response.status).to eq(200)
|
||||
json = JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json["users"].map { |u| u["username"] }).to include(user.username)
|
||||
end
|
||||
|
||||
it "searches when provided the topic only" do
|
||||
get "/u/search/users.json", params: { topic_id: topic.id }
|
||||
expect(response.status).to eq(200)
|
||||
json = JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json["users"].map { |u| u["username"] }).to include(user.username)
|
||||
end
|
||||
|
||||
|
@ -3238,7 +3238,7 @@ describe UsersController do
|
|||
}
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
json = JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json["users"].map { |u| u["username"] }).to include(user.username)
|
||||
end
|
||||
|
||||
|
@ -3262,7 +3262,7 @@ describe UsersController do
|
|||
}
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
json = JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json["users"].map { |u| u["username"] }).to_not include(user.username)
|
||||
expect(json["users"].map { |u| u["username"] }).to include(privileged_user.username)
|
||||
end
|
||||
|
@ -3283,7 +3283,7 @@ describe UsersController do
|
|||
|
||||
it "returns names" do
|
||||
get "/u/search/users.json", params: { term: user.name }
|
||||
json = JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json["users"].map { |u| u["name"] }).to include(user.name)
|
||||
end
|
||||
end
|
||||
|
@ -3295,7 +3295,7 @@ describe UsersController do
|
|||
|
||||
it "returns names" do
|
||||
get "/u/search/users.json", params: { term: user.name }
|
||||
json = JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json["users"].map { |u| u["name"] }).not_to include(user.name)
|
||||
end
|
||||
end
|
||||
|
@ -3347,7 +3347,7 @@ describe UsersController do
|
|||
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
groups = JSON.parse(response.body)["groups"]
|
||||
groups = response.parsed_body["groups"]
|
||||
expect(groups).to eq(nil)
|
||||
end
|
||||
|
||||
|
@ -3356,7 +3356,7 @@ describe UsersController do
|
|||
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
groups = JSON.parse(response.body)["groups"]
|
||||
groups = response.parsed_body["groups"]
|
||||
|
||||
expect(groups.map { |group| group['name'] })
|
||||
.to_not include(private_group.name)
|
||||
|
@ -3370,7 +3370,7 @@ describe UsersController do
|
|||
}
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
expect(JSON.parse(response.body)).not_to have_key(:groups)
|
||||
expect(response.parsed_body).not_to have_key(:groups)
|
||||
end
|
||||
|
||||
it "searches for messageable groups" do
|
||||
|
@ -3382,7 +3382,7 @@ describe UsersController do
|
|||
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
expect(JSON.parse(response.body)["groups"].map { |group| group['name'] })
|
||||
expect(response.parsed_body["groups"].map { |group| group['name'] })
|
||||
.to contain_exactly(messageable_group.name, Group.find(Group::AUTO_GROUPS[:moderators]).name)
|
||||
end
|
||||
|
||||
|
@ -3395,7 +3395,7 @@ describe UsersController do
|
|||
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
groups = JSON.parse(response.body)["groups"]
|
||||
groups = response.parsed_body["groups"]
|
||||
|
||||
expect(groups.map { |group| group['name'] })
|
||||
.to contain_exactly(mentionable_group.name, mentionable_group_2.name)
|
||||
|
@ -3411,7 +3411,7 @@ describe UsersController do
|
|||
}
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
expect(JSON.parse(response.body)).not_to have_key(:groups)
|
||||
expect(response.parsed_body).not_to have_key(:groups)
|
||||
|
||||
get "/u/search/users.json", params: {
|
||||
include_mentionable_groups: 'false',
|
||||
|
@ -3420,7 +3420,7 @@ describe UsersController do
|
|||
}
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
expect(JSON.parse(response.body)).not_to have_key(:groups)
|
||||
expect(response.parsed_body).not_to have_key(:groups)
|
||||
|
||||
get "/u/search/users.json", params: {
|
||||
include_messageable_groups: 'false',
|
||||
|
@ -3429,7 +3429,7 @@ describe UsersController do
|
|||
}
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
expect(JSON.parse(response.body)).not_to have_key(:groups)
|
||||
expect(response.parsed_body).not_to have_key(:groups)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -3477,7 +3477,7 @@ describe UsersController do
|
|||
end
|
||||
|
||||
def users_found
|
||||
JSON.parse(response.body)['users'].map { |u| u['username'] }
|
||||
response.parsed_body['users'].map { |u| u['username'] }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -3505,7 +3505,7 @@ describe UsersController do
|
|||
post "/u/email-login.json", params: { login: user.email }
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
expect(JSON.parse(response.body)['user_found']).to eq(true)
|
||||
expect(response.parsed_body['user_found']).to eq(true)
|
||||
|
||||
job_args = Jobs::CriticalUserEmail.jobs.last["args"].first
|
||||
|
||||
|
@ -3530,7 +3530,7 @@ describe UsersController do
|
|||
post "/u/email-login.json", params: { login: '@random' }
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
json = JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json['user_found']).to eq(false)
|
||||
expect(json['hide_taken']).to eq(false)
|
||||
expect(Jobs::CriticalUserEmail.jobs).to eq([])
|
||||
|
@ -3543,7 +3543,7 @@ describe UsersController do
|
|||
post "/u/email-login.json", params: { login: user.email }
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
json = JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json.has_key?('user_found')).to eq(false)
|
||||
expect(json['hide_taken']).to eq(true)
|
||||
end
|
||||
|
@ -3610,7 +3610,7 @@ describe UsersController do
|
|||
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
response_body = JSON.parse(response.body)
|
||||
response_body = response.parsed_body
|
||||
|
||||
expect(response_body['key']).to be_present
|
||||
expect(response_body['qr']).to be_present
|
||||
|
@ -3646,7 +3646,7 @@ describe UsersController do
|
|||
post "/users/enable_second_factor_totp.json", params: { name: "test", second_factor_token: "123456" }
|
||||
end
|
||||
it "shows a helpful error message to the user" do
|
||||
expect(JSON.parse(response.body)['error']).to eq(I18n.t("login.invalid_second_factor_code"))
|
||||
expect(response.parsed_body['error']).to eq(I18n.t("login.invalid_second_factor_code"))
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -3656,7 +3656,7 @@ describe UsersController do
|
|||
post "/users/enable_second_factor_totp.json", params: { second_factor_token: "123456" }
|
||||
end
|
||||
it "shows a helpful error message to the user" do
|
||||
expect(JSON.parse(response.body)['error']).to eq(I18n.t("login.missing_second_factor_name"))
|
||||
expect(response.parsed_body['error']).to eq(I18n.t("login.missing_second_factor_name"))
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -3666,7 +3666,7 @@ describe UsersController do
|
|||
post "/users/enable_second_factor_totp.json", params: { name: "test" }
|
||||
end
|
||||
it "shows a helpful error message to the user" do
|
||||
expect(JSON.parse(response.body)['error']).to eq(I18n.t("login.missing_second_factor_code"))
|
||||
expect(response.parsed_body['error']).to eq(I18n.t("login.missing_second_factor_code"))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -3813,7 +3813,7 @@ describe UsersController do
|
|||
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
response_body = JSON.parse(response.body)
|
||||
response_body = response.parsed_body
|
||||
|
||||
# we use SecureRandom.hex(16) for backup codes, ensure this continues to be the case
|
||||
expect(response_body['backup_codes'].map(&:length)).to eq([32] * 10)
|
||||
|
@ -3826,7 +3826,7 @@ describe UsersController do
|
|||
it "stores the challenge in the session and returns challenge data, user id, and supported algorithms" do
|
||||
create_second_factor_security_key
|
||||
secure_session = read_secure_session
|
||||
response_parsed = JSON.parse(response.body)
|
||||
response_parsed = response.parsed_body
|
||||
expect(response_parsed["challenge"]).to eq(
|
||||
Webauthn.challenge(user, secure_session)
|
||||
)
|
||||
|
@ -3849,7 +3849,7 @@ describe UsersController do
|
|||
|
||||
it "returns those existing active credentials" do
|
||||
create_second_factor_security_key
|
||||
response_parsed = JSON.parse(response.body)
|
||||
response_parsed = response.parsed_body
|
||||
expect(response_parsed["existing_active_credential_ids"]).to eq(
|
||||
[user_security_key.credential_id]
|
||||
)
|
||||
|
@ -3862,7 +3862,7 @@ describe UsersController do
|
|||
it "creates a security key for the user" do
|
||||
simulate_localhost_webauthn_challenge
|
||||
create_second_factor_security_key
|
||||
response_parsed = JSON.parse(response.body)
|
||||
response_parsed = response.parsed_body
|
||||
|
||||
post "/u/register_second_factor_security_key.json", params: valid_security_key_create_post_data
|
||||
|
||||
|
@ -3876,7 +3876,7 @@ describe UsersController do
|
|||
it "shows a security key error and does not create a key" do
|
||||
stub_as_dev_localhost
|
||||
create_second_factor_security_key
|
||||
response_parsed = JSON.parse(response.body)
|
||||
response_parsed = response.parsed_body
|
||||
|
||||
post "/u/register_second_factor_security_key.json", params: {
|
||||
id: "bad id",
|
||||
|
@ -3888,7 +3888,7 @@ describe UsersController do
|
|||
}
|
||||
|
||||
expect(user.security_keys.count).to eq(0)
|
||||
expect(JSON.parse(response.body)["error"]).to eq(I18n.t("webauthn.validation.invalid_type_error"))
|
||||
expect(response.parsed_body["error"]).to eq(I18n.t("webauthn.validation.invalid_type_error"))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -4082,7 +4082,7 @@ describe UsersController do
|
|||
|
||||
it 'returns password required response' do
|
||||
expect(response.status).to eq(200)
|
||||
response_body = JSON.parse(response.body)
|
||||
response_body = response.parsed_body
|
||||
expect(response_body['password_required']).to eq(true)
|
||||
end
|
||||
end
|
||||
|
@ -4100,7 +4100,7 @@ describe UsersController do
|
|||
post "/u/second_factors.json", params: { password: password }
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
response_body = JSON.parse(response.body)
|
||||
response_body = response.parsed_body
|
||||
expect(response_body['totps'].map { |second_factor| second_factor['id'] }).to include(totp_second_factor.id)
|
||||
expect(response_body['security_keys'].map { |second_factor| second_factor['id'] }).to include(security_key_second_factor.id)
|
||||
end
|
||||
|
@ -4113,7 +4113,7 @@ describe UsersController do
|
|||
|
||||
post "/u/second_factors.json", params: { password: password }
|
||||
|
||||
response_body = JSON.parse(response.body)
|
||||
response_body = response.parsed_body
|
||||
expect(response_body['error']).to eq(
|
||||
I18n.t("login.incorrect_password")
|
||||
)
|
||||
|
@ -4237,7 +4237,7 @@ describe UsersController do
|
|||
sign_in(user)
|
||||
get "/u/#{user.username}/bookmarks.json"
|
||||
expect(response.status).to eq(200)
|
||||
expect(JSON.parse(response.body)['user_bookmark_list']['bookmarks'].map { |b| b['id'] }).to match_array([bookmark1.id, bookmark2.id])
|
||||
expect(response.parsed_body['user_bookmark_list']['bookmarks'].map { |b| b['id'] }).to match_array([bookmark1.id, bookmark2.id])
|
||||
end
|
||||
|
||||
it "does not show another user's bookmarks" do
|
||||
|
|
|
@ -43,7 +43,7 @@ describe WizardController do
|
|||
sign_in(Fabricate(:admin))
|
||||
get "/wizard.json"
|
||||
expect(response.status).to eq(200)
|
||||
expect(::JSON.parse(response.body).has_key?('wizard')).to eq(true)
|
||||
expect(response.parsed_body.has_key?('wizard')).to eq(true)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -6,7 +6,7 @@ module IntegrationHelpers
|
|||
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
body = JSON.parse(response.body)
|
||||
body = response.parsed_body
|
||||
honeypot = body["value"]
|
||||
challenge = body["challenge"]
|
||||
user = Fabricate.build(:user)
|
||||
|
@ -21,7 +21,7 @@ module IntegrationHelpers
|
|||
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
body = JSON.parse(response.body)
|
||||
body = response.parsed_body
|
||||
User.find(body["user_id"])
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue