mirror of
https://github.com/TracksApp/tracks.git
synced 2026-02-05 07:21:48 +01:00
fix failing test and make sure that you can supply 'starred' tag. Refactor todo model
This commit is contained in:
parent
72edf10ad3
commit
906ff11633
4 changed files with 71 additions and 72 deletions
|
|
@ -289,7 +289,7 @@ class Todo < ActiveRecord::Base
|
|||
|
||||
def add_predecessor(t)
|
||||
return if t.nil?
|
||||
|
||||
|
||||
@predecessor_array = predecessors
|
||||
@predecessor_array << t
|
||||
end
|
||||
|
|
@ -311,11 +311,11 @@ class Todo < ActiveRecord::Base
|
|||
def raw_notes=(value)
|
||||
self[:notes] = value
|
||||
end
|
||||
|
||||
|
||||
# XML API fixups
|
||||
def predecessor_dependencies=(params)
|
||||
value = params[:predecessor]
|
||||
|
||||
|
||||
if !value.nil?
|
||||
if value.class == Array
|
||||
value.each do |ele|
|
||||
|
|
@ -325,7 +325,7 @@ class Todo < ActiveRecord::Base
|
|||
predecessor_dependencies.build(value)
|
||||
end
|
||||
end
|
||||
else
|
||||
else
|
||||
if ele.is_a? String
|
||||
add_predecessor(self.user.todos.find_by_id(ele.to_i)) unless ele.blank?
|
||||
else
|
||||
|
|
@ -334,7 +334,7 @@ class Todo < ActiveRecord::Base
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
alias_method :original_context=, :context=
|
||||
def context=(value)
|
||||
if value.is_a? Context
|
||||
|
|
@ -343,7 +343,7 @@ class Todo < ActiveRecord::Base
|
|||
self.original_context=(Context.create(value))
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
alias_method :original_project=, :project=
|
||||
def project=(value)
|
||||
if value.is_a? Project
|
||||
|
|
@ -352,23 +352,13 @@ class Todo < ActiveRecord::Base
|
|||
self.original_project=(Project.create(value))
|
||||
end
|
||||
end
|
||||
|
||||
def tags=(params)
|
||||
value = params[:tag]
|
||||
|
||||
if !value.nil?
|
||||
if value.class == Array
|
||||
value.each do |attrs|
|
||||
tags.build(attrs)
|
||||
end
|
||||
else
|
||||
tags.build(value)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# Rich Todo API
|
||||
|
||||
# used by the REST API. <tags> will also work, this is renamed to add_tags in TodosController::TodoCreateParamsHelper::initialize
|
||||
def add_tags=(params)
|
||||
tag_with params[:tag].inject([]) { |list, value| list << value[:name] } unless params[:tag].nil?
|
||||
end
|
||||
|
||||
# Rich Todo API
|
||||
def self.from_rich_message(user, default_context_id, description, notes)
|
||||
fields = description.match(/([^>@]*)@?([^>]*)>?(.*)/)
|
||||
description = fields[1].strip
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue