refactors notifications into concerns and shared examples

This commit is contained in:
rgarcia
2017-12-14 16:15:30 +01:00
parent 56a7c46c12
commit 2b52d26d82
35 changed files with 630 additions and 376 deletions

View File

@@ -330,4 +330,31 @@ module CommonActions
expect(Poll::Voter.count).to eq(1)
end
def model_name(described_class)
return :proposal_notification if described_class == ProposalNotification
described_class.name.gsub("::", "_").downcase.to_sym
end
def comment_body(resource)
"comment-body-#{resource.class.name.gsub("::", "_").downcase.to_sym}_#{resource.id}"
end
def path_for(resource)
nested_path_for(resource) || url_for([resource, only_path: true])
end
def nested_path_for(resource)
case resource.class.name
when "Legislation::Question"
legislation_process_question_path(resource.process, resource)
when "Legislation::Proposal"
legislation_process_proposal_path(resource.process, resource)
when "Budget::Investment"
budget_investment_path(resource.budget, resource)
else
false
end
end
end