about summary refs log tree commit diff
path: root/spec
diff options
context:
space:
mode:
authorThibG <thib@sitedethib.com>2018-08-26 13:23:52 +0200
committerGitHub <noreply@github.com>2018-08-26 13:23:52 +0200
commit2903f8f36b7c41b77de4ad6c8c5b0a6c0b2a7ace (patch)
tree4c8d12cc031476870a918bec3b3000f899101a32 /spec
parent0ddf439999b05b5dfd6d5a5257327fa7d3565e65 (diff)
parent246c313d457397f412f9fb5eed3ee02cf5d9a561 (diff)
Merge pull request #671 from ThibG/glitch-soc/merge-upstream
Merge upstream changes
Diffstat (limited to 'spec')
-rw-r--r--spec/controllers/application_controller_spec.rb37
-rw-r--r--spec/models/user_spec.rb2
2 files changed, 38 insertions, 1 deletions
diff --git a/spec/controllers/application_controller_spec.rb b/spec/controllers/application_controller_spec.rb
index c6c78d3f7..2603688be 100644
--- a/spec/controllers/application_controller_spec.rb
+++ b/spec/controllers/application_controller_spec.rb
@@ -92,6 +92,43 @@ describe ApplicationController, type: :controller do
     end
   end
 
+  describe 'helper_method :current_flavour' do
+    it 'returns "glitch" when theme wasn\'t changed in admin settings' do
+      allow(Setting).to receive(:default_settings).and_return({'skin' => 'default'})
+      allow(Setting).to receive(:default_settings).and_return({'flavour' => 'glitch'})
+
+      expect(controller.view_context.current_flavour).to eq 'glitch'
+    end
+
+    it 'returns instances\'s flavour when user is not signed in' do
+      allow(Setting).to receive(:[]).with('skin').and_return 'default'
+      allow(Setting).to receive(:[]).with('flavour').and_return 'vanilla'
+
+      expect(controller.view_context.current_flavour).to eq 'vanilla'
+    end
+
+    it 'returns instances\'s default flavour when user didn\'t set theme' do
+      current_user = Fabricate(:user)
+      sign_in current_user
+
+      allow(Setting).to receive(:[]).with('skin').and_return 'default'
+      allow(Setting).to receive(:[]).with('flavour').and_return 'vanilla'
+
+      expect(controller.view_context.current_flavour).to eq 'vanilla'
+    end
+
+    it 'returns user\'s flavour when it is set' do
+      current_user = Fabricate(:user)
+      current_user.settings['flavour'] = 'glitch'
+      sign_in current_user
+
+      allow(Setting).to receive(:[]).with('skin').and_return 'default'
+      allow(Setting).to receive(:[]).with('flavour').and_return 'vanilla'
+
+      expect(controller.view_context.current_flavour).to eq 'glitch'
+    end
+  end
+
   context 'ActionController::RoutingError' do
     subject do
       routes.draw { get 'routing_error' => 'anonymous#routing_error' }
diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb
index 93a6c26fb..015e90edc 100644
--- a/spec/models/user_spec.rb
+++ b/spec/models/user_spec.rb
@@ -512,7 +512,7 @@ RSpec.describe User, type: :model do
       context 'when user is confirmed' do
         let(:confirmed_at) { Time.zone.now }
 
-        it { is_expected.to be false }
+        it { is_expected.to be true }
       end
 
       context 'when user is not confirmed' do