DG IZ; cleanup
This commit is contained in:
parent
955d9130a2
commit
e9d16cc09b
6 changed files with 6 additions and 34 deletions
|
|
@ -52,7 +52,7 @@ class AlbumsController < ApplicationController
|
|||
|
||||
data = clean_hash(params[:album])
|
||||
|
||||
if current_user.update_or_repost( @album, data )
|
||||
if current_user.update_post( @album, data )
|
||||
flash[:notice] = "Album #{@album.name} successfully edited."
|
||||
respond_with @album
|
||||
else
|
||||
|
|
|
|||
|
|
@ -37,13 +37,4 @@ class ApplicationController < ActionController::Base
|
|||
@request_count = Request.for_user(current_user).size if current_user
|
||||
end
|
||||
|
||||
def repost
|
||||
@post = current_user.find_visible_post_by_id params[:id]
|
||||
if current_user.repost( @post, :to => params[:aspect_ids] )
|
||||
flash[:notice] = "Item re-shared."
|
||||
else
|
||||
flash[:error] = "Failed to re-share."
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
|||
|
|
@ -88,7 +88,7 @@ class PhotosController < ApplicationController
|
|||
|
||||
data = clean_hash(params)
|
||||
|
||||
if current_user.update_or_repost( @photo, data[:photo] )
|
||||
if current_user.update_post( @photo, data[:photo] )
|
||||
flash[:notice] = "Photo successfully updated."
|
||||
respond_with @photo
|
||||
else
|
||||
|
|
|
|||
|
|
@ -122,13 +122,9 @@ class User
|
|||
post
|
||||
end
|
||||
|
||||
def update_or_repost( post, post_hash = {} )
|
||||
def update_post( post, post_hash = {} )
|
||||
if self.owns? post
|
||||
if post_hash[:aspect_ids]
|
||||
repost(post, post_hash[:aspect_ids]) if validate_aspect_permissions post_hash[:aspect_ids]
|
||||
else
|
||||
post.update_attributes!(post_hash)
|
||||
end
|
||||
post.update_attributes(post_hash)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -13,8 +13,6 @@ Diaspora::Application.routes.draw do
|
|||
resources :photos, :except => [:index]
|
||||
resources :albums
|
||||
|
||||
match 'repost', :to => 'application#repost', :as => 'repost'
|
||||
|
||||
match 'aspects/move_friends', :to => 'aspects#move_friends', :as => 'move_friends'
|
||||
match 'aspects/move_friend', :to => 'aspects#move_friend', :as => 'move_friend'
|
||||
match 'aspects/manage', :to => 'aspects#manage'
|
||||
|
|
|
|||
|
|
@ -65,27 +65,14 @@ describe User do
|
|||
end
|
||||
end
|
||||
|
||||
describe '#update_or_repost' do
|
||||
describe '#update_post' do
|
||||
let!(:album) { user.post(:album, :name => "Profile Photos", :to => aspect.id) }
|
||||
|
||||
it 'should repost' do
|
||||
update_hash = { :aspect_ids => aspect1.id }
|
||||
user.should_receive(:repost).with(album, update_hash[:aspect_ids]).and_return album
|
||||
user.update_or_repost( album, update_hash )
|
||||
end
|
||||
|
||||
it 'should update fields' do
|
||||
update_hash = { :name => "Other Photos" }
|
||||
user.update_or_repost( album, update_hash )
|
||||
user.update_post( album, update_hash )
|
||||
album.name.should == "Other Photos"
|
||||
end
|
||||
|
||||
it 'should reject posting to an external aspect' do
|
||||
update_hash = { :aspect_ids => [aspect3.id] }
|
||||
proc{
|
||||
user.update_or_repost( album, update_hash )
|
||||
}.should raise_error /Cannot post to an aspect you do not own./
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue