mirror of
https://github.com/mastodon/mastodon.git
synced 2024-12-22 17:17:32 +00:00
single_user_mode? always returns boolean (#3215)
This change also adds a specification for the method.
This commit is contained in:
parent
84608c3ff8
commit
aa662cecad
|
@ -61,7 +61,7 @@ class ApplicationController < ActionController::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
def single_user_mode?
|
def single_user_mode?
|
||||||
@single_user_mode ||= Rails.configuration.x.single_user_mode && Account.first
|
@single_user_mode ||= Rails.configuration.x.single_user_mode && Account.any?
|
||||||
end
|
end
|
||||||
|
|
||||||
def current_account
|
def current_account
|
||||||
|
|
24
spec/controllers/application_controller_spec.rb
Normal file
24
spec/controllers/application_controller_spec.rb
Normal file
|
@ -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
|
Loading…
Reference in a new issue