Class: Rallycat::Update

Inherits:
Object
  • Object
show all
Defined in:
lib/rallycat/update.rb

Defined Under Namespace

Classes: TaskNotFound, UserNotFound

Instance Method Summary collapse

Constructor Details

#initialize(api) ⇒ Update

Returns a new instance of Update.



6
7
8
# File 'lib/rallycat/update.rb', line 6

def initialize(api)
  @api = api
end

Instance Method Details

#task(task_number, attributes) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/rallycat/update.rb', line 10

def task(task_number, attributes)
  task = find_task(task_number)

  # When we set the state of the task and we don't explicitly set it to
  # blocked we want to remove the block. In our workflow, when you change
  # the state of the task it is also unblocked.
  if attributes[:state] && !attributes[:blocked]
    attributes[:blocked] = false
  end

  # The value in attributes[:owner] should be equal to the desired owner's 
  # display name in Rally. We need to fetch the user in order to get their
  # login_name. The login_name is needed in order to set the owner
  # attribute of a task.
  # 
  # We decided it would be easier for the user to enter 'John Smith'
  # instead of '[email protected]'.
  if display_name = attributes[:owner]
     = find_user(display_name)
    attributes[:owner] = 
  end

  task.update(attributes)

  messages = []

  if attributes[:state]
    messages << state_message(task_number, attributes[:state])
  end

  if attributes[:blocked]
    messages << blocked_message(task_number)
  end

  if attributes[:owner]
    messages << owner_message(task_number, display_name)
  end

  messages.join("\n")
end