Commit b6e19656fa2a4d99b96ca925f00768d6de879891

Authored by Victor Costa
1 parent 45799bf1

Add slug to ranking item

lib/ext/entities.rb
... ... @@ -18,7 +18,8 @@ module Noosfero
18 18 class RankingItem < Entity
19 19 root :proposals, :proposal
20 20 expose :id, :position, :abstract, :body, :votes_for, :votes_against
21   - expose :hits, :effective_support, :proposal_id, :created_at, :updated_at
  21 + expose :hits, :effective_support, :proposal_id, :created_at
  22 + expose :updated_at, :slug
22 23 end
23 24  
24 25 end
... ...
lib/proposals_discussion_plugin/ranking_item.rb
... ... @@ -4,6 +4,6 @@ class ProposalsDiscussionPlugin::RankingItem &lt; ActiveRecord::Base
4 4  
5 5 attr_accessible :proposal, :abstract, :votes_for, :votes_against, :hits, :effective_support
6 6  
7   - delegate :body, :to => :proposal
  7 + delegate :body, :slug, :to => :proposal
8 8  
9 9 end
... ...
test/unit/ranking_item_test.rb
... ... @@ -22,4 +22,10 @@ class RankingItemTest &lt; ActiveSupport::TestCase
22 22 assert_equal 'body', proposal.ranking_item.body
23 23 end
24 24  
  25 + should 'return slug of a proposal' do
  26 + proposal = ProposalsDiscussionPlugin::Proposal.create!(:name => 'test', :abstract => 'abstract', :body => 'body', :profile => profile, :parent => discussion)
  27 + discussion.update_ranking
  28 + assert_equal proposal.slug, proposal.ranking_item.slug
  29 + end
  30 +
25 31 end
... ...