mirror of
https://github.com/wahyd4/gitlabhq.git
synced 2026-08-18 17:16:08 +10:00
Improve specs for group/project notification controller
This commit is contained in:
@@ -2,16 +2,31 @@ 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: NotificationSetting.levels[:participating] }
|
||||
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
|
||||
|
||||
@@ -2,6 +2,11 @@ require 'spec_helper'
|
||||
|
||||
describe Projects::NotificationSettingsController do
|
||||
let(:project) { create(:empty_project) }
|
||||
let(:user) { create(:user) }
|
||||
|
||||
before do
|
||||
project.team << [user, :developer]
|
||||
end
|
||||
|
||||
describe '#create' do
|
||||
context 'when not authorized' do
|
||||
@@ -9,11 +14,26 @@ describe Projects::NotificationSettingsController do
|
||||
post :create,
|
||||
namespace_id: project.namespace.to_param,
|
||||
project_id: project.to_param,
|
||||
notification_setting: { level: NotificationSetting.levels[:participating] }
|
||||
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
|
||||
post :create,
|
||||
namespace_id: project.namespace.to_param,
|
||||
project_id: project.to_param,
|
||||
notification_setting: { level: :participating }
|
||||
|
||||
expect(response.status).to eq 200
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe '#update' do
|
||||
@@ -22,10 +42,25 @@ describe Projects::NotificationSettingsController do
|
||||
put :update,
|
||||
namespace_id: project.namespace.to_param,
|
||||
project_id: project.to_param,
|
||||
notification_setting: { level: NotificationSetting.levels[:participating] }
|
||||
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,
|
||||
namespace_id: project.namespace.to_param,
|
||||
project_id: project.to_param,
|
||||
notification_setting: { level: :participating }
|
||||
|
||||
expect(response.status).to eq 200
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user