Commit 7f399b82 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Change issue new? behavior

Issues that are less than 24 hours old are new now.
Also it does not matter if creation and edit dates are different.
Use `new?` instead of `today?` for UI highligt of new issues.
Signed-off-by: default avatarDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
parent 024c2993
...@@ -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