Add Project#new_issue_address(author):

Which would return the email address for creating a new issue
by sending an email to that particular address.
This commit is contained in:
Lin Jen-Shin 2016-06-23 18:36:44 +08:00
parent 176fa21cb7
commit 918646f8e9
2 changed files with 21 additions and 0 deletions

View File

@ -528,6 +528,11 @@ class Project < ActiveRecord::Base
web_url.split('://')[1]
end
def new_issue_address(author)
Gitlab::IncomingEmail.reply_address(
"#{path_with_namespace}+#{author.authentication_token}")
end
def build_commit_note(commit)
notes.new(commit_id: commit.id, noteable_type: 'Commit')
end

View File

@ -129,6 +129,22 @@ describe Project, models: true do
end
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) }
it 'returns the address to create a new issue' do
token = user.authentication_token
address = "p+#{project.namespace.path}/#{project.path}+#{token}@gl.ab"
expect(project.new_issue_address(user)).to eq(address)
end
end
describe 'last_activity methods' do
let(:project) { create(:project) }
let(:last_event) { double(created_at: Time.now) }