diff --git a/lib/merit/point_rules.rb b/lib/merit/point_rules.rb index 6afd833..8b242b4 100644 --- a/lib/merit/point_rules.rb +++ b/lib/merit/point_rules.rb @@ -60,6 +60,7 @@ module Merit weight(category) * value end + # TODO receive environment parameter def initialize AVAILABLE_RULES.each do |category, setting| [setting[:action], setting[:undo_action]].compact.zip([1, -1]).each do |action, signal| diff --git a/test/functional/gamification_plugin_profile_controller_test.rb b/test/functional/gamification_plugin_profile_controller_test.rb index 932519c..d1016dd 100644 --- a/test/functional/gamification_plugin_profile_controller_test.rb +++ b/test/functional/gamification_plugin_profile_controller_test.rb @@ -11,15 +11,25 @@ class GamificationPluginProfileControllerTest < ActionController::TestCase attr_accessor :profile, :person should 'display points in gamification info page' do - Profile.any_instance.expects(:points).returns(125) + person.add_points(20, :category => :comment_author) + person.add_points(30, :category => :article_author) get :info, :profile => profile.identifier - assert_tag :div, :attributes => {:class => 'score'}, :child => {:tag => 'span', :attributes => {:class => 'value'}, :content => '125'} + assert_tag :div, :attributes => {:class => 'score article_author'}, :child => {:tag => 'span', :attributes => {:class => 'value'}, :content => '30'} + assert_tag :div, :attributes => {:class => 'score comment_author'}, :child => {:tag => 'span', :attributes => {:class => 'value'}, :content => '20'} + assert_tag :div, :attributes => {:class => 'score total'}, :child => {:tag => 'span', :attributes => {:class => 'value'}, :content => '50'} end should 'display level in gamification info page' do person.update_attribute(:level, 12) get :info, :profile => profile.identifier - assert_tag :div, :attributes => {:class => 'level'}, :child => {:tag => 'span', :attributes => {:class => 'value'}, :content => '12'} + assert_tag :span, :attributes => {:class => 'level'}, :content => '12' + end + + should 'display person badges' do + person.add_badge(1) + person.add_badge(2) + get :info, :profile => profile.identifier + assert_select '.badges .badge-list .badge', 2 end end diff --git a/views/gamification/info.html.erb b/views/gamification/info.html.erb index e4405a9..3e8c145 100644 --- a/views/gamification/info.html.erb +++ b/views/gamification/info.html.erb @@ -1,24 +1,30 @@

<%= _('Gamification Info for %s' % @target.identifier) %>

-
- <%= _('Score: ') %> - <%= @target.points %> -
-
- <%= _('Level: ') %> - <%= @target.level %> +

<%= _('Level:') %> <%= @target.level %>

+
+

<%= _('Score') %>

+ <% Merit::PointRules::AVAILABLE_RULES.each do |category, setting| %> +
+ <%= _('%s: ' % category) %> + <%= @target.points(:category => category) %> +
+ <% end %> +
+ <%= _('Total: ') %> + <%= @target.points %> +

<%= _('Badges') %>

-
    +
      <% @target.badges.each do |badge| %>
    • - <%= badge.description %> - <% if badge.level.present? %> - <%= _('Level') %> <%= badge.level %> - <% end %> -
    • - <% end %> + <%= badge.description %> + <% if badge.level.present? %> + <%= _('Level') %> <%= badge.level %> + <% end %> + + <% end %>
-- libgit2 0.21.2