Add a spec to people_controller, make those specs a little clearer
This commit is contained in:
parent
ccd92fb850
commit
5cdeed6c54
2 changed files with 12 additions and 2 deletions
|
|
@ -56,6 +56,7 @@ class PeopleController < ApplicationController
|
|||
end
|
||||
|
||||
# upload and set new profile photo
|
||||
params[:person][:profile] ||= {}
|
||||
if params[:person][:profile][:image].present?
|
||||
raw_image = params[:person][:profile].delete(:image)
|
||||
params[:profile_image_hash] = { :user_file => raw_image, :to => "all" }
|
||||
|
|
|
|||
|
|
@ -22,14 +22,17 @@ describe PeopleController do
|
|||
|
||||
it 'should go to the current_user show page' do
|
||||
get :show, :id => user.person.id
|
||||
response.should be_success
|
||||
end
|
||||
|
||||
it "doesn't error out on an invalid id" do
|
||||
it "redirects on an invalid id" do
|
||||
get :show, :id => 'delicious'
|
||||
response.should redirect_to people_path
|
||||
end
|
||||
|
||||
it "doesn't error out on a nonexistent person" do
|
||||
it "redirects on a nonexistent person" do
|
||||
get :show, :id => user.id
|
||||
response.should redirect_to people_path
|
||||
end
|
||||
|
||||
describe '#update' do
|
||||
|
|
@ -50,5 +53,11 @@ describe PeopleController do
|
|||
user.person.profile.image_url.should == image_url
|
||||
end
|
||||
end
|
||||
it 'does not allow mass assignment' do
|
||||
new_user = make_user
|
||||
put :update, :id => user.person.id, :person => {
|
||||
:owner_id => new_user.id}
|
||||
user.person.reload.owner_id.should_not == new_user.id
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Reference in a new issue