summaryrefslogtreecommitdiff
path: root/spec/controllers/groups/notification_settings_controller_spec.rb
blob: 0786e45515a51c637970e54ab0c86233130ec215 (plain)
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
require 'spec_helper'

describe Groups::NotificationSettingsController do
  let(:group) { create(:group) }
  let(:user) { create(:user) }

  describe '#update' do
    context 'when not authorized' do
      it 'redirects to sign in page' do
        put :update,
            group_id: group.to_param,
            notification_setting: { level: :participating }

        expect(response).to redirect_to(new_user_session_path)
      end
    end

    context 'when authorized' do
      before do
        sign_in(user)
      end

      it 'returns success' do
        put :update,
            group_id: group.to_param,
            notification_setting: { level: :participating }

        expect(response.status).to eq 200
      end
    end
  end
end