From 85210589cbb85e62f8cf3551110895c8eb13e164 Mon Sep 17 00:00:00 2001 From: Andreas Nedbal Date: Sun, 3 Oct 2021 21:26:46 +0200 Subject: [PATCH] add test case for user count on about page --- spec/controllers/static_controller_spec.rb | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 spec/controllers/static_controller_spec.rb diff --git a/spec/controllers/static_controller_spec.rb b/spec/controllers/static_controller_spec.rb new file mode 100644 index 00000000..02b08787 --- /dev/null +++ b/spec/controllers/static_controller_spec.rb @@ -0,0 +1,21 @@ +# frozen_string_literal: true + +require "rails_helper" + +describe StaticController, type: :controller do + describe "#about" do + subject { get :about } + + before(:each) { + User.create(screen_name: 'very_valid_user', confirmed_at: Time.now, answered_count: 1, asked_count: 1) + User.create(screen_name: 'big_ben', permanently_banned: true) + User.create(screen_name: 'youre_mom', banned_until: Time.now + 10.days) + User.create(screen_name: 'silence_fox', confirmed_at: Time.now) + } + + it "shows the correct user count" do + subject + expect(assigns(:users)).to eq(1) + end + end +end \ No newline at end of file