Created
September 18, 2008 18:26
-
-
Save Bill/11457 to your computer and use it in GitHub Desktop.
This file contains 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
describe 'authenticated principal' do | |
before(:each) do | |
mock_valid_authentication | |
end | |
it 'should start with a new User object' do | |
get 'new' | |
assigns[:user].nil?.should == false | |
end | |
describe 'presenting valid captcha' do | |
before(:each) do | |
@captcha = Captcha.new(:captcha => 'CAPTCHA', :captcha_verified=>false) | |
end | |
describe 'with all required fields present' do | |
before(:each) do | |
@user = User.new(:email => 'email', :first_name => 'not-fred', :last_name => 'jones', :zip => 34567, :country => 'mexico', :nickname => 'not-freddo') | |
post 'create', {:user => @user.attributes, :captcha => @captcha.attributes} | |
end | |
it 'should save User' do | |
assigns[:user].should_not be_new_record | |
end | |
end | |
end # 'presenting valid captcha' | |
describe 'registered user' do | |
describe 'when looking for her own profile' do | |
it 'should see show form' do | |
get 'show', :id => users(:fred).id | |
response.should be_success | |
end | |
it 'should be able to update attributes' do | |
request.host = 'thoughtpropulsion.com' | |
put 'update', {:id => users(:fred).id, :nickname => 'freddo'} | |
response.should be_redirect | |
# TODO: fixme | |
# redirect matching doesn't work when routes depend on :host since redirect_to only matches based on URL path | |
# response.should redirect_to( :controller => 'users', :action => 'show', :id => users(:fred).id, :method => :get, :host => 'thoughtpropulsion.com') | |
end | |
end | |
describe "when looking for someone else's profile" do | |
it 'should not see show form' do | |
get 'show', :id => users(:sally).id | |
response.should_not be_success | |
end | |
it 'should not be able to edit attributes' do | |
put 'update', :id => users(:sally).id, :nickname => 'freddo' | |
response.headers["Status"].should == "403 Forbidden" | |
end | |
end | |
def mock_valid_authentication | |
session[:identity_url] = users(:fred).identity_url # matches user in fixtures | |
end | |
end # 'registered user' | |
def mock_valid_authentication | |
session[:identity_url] = 'not-fred.myopenid.com' # does NOT match user in fixtures | |
end | |
end # 'authenticated principal |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment