Skip to content

Commit

Permalink
Pushing broken photo controller spec for dan to fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Raphael committed Oct 28, 2010
1 parent b5bea7f commit 78acdb7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 25 deletions.
25 changes: 2 additions & 23 deletions app/controllers/photos_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,7 @@ def create

params[:user_file] = file

data = clean_hash(params)

@photo = current_user.post(:photo, data)
@photo = current_user.post(:photo, params)

respond_to do |format|
format.json{render(:layout => false , :json => {"success" => true, "data" => @photo}.to_json )}
Expand Down Expand Up @@ -94,31 +92,12 @@ def edit
def update
@photo = current_user.find_visible_post_by_id params[:id]

data = clean_hash(params)

if current_user.update_post( @photo, data[:photo] )
if current_user.update_post( @photo, params[:photo] )
flash[:notice] = I18n.t 'photos.update.notice'
respond_with @photo
else
flash[:error] = I18n.t 'photos.update.error'
render :action => :edit
end
end

private
def clean_hash(params)
if params[:photo]
return {
:photo => {
:caption => params[:photo][:caption],
}
}
else
return{
:album_id => params[:album_id],
:user_file => params[:user_file]
}
end
end

end
4 changes: 2 additions & 2 deletions spec/controllers/photos_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
require 'spec_helper'

describe PhotosController do
render_views
render_views
before do
@user = Factory.create(:user)
@aspect = @user.aspect(:name => "lame-os")
Expand All @@ -31,7 +31,7 @@
it "doesn't overwrite random attributes" do
new_user = Factory.create :user
params = { :caption => "now with lasers!", :person_id => new_user.id}
put('update', :id => @photo.id, :photo => params)
put :update, :id => @photo.id, :photo => params
@photo.reload.person_id.should == @user.person.id
end
end
Expand Down

0 comments on commit 78acdb7

Please sign in to comment.