Commit 6fa81300e41bc5bdd926ee5f7859346555bd8844

Authored by Victor Costa
2 parents 0b13c293 a97d8f17

Merge branch 'fixes_tasks_api' into 'master'

fixes creation of specific tasks in API

API: Fixes task creation with specific type to also work on development environment.
In development with the current code, the task descendants are not loaded when the method post_task is called.

See merge request !893
Showing 1 changed file with 1 additions and 2 deletions   Show diff stats
lib/noosfero/api/helpers.rb
... ... @@ -99,7 +99,6 @@ require_relative '../../find_by_contents'
99 99 end
100 100  
101 101 ARTICLE_TYPES = ['Article'] + Article.descendants.map{|a| a.to_s}
102   - TASK_TYPES = ['Task'] + Task.descendants.map{|a| a.to_s}
103 102  
104 103 def find_article(articles, id)
105 104 article = articles.find(id)
... ... @@ -154,7 +153,7 @@ require_relative '../../find_by_contents'
154 153  
155 154 def post_task(asset, params)
156 155 klass_type= params[:content_type].nil? ? 'Task' : params[:content_type]
157   - return forbidden! unless TASK_TYPES.include?(klass_type)
  156 + return forbidden! unless klass_type.constantize <= Task
158 157  
159 158 task = klass_type.constantize.new(params[:task])
160 159 task.requestor_id = current_person.id
... ...