From b6e19656fa2a4d99b96ca925f00768d6de879891 Mon Sep 17 00:00:00 2001 From: Victor Costa Date: Tue, 15 Dec 2015 17:49:16 -0300 Subject: [PATCH] Add slug to ranking item --- lib/ext/entities.rb | 3 ++- lib/proposals_discussion_plugin/ranking_item.rb | 2 +- test/unit/ranking_item_test.rb | 6 ++++++ 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/ext/entities.rb b/lib/ext/entities.rb index 2883745..e4f8e5b 100644 --- a/lib/ext/entities.rb +++ b/lib/ext/entities.rb @@ -18,7 +18,8 @@ module Noosfero class RankingItem < Entity root :proposals, :proposal expose :id, :position, :abstract, :body, :votes_for, :votes_against - expose :hits, :effective_support, :proposal_id, :created_at, :updated_at + expose :hits, :effective_support, :proposal_id, :created_at + expose :updated_at, :slug end end diff --git a/lib/proposals_discussion_plugin/ranking_item.rb b/lib/proposals_discussion_plugin/ranking_item.rb index 4b5f233..fa199a7 100644 --- a/lib/proposals_discussion_plugin/ranking_item.rb +++ b/lib/proposals_discussion_plugin/ranking_item.rb @@ -4,6 +4,6 @@ class ProposalsDiscussionPlugin::RankingItem < ActiveRecord::Base attr_accessible :proposal, :abstract, :votes_for, :votes_against, :hits, :effective_support - delegate :body, :to => :proposal + delegate :body, :slug, :to => :proposal end diff --git a/test/unit/ranking_item_test.rb b/test/unit/ranking_item_test.rb index 2d091be..7f37aea 100644 --- a/test/unit/ranking_item_test.rb +++ b/test/unit/ranking_item_test.rb @@ -22,4 +22,10 @@ class RankingItemTest < ActiveSupport::TestCase assert_equal 'body', proposal.ranking_item.body end + should 'return slug of a proposal' do + proposal = ProposalsDiscussionPlugin::Proposal.create!(:name => 'test', :abstract => 'abstract', :body => 'body', :profile => profile, :parent => discussion) + discussion.update_ranking + assert_equal proposal.slug, proposal.ranking_item.slug + end + end -- libgit2 0.21.2