Skip to content
Snippets Groups Projects
Commit e616fbfd authored by Lin Jen-Shin's avatar Lin Jen-Shin
Browse files

Only return the address if incoming emails is enabled:

parent 918646f8
No related branches found
No related tags found
1 merge request!3363Implement #3243 New Issue by email
Loading
Loading
@@ -529,9 +529,11 @@ class Project < ActiveRecord::Base
end
 
def new_issue_address(author)
if Gitlab::IncomingEmail.enabled?
Gitlab::IncomingEmail.reply_address(
"#{path_with_namespace}+#{author.authentication_token}")
end
end
 
def build_commit_note(commit)
notes.new(commit_id: commit.id, noteable_type: 'Commit')
Loading
Loading
Loading
Loading
@@ -130,13 +130,14 @@ describe Project, models: true do
end
 
describe "#new_issue_address" do
before do
stub_incoming_email_setting(address: "p+%{key}@gl.ab")
end
let(:project) { create(:empty_project, path: "somewhere") }
let(:user) { create(:user) }
 
context 'incoming email enabled' do
before do
stub_incoming_email_setting(enabled: true, address: "p+%{key}@gl.ab")
end
it 'returns the address to create a new issue' do
token = user.authentication_token
address = "p+#{project.namespace.path}/#{project.path}+#{token}@gl.ab"
Loading
Loading
@@ -145,6 +146,17 @@ describe Project, models: true do
end
end
 
context 'incoming email disabled' do
before do
stub_incoming_email_setting(enabled: false)
end
it 'returns nil' do
expect(project.new_issue_address(user)).to be_nil
end
end
end
describe 'last_activity methods' do
let(:project) { create(:project) }
let(:last_event) { double(created_at: Time.now) }
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment