mirror of
https://github.com/discourse/discourse.git
synced 2025-06-04 09:34:41 +08:00
Added some specs for the group controller methods
This commit is contained in:
49
spec/controllers/groups_controller_spec.rb
Normal file
49
spec/controllers/groups_controller_spec.rb
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
require 'spec_helper'
|
||||||
|
|
||||||
|
describe GroupsController do
|
||||||
|
let(:group) { Fabricate(:group) }
|
||||||
|
|
||||||
|
describe 'show' 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
|
||||||
|
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
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
describe "posts" 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
|
||||||
|
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([])
|
||||||
|
xhr :get, :posts, group_id: group.name
|
||||||
|
response.should be_success
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
describe "members" 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
|
||||||
|
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
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
Reference in New Issue
Block a user