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
def issue_css_classes(issue)
classes = ["issue"]
classes << "closed" if issue.closed?
classes << "today" if issue.today?
classes << "today" if issue.new?
classes << "user-can-drag" if @sort == 'relative_position'
classes.join(' ')
end
......
......@@ -385,8 +385,12 @@ module Issuable
Date.today == created_at.to_date
end
def created_hours_ago
(Time.now.utc.to_i - created_at.utc.to_i) / 3600
end
def new?
today? && created_at == updated_at
created_hours_ago < 24
end
def open?
......
---
title: Change logic behind new issues highlight
merge_request: 41150
author:
type: changed
......@@ -295,20 +295,14 @@ RSpec.describe Issuable do
end
describe "#new?" do
it "returns true when created today and record hasn't been updated" do
allow(issue).to receive(:today?).and_return(true)
expect(issue.new?).to be_truthy
end
it "returns false when not created today" do
allow(issue).to receive(:today?).and_return(false)
it "returns false when created 30 hours ago" do
allow(issue).to receive(:created_at).and_return(Time.current - 30.hours)
expect(issue.new?).to be_falsey
end
it "returns false when record has been updated" do
allow(issue).to receive(:today?).and_return(true)
issue.update_attribute(:updated_at, 1.hour.ago)
expect(issue.new?).to be_falsey
it "returns true when created 20 hours ago" do
allow(issue).to receive(:created_at).and_return(Time.current - 20.hours)
expect(issue.new?).to be_truthy
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