Pushing broken photo controller spec for dan to fix
This commit is contained in:
parent
b5bea7f14d
commit
78acdb7368
2 changed files with 4 additions and 25 deletions
|
|
@ -37,9 +37,7 @@ class PhotosController < ApplicationController
|
||||||
|
|
||||||
params[:user_file] = file
|
params[:user_file] = file
|
||||||
|
|
||||||
data = clean_hash(params)
|
@photo = current_user.post(:photo, params)
|
||||||
|
|
||||||
@photo = current_user.post(:photo, data)
|
|
||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.json{render(:layout => false , :json => {"success" => true, "data" => @photo}.to_json )}
|
format.json{render(:layout => false , :json => {"success" => true, "data" => @photo}.to_json )}
|
||||||
|
|
@ -94,9 +92,7 @@ class PhotosController < ApplicationController
|
||||||
def update
|
def update
|
||||||
@photo = current_user.find_visible_post_by_id params[:id]
|
@photo = current_user.find_visible_post_by_id params[:id]
|
||||||
|
|
||||||
data = clean_hash(params)
|
if current_user.update_post( @photo, params[:photo] )
|
||||||
|
|
||||||
if current_user.update_post( @photo, data[:photo] )
|
|
||||||
flash[:notice] = I18n.t 'photos.update.notice'
|
flash[:notice] = I18n.t 'photos.update.notice'
|
||||||
respond_with @photo
|
respond_with @photo
|
||||||
else
|
else
|
||||||
|
|
@ -104,21 +100,4 @@ class PhotosController < ApplicationController
|
||||||
render :action => :edit
|
render :action => :edit
|
||||||
end
|
end
|
||||||
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
|
end
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@
|
||||||
require 'spec_helper'
|
require 'spec_helper'
|
||||||
|
|
||||||
describe PhotosController do
|
describe PhotosController do
|
||||||
render_views
|
render_views
|
||||||
before do
|
before do
|
||||||
@user = Factory.create(:user)
|
@user = Factory.create(:user)
|
||||||
@aspect = @user.aspect(:name => "lame-os")
|
@aspect = @user.aspect(:name => "lame-os")
|
||||||
|
|
@ -31,7 +31,7 @@ describe PhotosController do
|
||||||
it "doesn't overwrite random attributes" do
|
it "doesn't overwrite random attributes" do
|
||||||
new_user = Factory.create :user
|
new_user = Factory.create :user
|
||||||
params = { :caption => "now with lasers!", :person_id => new_user.id}
|
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
|
@photo.reload.person_id.should == @user.person.id
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue