From f5337fcb5907dcbd5c936ca7b0237d7caad8bccc Mon Sep 17 00:00:00 2001 From: Maximilian Grundke Date: Mon, 7 May 2018 17:17:56 +0200 Subject: [PATCH] Add tests for statistics controller routes --- .../controllers/statistics_controller_spec.rb | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 spec/controllers/statistics_controller_spec.rb diff --git a/spec/controllers/statistics_controller_spec.rb b/spec/controllers/statistics_controller_spec.rb new file mode 100644 index 00000000..c193315d --- /dev/null +++ b/spec/controllers/statistics_controller_spec.rb @@ -0,0 +1,34 @@ +require 'rails_helper' + +describe StatisticsController do + let(:user) { FactoryBot.create(:admin) } + before(:each) { allow(controller).to receive(:current_user).and_return(user) } + + [:show, :graphs].each do |route| + describe "GET ##{route}" do + before(:each) { get route } + + expect_status(200) + expect_template(route) + end + end + + [:user_activity_history, :rfc_activity_history].each do |route| + describe "GET ##{route}" do + before(:each) { get route } + + expect_status(200) + expect_template(:activity_history) + end + end + + [:show, :user_activity, :user_activity_history, :rfc_activity, :rfc_activity_history].each do |route| + describe "GET ##{route}.json" do + before(:each) { get route, format: :json } + + expect_status(200) + expect_json + end + end + +end