about summary refs log tree commit diff
path: root/spec/controllers/settings/flavours_controller_spec.rb
blob: f89bde1f96fd28bf50b89cdea30852fc75c5a4ee (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# frozen_string_literal: true
require 'rails_helper'

RSpec.describe Settings::FlavoursController, type: :controller do
  let(:user) { Fabricate(:user) }

  before do
    sign_in user, scope: :user
  end

  describe 'PUT #update' do
    describe 'without a user[setting_skin] parameter' do
      it 'sets the selected flavour' do
        put :update, params: { flavour: 'schnozzberry' }

        user.reload

        expect(user.setting_flavour).to eq 'schnozzberry'
      end
    end

    describe 'with a user[setting_skin] parameter' do
      before do
        put :update, params: { flavour: 'schnozzberry', user: { setting_skin: 'wallpaper' } }

        user.reload
      end

      it 'sets the selected flavour' do
        expect(user.setting_flavour).to eq 'schnozzberry'
      end

      it 'sets the selected skin' do
        expect(user.setting_skin).to eq 'wallpaper'
      end
    end
  end
end