Class: Lazylead::Task::Assignee

Inherits:
Object
  • Object
show all
Defined in:
lib/lazylead/task/assignment.rb

Overview

Instance of “Assignee” history item for the particular ticket.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(issue, allowed, silent) ⇒ Assignee

Returns a new instance of Assignee.



59
60
61
62
63
# File 'lib/lazylead/task/assignment.rb', line 59

def initialize(issue, allowed, silent)
  @issue = issue
  @allowed = allowed
  @silent = silent
end

Instance Attribute Details

#issueObject (readonly)

Returns the value of attribute issue.



57
58
59
# File 'lib/lazylead/task/assignment.rb', line 57

def issue
  @issue
end

Instance Method Details

#add_label(name = "LL.IllegalChangeOfAssignee") ⇒ Object

Mark ticket with particular label



82
83
84
# File 'lib/lazylead/task/assignment.rb', line 82

def add_label(name = "LL.IllegalChangeOfAssignee")
  @issue.add_label(name) unless @silent
end

#illegal?Boolean

Gives true when last change of “Assignee” field was done

by not authorized person.

Returns:

  • (Boolean)


67
68
69
70
# File 'lib/lazylead/task/assignment.rb', line 67

def illegal?
  return false if last.nil? || @issue.assignee.id.eql?(last["author"]["name"])
  @allowed.none? { |a| a.eql? last["author"]["name"] }
end

#lastObject

Detect details about last change of “Assignee” to non-null value



73
74
75
76
77
78
79
# File 'lib/lazylead/task/assignment.rb', line 73

def last
  @last ||= issue.history.reverse.find do |h|
    h["items"].any? do |i|
      i["field"] == "assignee"
    end
  end
end

#toObject

The name of current assignee for ticket



87
88
89
# File 'lib/lazylead/task/assignment.rb', line 87

def to
  @issue.fields["assignee"]["displayName"]
end