about summary refs log tree commit diff
path: root/spec/controllers/application_controller_spec.rb
diff options
context:
space:
mode:
authorAkihiko Odaki <akihiko.odaki.4i@stu.hosei.ac.jp>2017-05-22 13:00:07 +0900
committerEugen Rochko <eugen@zeonfederated.com>2017-05-22 06:00:06 +0200
commitaa662cecada500b57d8959f311a2a74e41e6211a (patch)
tree390049deaaf607c4243c1c990b77fab93bf0b965 /spec/controllers/application_controller_spec.rb
parent84608c3ff8fe51654868546cca6e64730d06286e (diff)
single_user_mode? always returns boolean (#3215)
This change also adds a specification for the method.
Diffstat (limited to 'spec/controllers/application_controller_spec.rb')
-rw-r--r--spec/controllers/application_controller_spec.rb24
1 files changed, 24 insertions, 0 deletions
diff --git a/spec/controllers/application_controller_spec.rb b/spec/controllers/application_controller_spec.rb
new file mode 100644
index 000000000..44830e12b
--- /dev/null
+++ b/spec/controllers/application_controller_spec.rb
@@ -0,0 +1,24 @@
+# frozen_string_literal: true
+
+require 'rails_helper'
+
+describe ApplicationController do
+  describe 'helper_method :single_user_mode?' do
+    it 'returns false if it is in single_user_mode but there is no account' do
+      allow(Rails.configuration.x).to receive(:single_user_mode).and_return(true)
+      expect(controller.view_context.single_user_mode?).to eq false
+    end
+
+    it 'returns false if there is an account but it is not in single_user_mode' do
+      allow(Rails.configuration.x).to receive(:single_user_mode).and_return(false)
+      Fabricate(:account)
+      expect(controller.view_context.single_user_mode?).to eq false
+    end
+
+    it 'returns true if it is in single_user_mode and there is an account' do
+      allow(Rails.configuration.x).to receive(:single_user_mode).and_return(true)
+      Fabricate(:account)
+      expect(controller.view_context.single_user_mode?).to eq true
+    end
+  end
+end