Commit 3cc86412 authored by Nick Thomas's avatar Nick Thomas

Merge branch 'dz-improve-new-issue-highlight' into 'master'

Change logic behind "new" issues highlight

Closes #233045

See merge request gitlab-org/gitlab!41150
parents 39bc3609 7f399b82
...@@ -4,7 +4,7 @@ module IssuesHelper ...@@ -4,7 +4,7 @@ module IssuesHelper
def issue_css_classes(issue) def issue_css_classes(issue)
classes = ["issue"] classes = ["issue"]
classes << "closed" if issue.closed? classes << "closed" if issue.closed?
classes << "today" if issue.today? classes << "today" if issue.new?
classes << "user-can-drag" if @sort == 'relative_position' classes << "user-can-drag" if @sort == 'relative_position'
classes.join(' ') classes.join(' ')
end end
......
...@@ -385,8 +385,12 @@ module Issuable ...@@ -385,8 +385,12 @@ module Issuable
Date.today == created_at.to_date Date.today == created_at.to_date
end end
def created_hours_ago
(Time.now.utc.to_i - created_at.utc.to_i) / 3600
end
def new? def new?
today? && created_at == updated_at created_hours_ago < 24
end end
def open? def open?
......
---
title: Change logic behind new issues highlight
merge_request: 41150
author:
type: changed
...@@ -295,20 +295,14 @@ RSpec.describe Issuable do ...@@ -295,20 +295,14 @@ RSpec.describe Issuable do
end end
describe "#new?" do describe "#new?" do
it "returns true when created today and record hasn't been updated" do it "returns false when created 30 hours ago" do
allow(issue).to receive(:today?).and_return(true) allow(issue).to receive(:created_at).and_return(Time.current - 30.hours)
expect(issue.new?).to be_truthy
end
it "returns false when not created today" do
allow(issue).to receive(:today?).and_return(false)
expect(issue.new?).to be_falsey expect(issue.new?).to be_falsey
end end
it "returns false when record has been updated" do it "returns true when created 20 hours ago" do
allow(issue).to receive(:today?).and_return(true) allow(issue).to receive(:created_at).and_return(Time.current - 20.hours)
issue.update_attribute(:updated_at, 1.hour.ago) expect(issue.new?).to be_truthy
expect(issue.new?).to be_falsey
end end
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment