diff --git a/app/controllers/aspects_controller.rb b/app/controllers/aspects_controller.rb index 051fb97e2..7bca3a14a 100644 --- a/app/controllers/aspects_controller.rb +++ b/app/controllers/aspects_controller.rb @@ -7,6 +7,7 @@ require File.join(Rails.root, "lib", 'stream', "aspect_stream") class AspectsController < ApplicationController before_filter :authenticate_user! before_filter :save_sort_order, :only => :index + before_filter :save_selected_aspects, :only => :index before_filter :ensure_page, :only => :index respond_to :html, :js @@ -15,7 +16,7 @@ class AspectsController < ApplicationController helper_method :selected_people def index - aspect_ids = (params[:a_ids] ? params[:a_ids] : []) + aspect_ids = (session[:a_ids] ? session[:a_ids] : []) @stream = AspectStream.new(current_user, aspect_ids, :order => sort_order, :max_time => params[:max_time].to_i) @@ -138,4 +139,10 @@ class AspectsController < ApplicationController end private + + def save_selected_aspects + if params[:a_ids].present? + session[:a_ids] = params[:a_ids] + end + end end diff --git a/features/aspect_navigation.feature b/features/aspect_navigation.feature new file mode 100644 index 000000000..9611d7ba8 --- /dev/null +++ b/features/aspect_navigation.feature @@ -0,0 +1,22 @@ +@javascript +Feature: Aspect navigation on the left menu + In order to filter posts visibility and post targeting + As a diaspora user + I want to use the aspect navigation menu + + Background: + Given a user with username "bob" + And I sign in as "bob@bob.bob" + + Scenario: All aspects are selected by default + When I go to the aspects page + Then I should see "Besties" aspect selected + Then I should see "Unicorns" aspect selected + + Scenario: Aspects selection is remembered through site navigation + When I go to the aspects page + And I select only "Besties" aspect + And I go to the contacts page + And I go to the aspects page + Then I should see "Besties" aspect selected + Then I should see "Unicorns" aspect unselected diff --git a/features/mentions_from_profile_page.feature b/features/mentions_from_profile_page.feature index 247ddba76..a5b3c3885 100644 --- a/features/mentions_from_profile_page.feature +++ b/features/mentions_from_profile_page.feature @@ -50,13 +50,9 @@ Feature: mentioning a contact from their profile page And I press "Share" in the modal window When I am on the aspects page - And I follow "Deselect all" within "#aspect_nav" - And I follow "PostingTo" within "#aspect_nav" - And I wait for the ajax to finish + And I select only "PostingTo" aspect Then I should see "I am eating a yogurt" When I am on the aspects page - And I follow "Deselect all" within "#aspect_nav" - And I follow "NotPostingThingsHere" within "#aspect_nav" - And I wait for the ajax to finish + And I select only "NotPostingThingsHere" aspect Then I should not see "I am eating a yogurt" diff --git a/features/step_definitions/aspects_steps.rb b/features/step_definitions/aspects_steps.rb index 9c0bc66c0..ba490c9bd 100644 --- a/features/step_definitions/aspects_steps.rb +++ b/features/step_definitions/aspects_steps.rb @@ -7,8 +7,23 @@ end When /^I select only "([^"]*)" aspect$/ do |aspect_name| within('#aspect_nav') do + click_link 'Select all' if has_link? 'Select all' click_link 'Deselect all' click_link aspect_name end And %{I wait for the ajax to finish} end + +When /^I should see "([^"]*)" aspect selected$/ do |aspect_name| + aspect = @me.aspects.where(:name => aspect_name).first + within("#aspect_nav") do + page.has_css?("li.active[data-aspect_id='#{aspect.id}']").should be_true + end +end + +When /^I should see "([^"]*)" aspect unselected$/ do |aspect_name| + aspect = @me.aspects.where(:name => aspect_name).first + within("#aspect_nav") do + page.has_css?("li[data-aspect_id='#{aspect.id}']:not(.active)").should be_true + end +end diff --git a/public/javascripts/widgets/aspect-navigation.js b/public/javascripts/widgets/aspect-navigation.js index 144f3e7cf..786f08934 100644 --- a/public/javascripts/widgets/aspect-navigation.js +++ b/public/javascripts/widgets/aspect-navigation.js @@ -100,11 +100,11 @@ self.abortAjax(); self.fadeOut(); - if (typeof(history.pushState) == 'function') { - history.pushState(null, document.title, newURL); - } - self.jXHR = $.getScript(newURL, function(data) { + if (typeof(history.pushState) == 'function') { + history.pushState(null, document.title, newURL); + } + var textarea = $("#publisher textarea#status_message_fake_text"), photozone = $("#photodropzone");