Remember last selected aspects through the session
This commit is contained in:
parent
c8bc7349ad
commit
6b5928ca09
5 changed files with 51 additions and 11 deletions
|
|
@ -7,6 +7,7 @@ require File.join(Rails.root, "lib", 'stream', "aspect_stream")
|
||||||
class AspectsController < ApplicationController
|
class AspectsController < ApplicationController
|
||||||
before_filter :authenticate_user!
|
before_filter :authenticate_user!
|
||||||
before_filter :save_sort_order, :only => :index
|
before_filter :save_sort_order, :only => :index
|
||||||
|
before_filter :save_selected_aspects, :only => :index
|
||||||
before_filter :ensure_page, :only => :index
|
before_filter :ensure_page, :only => :index
|
||||||
|
|
||||||
respond_to :html, :js
|
respond_to :html, :js
|
||||||
|
|
@ -15,7 +16,7 @@ class AspectsController < ApplicationController
|
||||||
helper_method :selected_people
|
helper_method :selected_people
|
||||||
|
|
||||||
def index
|
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,
|
@stream = AspectStream.new(current_user, aspect_ids,
|
||||||
:order => sort_order,
|
:order => sort_order,
|
||||||
:max_time => params[:max_time].to_i)
|
:max_time => params[:max_time].to_i)
|
||||||
|
|
@ -138,4 +139,10 @@ class AspectsController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
|
def save_selected_aspects
|
||||||
|
if params[:a_ids].present?
|
||||||
|
session[:a_ids] = params[:a_ids]
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
22
features/aspect_navigation.feature
Normal file
22
features/aspect_navigation.feature
Normal 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
|
||||||
|
|
@ -50,13 +50,9 @@ Feature: mentioning a contact from their profile page
|
||||||
And I press "Share" in the modal window
|
And I press "Share" in the modal window
|
||||||
|
|
||||||
When I am on the aspects page
|
When I am on the aspects page
|
||||||
And I follow "Deselect all" within "#aspect_nav"
|
And I select only "PostingTo" aspect
|
||||||
And I follow "PostingTo" within "#aspect_nav"
|
|
||||||
And I wait for the ajax to finish
|
|
||||||
Then I should see "I am eating a yogurt"
|
Then I should see "I am eating a yogurt"
|
||||||
|
|
||||||
When I am on the aspects page
|
When I am on the aspects page
|
||||||
And I follow "Deselect all" within "#aspect_nav"
|
And I select only "NotPostingThingsHere" aspect
|
||||||
And I follow "NotPostingThingsHere" within "#aspect_nav"
|
|
||||||
And I wait for the ajax to finish
|
|
||||||
Then I should not see "I am eating a yogurt"
|
Then I should not see "I am eating a yogurt"
|
||||||
|
|
|
||||||
|
|
@ -7,8 +7,23 @@ end
|
||||||
|
|
||||||
When /^I select only "([^"]*)" aspect$/ do |aspect_name|
|
When /^I select only "([^"]*)" aspect$/ do |aspect_name|
|
||||||
within('#aspect_nav') do
|
within('#aspect_nav') do
|
||||||
|
click_link 'Select all' if has_link? 'Select all'
|
||||||
click_link 'Deselect all'
|
click_link 'Deselect all'
|
||||||
click_link aspect_name
|
click_link aspect_name
|
||||||
end
|
end
|
||||||
And %{I wait for the ajax to finish}
|
And %{I wait for the ajax to finish}
|
||||||
end
|
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
|
||||||
|
|
|
||||||
|
|
@ -100,11 +100,11 @@
|
||||||
self.abortAjax();
|
self.abortAjax();
|
||||||
self.fadeOut();
|
self.fadeOut();
|
||||||
|
|
||||||
if (typeof(history.pushState) == 'function') {
|
|
||||||
history.pushState(null, document.title, newURL);
|
|
||||||
}
|
|
||||||
|
|
||||||
self.jXHR = $.getScript(newURL, function(data) {
|
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"),
|
var textarea = $("#publisher textarea#status_message_fake_text"),
|
||||||
photozone = $("#photodropzone");
|
photozone = $("#photodropzone");
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue