mirror of
https://github.com/discourse/discourse.git
synced 2025-05-29 11:48:08 +08:00
DEV: Assert for 200 response code to avoid changing magic helper in the future.
This commit is contained in:
@ -152,7 +152,7 @@ describe GroupsController do
|
||||
staff_group
|
||||
get "/groups.json"
|
||||
|
||||
expect(response).to be_successful
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
response_body = JSON.parse(response.body)
|
||||
|
||||
@ -382,7 +382,7 @@ describe GroupsController do
|
||||
sign_in(user)
|
||||
|
||||
get "/groups/#{group.name}/mentionable.json"
|
||||
expect(response).to be_successful
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
response_body = JSON.parse(response.body)
|
||||
expect(response_body["mentionable"]).to eq(false)
|
||||
@ -393,7 +393,7 @@ describe GroupsController do
|
||||
)
|
||||
|
||||
get "/groups/#{group.name}/mentionable.json"
|
||||
expect(response).to be_successful
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
response_body = JSON.parse(response.body)
|
||||
expect(response_body["mentionable"]).to eq(true)
|
||||
@ -405,7 +405,7 @@ describe GroupsController do
|
||||
sign_in(user)
|
||||
|
||||
get "/groups/#{group.name}/messageable.json"
|
||||
expect(response).to be_successful
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
response_body = JSON.parse(response.body)
|
||||
expect(response_body["messageable"]).to eq(false)
|
||||
@ -416,7 +416,7 @@ describe GroupsController do
|
||||
)
|
||||
|
||||
get "/groups/#{group.name}/messageable.json"
|
||||
expect(response).to be_successful
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
response_body = JSON.parse(response.body)
|
||||
expect(response_body["messageable"]).to eq(true)
|
||||
@ -645,7 +645,7 @@ describe GroupsController do
|
||||
order: 'last_seen_at', desc: true
|
||||
}
|
||||
|
||||
expect(response).to be_successful
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
members = JSON.parse(response.body)["members"]
|
||||
|
||||
@ -653,7 +653,7 @@ describe GroupsController do
|
||||
|
||||
get "/groups/#{group.name}/members.json", params: { order: 'last_seen_at' }
|
||||
|
||||
expect(response).to be_successful
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
members = JSON.parse(response.body)["members"]
|
||||
|
||||
@ -663,7 +663,7 @@ describe GroupsController do
|
||||
order: 'last_posted_at', desc: true
|
||||
}
|
||||
|
||||
expect(response).to be_successful
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
members = JSON.parse(response.body)["members"]
|
||||
|
||||
@ -673,7 +673,7 @@ describe GroupsController do
|
||||
it "should not allow members to be sorted by columns that are not allowed" do
|
||||
get "/groups/#{group.name}/members.json", params: { order: 'email' }
|
||||
|
||||
expect(response).to be_successful
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
members = JSON.parse(response.body)["members"]
|
||||
|
||||
@ -808,7 +808,7 @@ describe GroupsController do
|
||||
put "/groups/#{group.id}/members.json", params: { usernames: user2.username }
|
||||
end.to change { group.users.count }.by(1)
|
||||
|
||||
expect(response).to be_successful
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
group_history = GroupHistory.last
|
||||
|
||||
@ -834,7 +834,7 @@ describe GroupsController do
|
||||
params: { usernames: [user1.username, user2.username].join(",") }
|
||||
end.to change { group.users.count }.by(2)
|
||||
|
||||
expect(response).to be_successful
|
||||
expect(response.status).to eq(200)
|
||||
end
|
||||
|
||||
it "adds by id" do
|
||||
@ -843,7 +843,7 @@ describe GroupsController do
|
||||
params: { user_ids: [user1.id, user2.id].join(",") }
|
||||
end.to change { group.users.count }.by(2)
|
||||
|
||||
expect(response).to be_successful
|
||||
expect(response.status).to eq(200)
|
||||
end
|
||||
|
||||
it "adds by email" do
|
||||
@ -852,7 +852,7 @@ describe GroupsController do
|
||||
params: { user_emails: [user1.email, user2.email].join(",") }
|
||||
end.to change { group.users.count }.by(2)
|
||||
|
||||
expect(response).to be_successful
|
||||
expect(response.status).to eq(200)
|
||||
end
|
||||
|
||||
it 'fails when multiple member already exists' do
|
||||
@ -920,7 +920,7 @@ describe GroupsController do
|
||||
params: { usernames: other_user.username }
|
||||
end.to change { group.users.count }.by(1)
|
||||
|
||||
expect(response).to be_successful
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
group_history = GroupHistory.last
|
||||
|
||||
@ -938,7 +938,7 @@ describe GroupsController do
|
||||
params: { usernames: other_user.username }
|
||||
end.to change { group.users.count }.by(1)
|
||||
|
||||
expect(response).to be_successful
|
||||
expect(response.status).to eq(200)
|
||||
end
|
||||
|
||||
it 'should not allow an underprivilege user to add another user to a group' do
|
||||
@ -971,7 +971,7 @@ describe GroupsController do
|
||||
delete "/groups/#{group.id}/members.json", params: { user_id: user.id }
|
||||
end.to change { group.users.count }.by(-1)
|
||||
|
||||
expect(response).to be_successful
|
||||
expect(response.status).to eq(200)
|
||||
end
|
||||
|
||||
it "removes by username" do
|
||||
@ -979,7 +979,7 @@ describe GroupsController do
|
||||
delete "/groups/#{group.id}/members.json", params: { username: user.username }
|
||||
end.to change { group.users.count }.by(-1)
|
||||
|
||||
expect(response).to be_successful
|
||||
expect(response.status).to eq(200)
|
||||
end
|
||||
|
||||
it "removes user.primary_group_id when user is removed from group" do
|
||||
@ -996,7 +996,7 @@ describe GroupsController do
|
||||
params: { user_email: user.email }
|
||||
end.to change { group.users.count }.by(-1)
|
||||
|
||||
expect(response).to be_successful
|
||||
expect(response.status).to eq(200)
|
||||
end
|
||||
|
||||
context 'public group' do
|
||||
@ -1010,7 +1010,7 @@ describe GroupsController do
|
||||
params: { username: other_user.username }
|
||||
end.to change { group.users.count }.by(-1)
|
||||
|
||||
expect(response).to be_successful
|
||||
expect(response.status).to eq(200)
|
||||
end
|
||||
end
|
||||
|
||||
@ -1022,7 +1022,7 @@ describe GroupsController do
|
||||
params: { username: other_user.username }
|
||||
end.to change { group.users.count }.by(-1)
|
||||
|
||||
expect(response).to be_successful
|
||||
expect(response.status).to eq(200)
|
||||
end
|
||||
|
||||
it 'should not allow a underprivilege user to leave a group for another user' do
|
||||
@ -1077,7 +1077,7 @@ describe GroupsController do
|
||||
it 'should allow group owner to view history' do
|
||||
get "/groups/#{group.name}/logs.json"
|
||||
|
||||
expect(response).to be_successful
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
result = JSON.parse(response.body)["logs"].last
|
||||
|
||||
@ -1109,7 +1109,7 @@ describe GroupsController do
|
||||
|
||||
get "/groups/#{group.name}/logs.json"
|
||||
|
||||
expect(response).to be_successful
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
result = JSON.parse(response.body)["logs"].first
|
||||
|
||||
@ -1132,7 +1132,7 @@ describe GroupsController do
|
||||
filters: { "action" => "add_user_to_group" }
|
||||
}
|
||||
|
||||
expect(response).to be_successful
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
logs = JSON.parse(response.body)["logs"]
|
||||
|
||||
@ -1167,7 +1167,7 @@ describe GroupsController do
|
||||
post "/groups/#{group.name}/request_membership.json",
|
||||
params: { reason: 'Please add me in' }
|
||||
|
||||
expect(response).to be_successful
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
post = Post.last
|
||||
topic = post.topic
|
||||
@ -1217,7 +1217,7 @@ describe GroupsController do
|
||||
|
||||
get '/groups/search.json'
|
||||
|
||||
expect(response).to be_successful
|
||||
expect(response.status).to eq(200)
|
||||
groups = JSON.parse(response.body)
|
||||
|
||||
expected_ids = Group::AUTO_GROUPS.map { |name, id| id }
|
||||
@ -1229,7 +1229,7 @@ describe GroupsController do
|
||||
['GO', 'nerys'].each do |term|
|
||||
get "/groups/search.json?term=#{term}"
|
||||
|
||||
expect(response).to be_successful
|
||||
expect(response.status).to eq(200)
|
||||
groups = JSON.parse(response.body)
|
||||
|
||||
expect(groups.length).to eq(1)
|
||||
@ -1238,7 +1238,7 @@ describe GroupsController do
|
||||
|
||||
get "/groups/search.json?term=KingOfTheNorth"
|
||||
|
||||
expect(response).to be_successful
|
||||
expect(response.status).to eq(200)
|
||||
groups = JSON.parse(response.body)
|
||||
|
||||
expect(groups).to eq([])
|
||||
@ -1255,7 +1255,7 @@ describe GroupsController do
|
||||
|
||||
get "/groups/search.json?term=north"
|
||||
|
||||
expect(response).to be_successful
|
||||
expect(response.status).to eq(200)
|
||||
groups = JSON.parse(response.body)
|
||||
|
||||
expect(groups.length).to eq(1)
|
||||
@ -1269,7 +1269,7 @@ describe GroupsController do
|
||||
|
||||
get '/groups/search.json?ignore_automatic=true'
|
||||
|
||||
expect(response).to be_successful
|
||||
expect(response.status).to eq(200)
|
||||
groups = JSON.parse(response.body)
|
||||
|
||||
expect(groups.length).to eq(2)
|
||||
|
Reference in New Issue
Block a user