diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 56f0d01bb2523d2f809f936de719c305eb116e64..c7443c7af4e96ec375db235498d0af6cbc8fdfe1 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -16,8 +16,8 @@ class ApplicationController < ActionController::Base inflection_method :grammatical_gender => :gender - helper_method :all_aspects, :object_aspect_ids, :all_contacts_count, :my_contacts_count, :only_sharing_count - + helper_method :all_aspects, :all_contacts_count, :my_contacts_count, :only_sharing_count + def ensure_http_referer_is_set request.env['HTTP_REFERER'] ||= '/aspects' end @@ -34,16 +34,8 @@ class ApplicationController < ActionController::Base ##helpers - def object_aspect_ids - if user_signed_in? - @object_aspect_ids ||= [] - end - end - def all_aspects - if user_signed_in? - @all_aspects ||= current_user.aspects - end + @all_aspects ||= current_user.aspects end def all_contacts_count diff --git a/app/controllers/aspects_controller.rb b/app/controllers/aspects_controller.rb index 581a3c8ed1f27764a21782a11caf9fb13d35d506..1286e85c1ccdbdff7f2b2ce65093382a37265e3c 100644 --- a/app/controllers/aspects_controller.rb +++ b/app/controllers/aspects_controller.rb @@ -158,6 +158,11 @@ class AspectsController < ApplicationController params[:max_time] ||= Time.now + 1 end + helper_method :all_aspects_selected? + def all_aspects_selected? + @aspect == :all + end + private def save_sort_order if params[:sort_order].present? diff --git a/app/controllers/photos_controller.rb b/app/controllers/photos_controller.rb index a0dd7f1a0e54913df2680e7f2739df499569cfb3..952a504062935935a837f1f99d8e4de3f9566378 100644 --- a/app/controllers/photos_controller.rb +++ b/app/controllers/photos_controller.rb @@ -5,11 +5,11 @@ class PhotosController < ApplicationController before_filter :authenticate_user! - helper_method :object_aspect_ids, :parent, :photo, :additional_photos, :next_photo, :previous_photo, :ownership + helper_method :parent, :photo, :additional_photos, :next_photo, :previous_photo, :ownership respond_to :html, :json - + def index @post_type = :photos @person = Person.find_by_id(params[:person_id]) @@ -181,15 +181,6 @@ class PhotosController < ApplicationController end # helpers - - # used on the show page to show which aspects are selected - def object_aspect_ids - if params[:action] == 'show' && parent_aspects = parent.aspects.where(:user_id => current_user.id).all - @object_aspect_ids ||= parent_aspects.map{|a| a.id} - else - super - end - end def ownership @ownership ||= current_user.owns? photo diff --git a/app/controllers/status_messages_controller.rb b/app/controllers/status_messages_controller.rb index 2f018766f0aa4206a9d4bdcdd8eaf79b616dc5f5..5160411c64996dea93601dcb3dc33c03b1ea900c 100644 --- a/app/controllers/status_messages_controller.rb +++ b/app/controllers/status_messages_controller.rb @@ -10,8 +10,6 @@ class StatusMessagesController < ApplicationController respond_to :json, :only => :show - helper_method :object_aspect_ids - # Called when a user clicks "Mention" on a profile page # @option [Integer] person_id The id of the person to be mentioned def new @@ -110,7 +108,6 @@ class StatusMessagesController < ApplicationController def show @status_message = current_user.find_visible_post_by_id params[:id] if @status_message - @object_aspect_ids = @status_message.aspects.map{|a| a.id} # mark corresponding notification as read if notification = Notification.where(:recipient_id => current_user.id, :target_id => @status_message.id).first @@ -126,11 +123,4 @@ class StatusMessagesController < ApplicationController end end - def object_aspect_ids - if params[:action] == 'show' - @object_aspect_ids ||= @status_message.aspects.map{|a| a.id} - else - super - end - end end diff --git a/app/controllers/vanna_controller.rb b/app/controllers/vanna_controller.rb index c5ad614305be7abe12886977ab2c4b23a4233624..f3997de7fd53165c020012aa1fcd66b042bd0a9c 100644 --- a/app/controllers/vanna_controller.rb +++ b/app/controllers/vanna_controller.rb @@ -26,7 +26,6 @@ class VannaController < Vanna::Base before_filter :set_git_header if (AppConfig[:git_update] && AppConfig[:git_revision]) before_filter :which_action_and_user before_filter :all_aspects - before_filter :object_aspect_ids prepend_before_filter :clear_gc_stats before_filter :set_grammatical_gender @@ -41,7 +40,6 @@ class VannaController < Vanna::Base @notification_count = Notification.for(current_user, :unread =>true).count @unread_message_count = ConversationVisibility.sum(:unread, :conditions => "person_id = #{current_user.person.id}") end - @object_aspect_ids = [] @all_aspects = current_user.aspects end end @@ -56,16 +54,8 @@ class VannaController < Vanna::Base end end - def object_aspect_ids - if user_signed_in? - @object_aspect_ids ||= [] - end - end - def all_aspects - if user_signed_in? - @all_aspects ||= current_user.aspects - end + @all_aspects ||= current_user.aspects end def set_git_header @@ -130,6 +120,6 @@ class VannaController < Vanna::Base end def after_sign_in_path_for(resource) - stored_location_for(:user) || aspects_path(:a_ids => current_user.aspects.where(:open => true).select(:id).all.map{|a| a.id}) + stored_location_for(:user) || aspects_path(:a_ids => current_user.aspects.where(:open => true).select(:id).all.map{|a| a.id}) end end diff --git a/app/views/aspects/_aspect_stream.haml b/app/views/aspects/_aspect_stream.haml index 76823b474d607d397af3e41ce8ca0432e46726c5..3994a06a4fead488cc11b03a9e68df147810eb80 100644 --- a/app/views/aspects/_aspect_stream.haml +++ b/app/views/aspects/_aspect_stream.haml @@ -11,7 +11,7 @@ = link_to_if(session[:sort_order] == 'updated_at', t('.posted'), aspects_path(:a_ids => params[:a_ids], :sort_order => 'created_at' )) %h3 - - if @aspect == :all + - if all_aspects_selected? = t('.stream') - else = @aspects.to_sentence diff --git a/app/views/aspects/_selected_contacts.html.haml b/app/views/aspects/_selected_contacts.html.haml index d882922b325305a285865dc175c4f79c8d4af634..3851976827b46c3f744c309b01814e46dad45fdf 100644 --- a/app/views/aspects/_selected_contacts.html.haml +++ b/app/views/aspects/_selected_contacts.html.haml @@ -1,7 +1,7 @@ #selected_aspect_contacts.section .title.no_icon %h5 - - if @aspect == :all || @aspect_ids.size > 1 + - if @aspect_ids.size > 1 = "#{t('_contacts')}" - else = @aspect.name diff --git a/spec/controllers/photos_controller_spec.rb b/spec/controllers/photos_controller_spec.rb index e77c0c2e706fb75912178b011fcb95d76f1faad0..329d76e3636978f4572c26d6a72313c185b868ec 100644 --- a/spec/controllers/photos_controller_spec.rb +++ b/spec/controllers/photos_controller_spec.rb @@ -186,26 +186,14 @@ describe PhotosController do describe 'data helpers' do - describe '.object_aspect_ids' do - it 'on show, assigns object aspect ids' do - get :show, :id => @alices_photo.id - @controller.object_aspect_ids.should == [alice.aspects.first.id] - end - - it 'on index, it is empty' do - get :index, :person_id => alice.person.id - @controller.object_aspect_ids.should == [] - end - end - describe '.ownership' do it 'is true if current user owns the photo' do - get :show, :id => @alices_photo.id + get :show, :id => @alices_photo.id @controller.ownership.should be_true end it 'is true if current user owns the photo' do - get :show, :id => @bobs_photo.id + get :show, :id => @bobs_photo.id @controller.ownership.should be_false end end @@ -229,7 +217,7 @@ describe PhotosController do it 'returns a visible photo, based on the :id param' do get :show, :id => @alices_photo.id @controller.photo.id.should == @alices_photo.id - + end end