-
-
Save bkerley/45 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'spec_helper' | |
describe GroupsController do | |
include SessionTestHelper | |
describe "GET 'show'" do | |
it "should load the group from the database" do | |
@the_group = Factory(:group) | |
Group.stub(:find_active_by_unique_name).with("london-developers"). | |
and_return(@the_group) | |
get :show, :id => "london-developers" | |
response.should be_success | |
assigns(:group).should == @the_group | |
end | |
it "should send back a 404 when give an invalid id" do | |
get :show, :id => "i-dont-exist" | |
response.status.should == 404 | |
end | |
end | |
describe "GET 'index'" do | |
it "should load all the active groups from the database" do | |
@the_group = Factory(:group) | |
groups = [@the_group, @the_group] | |
Group.stub(:all_active).and_return(groups) | |
get :index | |
response.should be_success | |
assigns(:groups).should == groups | |
end | |
end | |
describe "GET 'edit'" do | |
before :each do | |
@user = Factory(:user) | |
logged_in_user_is(@user) | |
end | |
it "should load the group from the database" do | |
@the_group = Factory(:group, :organizer => @user) | |
Group.stub(:find_active_by_unique_name).with("london-developers"). | |
and_return(@the_group) | |
get :edit, :id => "london-developers" | |
response.should be_success | |
assigns(:group).should == @the_group | |
end | |
it "should only allow editing by the organiser of the group" do | |
@the_group = Factory(:group, :organizer => Factory(:ken)) | |
Group.stub(:find_active_by_unique_name).with("london-developers"). | |
and_return(@the_group) | |
get :edit, :id => "london-developers" | |
response.status.should == 403 | |
end | |
end | |
describe "PUT 'update'" do | |
before :each do | |
@user = Factory(:user) | |
logged_in_user_is(@user) | |
end | |
it "should update the group" do | |
@the_group = mock_model(Group).as_null_object | |
Group.stub(:find_active_by_unique_name).with("london-developers"). | |
and_return(@the_group) | |
valid_info = {:id => "london-developers", | |
:group => {"description" => "a description"}} | |
@the_group.should_receive(:update_attributes!).with(valid_info[:group]) | |
put :update, valid_info | |
response.should redirect_to group_url(@the_group.unique_name) | |
end | |
it "should only allow editing by the organiser of the group" do | |
@the_group = Factory(:group, :organizer => Factory(:ken)) | |
Group.stub(:find_active_by_unique_name).with("london-developers"). | |
and_return(@the_group) | |
valid_info = {:id => "london-developers", | |
:group => {"description" => "a description"}} | |
put :update, valid_info | |
get :update, :id => "london-developers" | |
response.status.should == 403 | |
end | |
end | |
end |
Falabella
Falabella
Falabella
Falabella 2
Falabella 2
Falabella 2
Falabella 2
Falabella 2
Falabella 2
Falabella 2
Falabella
Falabella
Falabella
Falabella
Falabella
Aqui el comentario
Aqui el comentario
Aqui el comentario
Aqui el comentario
comentario de prueba
comentario de prueba
comentario de prueba
comentario de prueba
comentario de prueba
comentario de prueba
comentario de prueba
comentario de prueba
comentario de prueba
comentario de prueba
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Falabella