diff options
author | Lin Jen-Shin <godfat@godfat.org> | 2016-06-23 18:36:44 +0800 |
---|---|---|
committer | Lin Jen-Shin <godfat@godfat.org> | 2016-06-23 18:36:44 +0800 |
commit | 918646f8e9daa954d25f122f866bd675c1278c42 (patch) | |
tree | f24be3acc0ec8411ad959cf8264a60c351922bd4 | |
parent | 176fa21cb75f404b401e021f0cdcc6a138c207eb (diff) | |
download | gitlab-ce-918646f8e9daa954d25f122f866bd675c1278c42.tar.gz |
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.
-rw-r--r-- | app/models/project.rb | 5 | ||||
-rw-r--r-- | spec/models/project_spec.rb | 16 |
2 files changed, 21 insertions, 0 deletions
diff --git a/app/models/project.rb b/app/models/project.rb index 0d2e612436a..822d6489112 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -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 diff --git a/spec/models/project_spec.rb b/spec/models/project_spec.rb index 30aa2b70c8d..407efc9f966 100644 --- a/spec/models/project_spec.rb +++ b/spec/models/project_spec.rb @@ -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) } |