diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-03-04 12:08:20 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-03-04 12:08:20 +0300 |
commit | d80f3cd75e700b6e62910865bfd36734644ffa89 (patch) | |
tree | aa2fa2f2b4385854c13591bef8e74924ef661657 /spec/models | |
parent | be81c1578d65f25edfde8aa550f190b8d3e6d976 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/models')
-rw-r--r-- | spec/models/issue_spec.rb | 35 | ||||
-rw-r--r-- | spec/models/resource_weight_event_spec.rb | 2 |
2 files changed, 33 insertions, 4 deletions
diff --git a/spec/models/issue_spec.rb b/spec/models/issue_spec.rb index dd1588036b6..66b298bb36f 100644 --- a/spec/models/issue_spec.rb +++ b/spec/models/issue_spec.rb @@ -425,16 +425,16 @@ describe Issue do let(:issue) { create(:issue, title: 'testing-issue') } it 'starts with the issue iid' do - expect(issue.to_branch_name).to match /\A#{issue.iid}-[A-Za-z\-]+\z/ + expect(issue.to_branch_name).to match(/\A#{issue.iid}-[A-Za-z\-]+\z/) end it "contains the issue title if not confidential" do - expect(issue.to_branch_name).to match /testing-issue\z/ + expect(issue.to_branch_name).to match(/testing-issue\z/) end it "does not contain the issue title if confidential" do issue = create(:issue, title: 'testing-issue', confidential: true) - expect(issue.to_branch_name).to match /confidential-issue\z/ + expect(issue.to_branch_name).to match(/confidential-issue\z/) end context 'issue title longer than 100 characters' do @@ -932,4 +932,33 @@ describe Issue do end it_behaves_like 'versioned description' + + describe "#previous_updated_at" do + let_it_be(:updated_at) { Time.new(2012, 01, 06) } + let_it_be(:issue) { create(:issue, updated_at: updated_at) } + + it 'returns updated_at value if updated_at did not change at all' do + allow(issue).to receive(:previous_changes).and_return({}) + + expect(issue.previous_updated_at).to eq(updated_at) + end + + it 'returns updated_at value if `previous_changes` has nil value for `updated_at`' do + allow(issue).to receive(:previous_changes).and_return({ 'updated_at' => nil }) + + expect(issue.previous_updated_at).to eq(updated_at) + end + + it 'returns updated_at value if previous updated_at value is not present' do + allow(issue).to receive(:previous_changes).and_return({ 'updated_at' => [nil, Time.new(2013, 02, 06)] }) + + expect(issue.previous_updated_at).to eq(updated_at) + end + + it 'returns previous updated_at when present' do + allow(issue).to receive(:previous_changes).and_return({ 'updated_at' => [Time.new(2013, 02, 06), Time.new(2013, 03, 06)] }) + + expect(issue.previous_updated_at).to eq(Time.new(2013, 02, 06)) + end + end end diff --git a/spec/models/resource_weight_event_spec.rb b/spec/models/resource_weight_event_spec.rb index 11b633e1dcf..8a37883d933 100644 --- a/spec/models/resource_weight_event_spec.rb +++ b/spec/models/resource_weight_event_spec.rb @@ -67,7 +67,7 @@ RSpec.describe ResourceWeightEvent, type: :model do it 'returns the expected id' do allow(Digest::SHA1).to receive(:hexdigest) - .with("ResourceWeightEvent-2019-12-30 00:00:00 UTC-#{user1.id}") + .with("ResourceWeightEvent-#{event.id}-#{user1.id}") .and_return('73d167c478') expect(event.discussion_id).to eq('73d167c478') |