Requires user to be signed in when changing notification settings

parent 93a10f17
class Groups::NotificationSettingsController < Groups::ApplicationController class Groups::NotificationSettingsController < Groups::ApplicationController
before_action :authenticate_user!
def update def update
notification_setting = current_user.notification_settings_for(group) notification_setting = current_user.notification_settings_for(group)
saved = notification_setting.update_attributes(notification_setting_params) saved = notification_setting.update_attributes(notification_setting_params)
......
class Projects::NotificationSettingsController < Projects::ApplicationController class Projects::NotificationSettingsController < Projects::ApplicationController
before_action :authenticate_user!
def create def create
notification_setting = current_user.notification_settings_for(project) notification_setting = current_user.notification_settings_for(project)
saved = notification_setting.update_attributes(notification_setting_params) saved = notification_setting.update_attributes(notification_setting_params)
......
require 'spec_helper'
describe Groups::NotificationSettingsController do
let(:group) { create(:group) }
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: NotificationSetting.levels[:participating] }
expect(response).to redirect_to(new_user_session_path)
end
end
end
end
require 'spec_helper'
describe Projects::NotificationSettingsController do
let(:project) { create(:empty_project) }
describe '#create' do
context 'when not authorized' do
it 'redirects to sign in page' do
post :create,
namespace_id: project.namespace.to_param,
project_id: project.to_param,
notification_setting: { level: NotificationSetting.levels[:participating] }
expect(response).to redirect_to(new_user_session_path)
end
end
end
describe '#update' do
context 'when not authorized' do
it 'redirects to sign in page' do
put :update,
namespace_id: project.namespace.to_param,
project_id: project.to_param,
notification_setting: { level: NotificationSetting.levels[:participating] }
expect(response).to redirect_to(new_user_session_path)
end
end
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment