Remember last selected aspects through the session

This commit is contained in:
Gonzalo Rodriguez 2011-10-09 01:49:47 -02:00
parent c8bc7349ad
commit 6b5928ca09
5 changed files with 51 additions and 11 deletions

View file

@ -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

View file

@ -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

View file

@ -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"

View file

@ -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

View file

@ -100,11 +100,11 @@
self.abortAjax();
self.fadeOut();
self.jXHR = $.getScript(newURL, function(data) {
if (typeof(history.pushState) == 'function') {
history.pushState(null, document.title, newURL);
}
self.jXHR = $.getScript(newURL, function(data) {
var textarea = $("#publisher textarea#status_message_fake_text"),
photozone = $("#photodropzone");