debian-mirror-gitlab/spec/views/projects/issues/_issue.html.haml_spec.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

45 lines
1.2 KiB
Ruby
Raw Normal View History

2022-08-13 15:12:31 +05:30
# 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