diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-06-30 09:10:05 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-06-30 09:10:05 +0000 |
commit | 312ac59328577a230a049eb71c56f648508d209f (patch) | |
tree | a8aab96504d3062ee18c08176d36d6073711ccb8 /spec/views | |
parent | e6f10cb4b38644d88a2e0016af206d2eb68a25d8 (diff) | |
download | gitlab-ce-312ac59328577a230a049eb71c56f648508d209f.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/views')
-rw-r--r-- | spec/views/projects/issues/_issue.html.haml_spec.rb | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/spec/views/projects/issues/_issue.html.haml_spec.rb b/spec/views/projects/issues/_issue.html.haml_spec.rb new file mode 100644 index 00000000000..29bef557304 --- /dev/null +++ b/spec/views/projects/issues/_issue.html.haml_spec.rb @@ -0,0 +1,44 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe 'projects/issues/_issue.html.haml' do + before do + assign(:project, issue.project) + assign(:issuable_meta_data, { + issue.id => Gitlab::IssuableMetadata::IssuableMeta.new(1, 1, 1, 1) + }) + + render partial: 'projects/issues/issue', locals: { issue: issue } + end + + describe 'timestamp', :freeze_time do + context 'when issue is open' do + let(:issue) { create(:issue, updated_at: 1.day.ago) } + + it 'shows last updated date' do + expect(rendered).to have_content("updated #{format_timestamp(1.day.ago)}") + end + end + + context 'when issue is closed' do + let(:issue) { create(:issue, :closed, closed_at: 2.days.ago, updated_at: 1.day.ago) } + + it 'shows closed date' do + expect(rendered).to have_content("closed #{format_timestamp(2.days.ago)}") + end + end + + context 'when issue is closed but closed_at is empty' do + let(:issue) { create(:issue, :closed, closed_at: nil, updated_at: 1.day.ago) } + + it 'shows last updated date' do + expect(rendered).to have_content("updated #{format_timestamp(1.day.ago)}") + end + end + + def format_timestamp(time) + l(time, format: "%b %d, %Y") + end + end +end |