From e9d16cc09b5c6dd2ae256658e0ec8b30fb56f882 Mon Sep 17 00:00:00 2001 From: danielvincent Date: Wed, 22 Sep 2010 15:48:50 -0700 Subject: [PATCH] DG IZ; cleanup --- app/controllers/albums_controller.rb | 2 +- app/controllers/application_controller.rb | 9 --------- app/controllers/photos_controller.rb | 2 +- app/models/user.rb | 8 ++------ config/routes.rb | 2 -- spec/models/user/posting_spec.rb | 17 ++--------------- 6 files changed, 6 insertions(+), 34 deletions(-) diff --git a/app/controllers/albums_controller.rb b/app/controllers/albums_controller.rb index 14adcebe1..d3cad54e2 100644 --- a/app/controllers/albums_controller.rb +++ b/app/controllers/albums_controller.rb @@ -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 diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index ac0d11b1c..f0ca5bfc8 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -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 diff --git a/app/controllers/photos_controller.rb b/app/controllers/photos_controller.rb index 8d383f53a..d0cb1871e 100644 --- a/app/controllers/photos_controller.rb +++ b/app/controllers/photos_controller.rb @@ -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 diff --git a/app/models/user.rb b/app/models/user.rb index 45f947807..8f74e2233 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -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 diff --git a/config/routes.rb b/config/routes.rb index 1a7a53925..0ac115b76 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -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' diff --git a/spec/models/user/posting_spec.rb b/spec/models/user/posting_spec.rb index 6b939b573..d307e7a43 100644 --- a/spec/models/user/posting_spec.rb +++ b/spec/models/user/posting_spec.rb @@ -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