Commit c2c7014e authored by Felipe Artur's avatar Felipe Artur

Improve documentation and add changelog

parent 07ff874f
......@@ -101,11 +101,7 @@ class ProjectsController < Projects::ApplicationController
respond_to do |format|
format.html do
if current_user
if can?(current_user, :read_project, @project)
@notification_setting = current_user.notification_settings_for(@project)
end
end
@notification_setting = current_user.notification_settings_for(@project) if current_user
if @project.repository_exists?
if @project.empty_repo?
......
......@@ -777,11 +777,10 @@ class User < ActiveRecord::Base
end
def notification_settings_for(source)
notification_setting = notification_settings.find_or_initialize_by({ source: source })
notification_setting = notification_settings.find_or_initialize_by(source: source)
if source.is_a?(Project)
membership = source.team.find_member(self.id)
notification_setting.level = :disabled unless membership.present? || notification_setting.persisted?
if source.is_a?(Project) && !source.team.member?(id) && !notification_setting.persisted?
notification_setting.level = :disabled
end
notification_setting
......
......@@ -106,6 +106,35 @@ describe NotificationService, services: true do
should_not_email(@u_disabled)
end
end
context 'when user is not project member' do
let(:user) { create(:user) }
let(:project) { create(:empty_project, :public) }
let(:issue) { create(:issue, project: project, assignee: create(:user)) }
let(:note) { create(:note_on_issue, noteable: issue, project_id: issue.project_id, note: 'anything') }
before { ActionMailer::Base.deliveries.clear }
context "and has notification setting" do
before do
setting = user.notification_settings_for(project)
setting.level = :watch
setting.save
end
it "sends user email" do
notification.new_note(note)
should_email(user)
end
end
context "and does note have notification setting" do
it "does not send email" do
notification.new_note(note)
should_not_email(user)
end
end
end
end
context 'confidential issue note' do
......@@ -147,7 +176,6 @@ describe NotificationService, services: true do
before do
build_team(note.project)
note.project.team << [[note.author, note.noteable.author, note.noteable.assignee], :master]
ActionMailer::Base.deliveries.clear
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