Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2022-06-30 12:10:05 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2022-06-30 12:10:05 +0300
commit312ac59328577a230a049eb71c56f648508d209f (patch)
treea8aab96504d3062ee18c08176d36d6073711ccb8 /spec/views/projects
parente6f10cb4b38644d88a2e0016af206d2eb68a25d8 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/views/projects')
-rw-r--r--spec/views/projects/issues/_issue.html.haml_spec.rb44
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