Merge branch 'jej-backport-authorless-fix' into 'master'
Prevents error on nil author from Issuable author_name See merge request !10112
This commit is contained in:
commit
0b71dbcc2e
2 changed files with 29 additions and 0 deletions
|
@ -50,6 +50,7 @@ module Issuable
|
|||
:email,
|
||||
:public_email,
|
||||
to: :author,
|
||||
allow_nil: true,
|
||||
prefix: true
|
||||
|
||||
delegate :name,
|
||||
|
|
|
@ -44,6 +44,34 @@ describe Issue, "Issuable" do
|
|||
it { expect(described_class).to respond_to(:assigned) }
|
||||
end
|
||||
|
||||
describe 'author_name' do
|
||||
it 'is delegated to author' do
|
||||
expect(issue.author_name).to eq issue.author.name
|
||||
end
|
||||
|
||||
it 'returns nil when author is nil' do
|
||||
issue.author_id = nil
|
||||
issue.save(validate: false)
|
||||
|
||||
expect(issue.author_name).to eq nil
|
||||
end
|
||||
end
|
||||
|
||||
describe 'assignee_name' do
|
||||
it 'is delegated to assignee' do
|
||||
issue.update!(assignee: create(:user))
|
||||
|
||||
expect(issue.assignee_name).to eq issue.assignee.name
|
||||
end
|
||||
|
||||
it 'returns nil when assignee is nil' do
|
||||
issue.assignee_id = nil
|
||||
issue.save(validate: false)
|
||||
|
||||
expect(issue.assignee_name).to eq nil
|
||||
end
|
||||
end
|
||||
|
||||
describe "before_save" do
|
||||
describe "#update_cache_counts" do
|
||||
context "when previous assignee exists" do
|
||||
|
|
Loading…
Reference in a new issue