mirror of
https://github.com/discourse/discourse.git
synced 2025-05-22 03:51:07 +08:00
controllers with rspec3 syntax
This commit is contained in:
@ -7,21 +7,21 @@ describe GroupsController do
|
||||
it "ensures the group can be seen" do
|
||||
Guardian.any_instance.expects(:can_see?).with(group).returns(false)
|
||||
xhr :get, :show, id: group.name
|
||||
response.should_not be_success
|
||||
expect(response).not_to be_success
|
||||
end
|
||||
|
||||
it "responds with JSON" do
|
||||
Guardian.any_instance.expects(:can_see?).with(group).returns(true)
|
||||
xhr :get, :show, id: group.name
|
||||
response.should be_success
|
||||
::JSON.parse(response.body)['basic_group']['id'].should == group.id
|
||||
expect(response).to be_success
|
||||
expect(::JSON.parse(response.body)['basic_group']['id']).to eq(group.id)
|
||||
end
|
||||
|
||||
it "works even with an upper case group name" do
|
||||
Guardian.any_instance.expects(:can_see?).with(group).returns(true)
|
||||
xhr :get, :show, id: group.name.upcase
|
||||
response.should be_success
|
||||
::JSON.parse(response.body)['basic_group']['id'].should == group.id
|
||||
expect(response).to be_success
|
||||
expect(::JSON.parse(response.body)['basic_group']['id']).to eq(group.id)
|
||||
end
|
||||
end
|
||||
|
||||
@ -29,14 +29,14 @@ describe GroupsController do
|
||||
it "ensures the group can be seen" do
|
||||
Guardian.any_instance.expects(:can_see?).with(group).returns(false)
|
||||
xhr :get, :counts, group_id: group.name
|
||||
response.should_not be_success
|
||||
expect(response).not_to be_success
|
||||
end
|
||||
|
||||
it "performs the query and responds with JSON" do
|
||||
Guardian.any_instance.expects(:can_see?).with(group).returns(true)
|
||||
Group.any_instance.expects(:posts_for).returns(Group.none)
|
||||
xhr :get, :counts, group_id: group.name
|
||||
response.should be_success
|
||||
expect(response).to be_success
|
||||
end
|
||||
end
|
||||
|
||||
@ -44,14 +44,14 @@ describe GroupsController do
|
||||
it "ensures the group can be seen" do
|
||||
Guardian.any_instance.expects(:can_see?).with(group).returns(false)
|
||||
xhr :get, :posts, group_id: group.name
|
||||
response.should_not be_success
|
||||
expect(response).not_to be_success
|
||||
end
|
||||
|
||||
it "calls `posts_for` and responds with JSON" do
|
||||
Guardian.any_instance.expects(:can_see?).with(group).returns(true)
|
||||
Group.any_instance.expects(:posts_for).returns(Group.none)
|
||||
xhr :get, :posts, group_id: group.name
|
||||
response.should be_success
|
||||
expect(response).to be_success
|
||||
end
|
||||
end
|
||||
|
||||
@ -59,13 +59,13 @@ describe GroupsController do
|
||||
it "ensures the group can be seen" do
|
||||
Guardian.any_instance.expects(:can_see?).with(group).returns(false)
|
||||
xhr :get, :members, group_id: group.name
|
||||
response.should_not be_success
|
||||
expect(response).not_to be_success
|
||||
end
|
||||
|
||||
it "calls `posts_for` and responds with JSON" do
|
||||
Guardian.any_instance.expects(:can_see?).with(group).returns(true)
|
||||
xhr :get, :posts, group_id: group.name
|
||||
response.should be_success
|
||||
expect(response).to be_success
|
||||
end
|
||||
|
||||
# Pending until we fix group truncation
|
||||
@ -74,14 +74,14 @@ describe GroupsController do
|
||||
usernames = group.users.map{ |m| m['username'] }.sort
|
||||
|
||||
xhr :get, :members, group_id: group.name, limit: 3
|
||||
response.should be_success
|
||||
expect(response).to be_success
|
||||
members = JSON.parse(response.body)
|
||||
members.map{ |m| m['username'] }.should eq(usernames[0..2])
|
||||
expect(members.map{ |m| m['username'] }).to eq(usernames[0..2])
|
||||
|
||||
xhr :get, :members, group_id: group.name, limit: 3, offset: 3
|
||||
response.should be_success
|
||||
expect(response).to be_success
|
||||
members = JSON.parse(response.body)
|
||||
members.map{ |m| m['username'] }.should eq(usernames[3..4])
|
||||
expect(members.map{ |m| m['username'] }).to eq(usernames[3..4])
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user