Commit c59a0c4947ef85fba1fd52f45107c6bd878e3fa6
1 parent
7fd77a7e
Exists in
master
and in
1 other branch
Display info about profile
Showing
3 changed files
with
34 additions
and
17 deletions
Show diff stats
lib/merit/point_rules.rb
| ... | ... | @@ -60,6 +60,7 @@ module Merit |
| 60 | 60 | weight(category) * value |
| 61 | 61 | end |
| 62 | 62 | |
| 63 | + # TODO receive environment parameter | |
| 63 | 64 | def initialize |
| 64 | 65 | AVAILABLE_RULES.each do |category, setting| |
| 65 | 66 | [setting[:action], setting[:undo_action]].compact.zip([1, -1]).each do |action, signal| | ... | ... |
test/functional/gamification_plugin_profile_controller_test.rb
| ... | ... | @@ -11,15 +11,25 @@ class GamificationPluginProfileControllerTest < ActionController::TestCase |
| 11 | 11 | attr_accessor :profile, :person |
| 12 | 12 | |
| 13 | 13 | should 'display points in gamification info page' do |
| 14 | - Profile.any_instance.expects(:points).returns(125) | |
| 14 | + person.add_points(20, :category => :comment_author) | |
| 15 | + person.add_points(30, :category => :article_author) | |
| 15 | 16 | get :info, :profile => profile.identifier |
| 16 | - assert_tag :div, :attributes => {:class => 'score'}, :child => {:tag => 'span', :attributes => {:class => 'value'}, :content => '125'} | |
| 17 | + assert_tag :div, :attributes => {:class => 'score article_author'}, :child => {:tag => 'span', :attributes => {:class => 'value'}, :content => '30'} | |
| 18 | + assert_tag :div, :attributes => {:class => 'score comment_author'}, :child => {:tag => 'span', :attributes => {:class => 'value'}, :content => '20'} | |
| 19 | + assert_tag :div, :attributes => {:class => 'score total'}, :child => {:tag => 'span', :attributes => {:class => 'value'}, :content => '50'} | |
| 17 | 20 | end |
| 18 | 21 | |
| 19 | 22 | should 'display level in gamification info page' do |
| 20 | 23 | person.update_attribute(:level, 12) |
| 21 | 24 | get :info, :profile => profile.identifier |
| 22 | - assert_tag :div, :attributes => {:class => 'level'}, :child => {:tag => 'span', :attributes => {:class => 'value'}, :content => '12'} | |
| 25 | + assert_tag :span, :attributes => {:class => 'level'}, :content => '12' | |
| 26 | + end | |
| 27 | + | |
| 28 | + should 'display person badges' do | |
| 29 | + person.add_badge(1) | |
| 30 | + person.add_badge(2) | |
| 31 | + get :info, :profile => profile.identifier | |
| 32 | + assert_select '.badges .badge-list .badge', 2 | |
| 23 | 33 | end |
| 24 | 34 | |
| 25 | 35 | end | ... | ... |
views/gamification/info.html.erb
| 1 | 1 | <div class="gamification"> |
| 2 | 2 | <h1><%= _('Gamification Info for %s' % @target.identifier) %></h1> |
| 3 | - <div class="score"> | |
| 4 | - <span class="label"><%= _('Score: ') %></span> | |
| 5 | - <span class="value"><%= @target.points %></span> | |
| 6 | - </div> | |
| 7 | - <div class="level"> | |
| 8 | - <span class="label"><%= _('Level: ') %></span> | |
| 9 | - <span class="value"><%= @target.level %></span> | |
| 3 | + <h3> <%= _('Level:') %> <span class="level"><%= @target.level %></span></h3> | |
| 4 | + <div class="scores"> | |
| 5 | + <h3><%= _('Score') %></h3> | |
| 6 | + <% Merit::PointRules::AVAILABLE_RULES.each do |category, setting| %> | |
| 7 | + <div class="score <%= category %>"> | |
| 8 | + <span class="label"><%= _('%s: ' % category) %></span> | |
| 9 | + <span class="value"><%= @target.points(:category => category) %></span> | |
| 10 | + </div> | |
| 11 | + <% end %> | |
| 12 | + <div class="score total"> | |
| 13 | + <span class="label"><%= _('Total: ') %></span> | |
| 14 | + <span class="value"><%= @target.points %></span> | |
| 15 | + </div> | |
| 10 | 16 | </div> |
| 11 | 17 | <div class="badges"> |
| 12 | 18 | <h3><%= _('Badges') %></h3> |
| 13 | - <ul> | |
| 19 | + <ul class="badge-list"> | |
| 14 | 20 | <% @target.badges.each do |badge| %> |
| 15 | 21 | <li class="badge <%= badge.name %>"> |
| 16 | - <span class="description"><%= badge.description %></span> | |
| 17 | - <% if badge.level.present? %> | |
| 18 | - <span class="label"><%= _('Level') %></span> <span class="level"><%= badge.level %></span> | |
| 19 | - <% end %> | |
| 20 | - </li> | |
| 21 | - <% end %> | |
| 22 | + <span class="description"><%= badge.description %></span> | |
| 23 | + <% if badge.level.present? %> | |
| 24 | + <span class="label"><%= _('Level') %></span> <span class="level"><%= badge.level %></span> | |
| 25 | + <% end %> | |
| 26 | + </li> | |
| 27 | + <% end %> | |
| 22 | 28 | </ul> |
| 23 | 29 | </div> |
| 24 | 30 | </div> | ... | ... |