Commit 1c9cd1cbdf102644c1f3a1463d0d281841ae4b95
1 parent
1a384d81
Exists in
master
and in
29 other branches
Fix HTTP caching scheme
(ActionItem2357)
Showing
4 changed files
with
18 additions
and
1 deletions
Show diff stats
features/session_and_cookies_handling.feature
@@ -16,6 +16,15 @@ Feature: session and cookies handling | @@ -16,6 +16,15 @@ Feature: session and cookies handling | ||
16 | When I go to the homepage | 16 | When I go to the homepage |
17 | Then there must be no cookies | 17 | Then there must be no cookies |
18 | 18 | ||
19 | + Scenario: user_data, not logged in | ||
20 | + When I make a AJAX request to the user data path | ||
21 | + Then there must be no cookies | ||
22 | + | ||
23 | + Scenario: user_data, logged in | ||
24 | + Given I am logged in as admin | ||
25 | + When I make a AJAX request to the user data path | ||
26 | + Then there must be a cookie "_noosfero_session" | ||
27 | + | ||
19 | # FIXME for some reason I could not test this scenario, although manual tests | 28 | # FIXME for some reason I could not test this scenario, although manual tests |
20 | # indicate this works! | 29 | # indicate this works! |
21 | # Scenario: logout | 30 | # Scenario: logout |
features/step_definitions/noosfero_steps.rb
@@ -576,3 +576,8 @@ end | @@ -576,3 +576,8 @@ end | ||
576 | Given /^the cache is turned (on|off)$/ do |state| | 576 | Given /^the cache is turned (on|off)$/ do |state| |
577 | ActionController::Base.perform_caching = (state == 'on') | 577 | ActionController::Base.perform_caching = (state == 'on') |
578 | end | 578 | end |
579 | + | ||
580 | +When /^I make a AJAX request to (.*)$/ do |page| | ||
581 | + header 'X-Requested-With', 'XMLHttpRequest' | ||
582 | + visit(path_to(page)) | ||
583 | +end |
features/support/paths.rb
@@ -96,6 +96,9 @@ module NavigationHelpers | @@ -96,6 +96,9 @@ module NavigationHelpers | ||
96 | when /^chat$/ | 96 | when /^chat$/ |
97 | '/chat' | 97 | '/chat' |
98 | 98 | ||
99 | + when /the user data path/ | ||
100 | + '/account/user_data' | ||
101 | + | ||
99 | # Add more mappings here. | 102 | # Add more mappings here. |
100 | # Here is a more fancy example: | 103 | # Here is a more fancy example: |
101 | # | 104 | # |
vendor/plugins/noosfero_caching/init.rb
@@ -27,7 +27,7 @@ module NoosferoHttpCaching | @@ -27,7 +27,7 @@ module NoosferoHttpCaching | ||
27 | end | 27 | end |
28 | 28 | ||
29 | def noosfero_session_check | 29 | def noosfero_session_check |
30 | - return if params[:controller] == 'account' || request.xhr? | 30 | + return if (params[:controller] == 'account' && params[:action] != 'user_data') |
31 | headers["X-Noosfero-Auth"] = (session[:user] != nil).to_s | 31 | headers["X-Noosfero-Auth"] = (session[:user] != nil).to_s |
32 | end | 32 | end |
33 | 33 |