diff options
Diffstat (limited to 'spec/views/projects/commits')
-rw-r--r-- | spec/views/projects/commits/show.html.haml_spec.rb | 34 |
1 files changed, 32 insertions, 2 deletions
diff --git a/spec/views/projects/commits/show.html.haml_spec.rb b/spec/views/projects/commits/show.html.haml_spec.rb index e5e9906a798..9393ba046dc 100644 --- a/spec/views/projects/commits/show.html.haml_spec.rb +++ b/spec/views/projects/commits/show.html.haml_spec.rb @@ -3,8 +3,10 @@ require 'spec_helper' RSpec.describe 'projects/commits/show.html.haml' do - let(:project) { create(:project, :repository) } - let(:commits) { [project.commit] } + let_it_be(:project) { create(:project, :repository) } + + let(:commits) { [commit] } + let(:commit) { project.commit } let(:path) { 'path/to/doc.md' } before do @@ -32,4 +34,32 @@ RSpec.describe 'projects/commits/show.html.haml' do expect(rendered).to have_link(href: "#{project_commits_path(project, path)}?format=atom") end end + + context 'commits date headers' do + let(:user) { build(:user, timezone: timezone) } + let(:committed_date) { Time.find_zone('UTC').parse('2023-01-01') } + + before do + allow(view).to receive(:current_user).and_return(user) + allow(commit).to receive(:committed_date).and_return(committed_date) + + render + end + + context 'when timezone is UTC' do + let(:timezone) { 'UTC' } + + it "renders commit date header in user's timezone" do + expect(rendered).to include('data-day="2023-01-01"') + end + end + + context 'when timezone is UTC-6' do + let(:timezone) { 'America/Mexico_City' } + + it "renders commit date header in user's timezone" do + expect(rendered).to include('data-day="2022-12-31"') + end + end + end end |