Skip to content

Instantly share code, notes, and snippets.

@bkerley
Forked from anonymous/touchnotes.py
Created July 21, 2008 02:25
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save bkerley/45 to your computer and use it in GitHub Desktop.
Save bkerley/45 to your computer and use it in GitHub Desktop.
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
@RobinsonVillanueva
Copy link

Falabella

@RobinsonVillanueva
Copy link

Falabella

@RobinsonVillanueva
Copy link

Falabella

@RobinsonVillanueva
Copy link

Falabella

@RobinsonVillanueva
Copy link

Falabella 2

@RobinsonVillanueva
Copy link

Falabella 2

@RobinsonVillanueva
Copy link

Falabella 2

@RobinsonVillanueva
Copy link

Falabella 2

@RobinsonVillanueva
Copy link

Falabella 2

@RobinsonVillanueva
Copy link

Falabella 2

@RobinsonVillanueva
Copy link

Falabella 2

@RobinsonVillanueva
Copy link

Falabella

@RobinsonVillanueva
Copy link

Falabella

@RobinsonVillanueva
Copy link

Falabella

@RobinsonVillanueva
Copy link

Falabella

@RobinsonVillanueva
Copy link

Falabella

@Marequena
Copy link

Aqui el comentario

@Marequena
Copy link

Aqui el comentario

@Marequena
Copy link

Aqui el comentario

@Marequena
Copy link

Aqui el comentario

@acaceresv
Copy link

comentario de prueba

@acaceresv
Copy link

comentario de prueba

@acaceresv
Copy link

comentario de prueba

@acaceresv
Copy link

comentario de prueba

@acaceresv
Copy link

comentario de prueba

@acaceresv
Copy link

comentario de prueba

@acaceresv
Copy link

comentario de prueba

@acaceresv
Copy link

comentario de prueba

@acaceresv
Copy link

comentario de prueba

@acaceresv
Copy link

comentario de prueba

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment