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,7 +18,8 @@ module Noosfero
18 class RankingItem < Entity 18 class RankingItem < Entity
19 root :proposals, :proposal 19 root :proposals, :proposal
20 expose :id, :position, :abstract, :body, :votes_for, :votes_against 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 end 23 end
23 24
24 end 25 end
lib/proposals_discussion_plugin/ranking_item.rb
@@ -4,6 +4,6 @@ class ProposalsDiscussionPlugin::RankingItem &lt; ActiveRecord::Base @@ -4,6 +4,6 @@ class ProposalsDiscussionPlugin::RankingItem &lt; ActiveRecord::Base
4 4
5 attr_accessible :proposal, :abstract, :votes_for, :votes_against, :hits, :effective_support 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 end 9 end
test/unit/ranking_item_test.rb
@@ -22,4 +22,10 @@ class RankingItemTest &lt; ActiveSupport::TestCase @@ -22,4 +22,10 @@ class RankingItemTest &lt; ActiveSupport::TestCase
22 assert_equal 'body', proposal.ranking_item.body 22 assert_equal 'body', proposal.ranking_item.body
23 end 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 end 31 end