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
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