Refactor path helpers for comments

This commit is contained in:
Amaia Castro
2017-01-17 17:26:05 +01:00
parent b8e0a5e7a5
commit 9c8102b9f3
2 changed files with 9 additions and 10 deletions

View File

@@ -41,8 +41,15 @@ module CommentsHelper
end
def commentable_path(comment)
if comment.commentable_type == "Budget::Investment"
budget_investment_path(comment.commentable.budget_id, comment.commentable)
commentable = comment.commentable
case comment.commentable_type
when "Budget::Investment"
budget_investment_path(commentable.budget_id, commentable)
when "Legislation::Question"
legislation_process_question_path(commentable.process, commentable)
when "Legislation::Annotation"
legislation_process_draft_version_annotation_path(commentable.draft_version.process, commentable.draft_version, commentable)
else
comment.commentable
end

View File

@@ -6,12 +6,4 @@ module LegislationHelper
def format_date_for_calendar_form(date)
l(date, format: "%d/%m/%Y") if date
end
def legislation_question_path(question)
legislation_process_question_path(question.process, question)
end
def legislation_annotation_path(annotation)
legislation_process_draft_version_annotation_path(annotation.draft_version.process, annotation.draft_version, annotation)
end
end