diff --git a/app/controllers/stats_controller.rb b/app/controllers/stats_controller.rb index 8c5afdb341..b0b89e1115 100644 --- a/app/controllers/stats_controller.rb +++ b/app/controllers/stats_controller.rb @@ -1,4 +1,6 @@ class StatsController < ApplicationController + before_action :require_user, only: %i(index range notes wikis users questions comments tags) + def subscriptions @tags = Rails.cache.fetch("stats-subscriptions-query", expires_in: 24.hours) do TagSelection diff --git a/test/functional/stats_controller_test.rb b/test/functional/stats_controller_test.rb index 4a4d477e0b..2a5f02cd07 100644 --- a/test/functional/stats_controller_test.rb +++ b/test/functional/stats_controller_test.rb @@ -6,9 +6,11 @@ def setup @start = 1.month.ago @end = Date.today @stats = [:notes, :comments, :users, :wikis, :questions, :answers, :tags, :node_tags] + activate_authlogic end test 'should assign correct value to graph_notes on GET stats' do + UserSession.create(users(:bob)) # we now require login for this page for load reasons Node.delete_all Node.create!(type: 'note', title:'blah', uid: 1, status: 1) get :index, params: { start: @start.to_s, end: @end.to_s } @@ -16,6 +18,7 @@ def setup end test 'should assign correct value to graph_wikis on GET stats' do + UserSession.create(users(:bob)) # we now require login for this page for load reasons Node.delete_all Node.create(type: 'note', title: 'blah', uid: 1, status: 1) Node.create(type: 'page', title: 'blahblah', uid: 1, status: 1) @@ -24,6 +27,7 @@ def setup end test 'should assign correct value to graph_comments on GET stats' do + UserSession.create(users(:bob)) # we now require login for this page for load reasons Comment.delete_all Comment.create!(comment: 'blah', timestamp: Time.now - 1) get :index, params: { start: @start.to_s, end: @end.to_s } @@ -32,6 +36,7 @@ def setup end test 'should load stats range query' do + UserSession.create(users(:bob)) # we now require login for this page for load reasons get :index assert_response :success assert_not_nil assigns(:notes) @@ -48,6 +53,7 @@ def setup end def csv_stats_download + UserSession.create(users(:bob)) # we now require login for this page for load reasons @stats.each do |action| test "should download #{action} as csv" do get action, params: { format: 'csv' } @@ -59,6 +65,7 @@ def csv_stats_download end def json_stats_downloads + UserSession.create(users(:bob)) # we now require login for this page for load reasons @stats.each do |action| test "should download #{action} as json" do get action, params: { format: 'json' } diff --git a/test/integration/I18n_test.rb b/test/integration/I18n_test.rb index 1ba4f95dc9..f356de07d8 100644 --- a/test/integration/I18n_test.rb +++ b/test/integration/I18n_test.rb @@ -500,6 +500,16 @@ class I18nTest < ActionDispatch::IntegrationTest available_testing_locales.each do |lang| get '/change_locale/' + lang.to_s follow_redirect! + + post '/user_sessions', + params: { + user_session: { + username: users(:jeff).username, + password: 'secretive' + } + } + follow_redirect! + start_time = 1.month.ago end_time = Date.today @graph_notes = Node.contribution_graph_making('note', start_time.to_time, end_time.to_time) diff --git a/test/integration/public_pages_test.rb b/test/integration/public_pages_test.rb index 8f22a563c8..09d9b30f0c 100644 --- a/test/integration/public_pages_test.rb +++ b/test/integration/public_pages_test.rb @@ -75,11 +75,6 @@ def setup assert_redirected_to '/search?q=foo' end - test 'browse /stats' do - get '/stats' - assert_response :success - end - test 'browse redirected node' do get nodes(:redirect).path assert_response :redirect