Commit 86320e27f6cff52810564f56490588f87697909b
Committed by
Álvaro Fernando Matos de Souza
1 parent
218a0bc1
Exists in
master
and in
5 other branches
Comments Hotspot on Communities Ratings Plugin
- Extra fields now only shows on Softwares Profiles Signed-off-by: Andre Bernardes <andrebsguedes@gmail.com> Signed-off-by: Tallys Martins <tallysmartins@gmail.com>
Showing
2 changed files
with
58 additions
and
1 deletions
Show diff stats
lib/software_communities_plugin.rb
| ... | ... | @@ -71,7 +71,9 @@ class SoftwareCommunitiesPlugin < Noosfero::Plugin |
| 71 | 71 | end |
| 72 | 72 | |
| 73 | 73 | def communities_ratings_plugin_comments_extra_fields |
| 74 | - Proc::new do render :file => 'comments_extra_fields' end | |
| 74 | + if context.profile.software? | |
| 75 | + Proc::new { render :file => 'comments_extra_fields' } | |
| 76 | + end | |
| 75 | 77 | end |
| 76 | 78 | |
| 77 | 79 | def communities_ratings_plugin_star_message | ... | ... |
| ... | ... | @@ -0,0 +1,55 @@ |
| 1 | +require File.expand_path(File.dirname(__FILE__)) + '/../../../../test/test_helper' | |
| 2 | +require File.expand_path(File.dirname(__FILE__)) + '/../helpers/software_test_helper' | |
| 3 | +require( | |
| 4 | + File.expand_path(File.dirname(__FILE__)) + | |
| 5 | + '/../../../../app/controllers/public/profile_controller' | |
| 6 | +) | |
| 7 | + | |
| 8 | +class ProfileController; def rescue_action(e) raise e end; end | |
| 9 | + | |
| 10 | +class ProfileControllerTest < ActionController::TestCase | |
| 11 | +include SoftwareTestHelper | |
| 12 | + def setup | |
| 13 | + @controller =CommunitiesRatingsPluginProfileController.new | |
| 14 | + @request = ActionController::TestRequest.new | |
| 15 | + @response = ActionController::TestResponse.new | |
| 16 | + @profile = create_user('default_user').person | |
| 17 | + | |
| 18 | + Environment.default.affiliate( | |
| 19 | + @profile, | |
| 20 | + [Environment::Roles.admin(Environment.default.id)] + | |
| 21 | + Profile::Roles.all_roles(Environment.default.id) | |
| 22 | + ) | |
| 23 | + | |
| 24 | + LicenseInfo.create( | |
| 25 | + :version=>"CC-GPL-V2", | |
| 26 | + :link=>"http://creativecommons.org/licenses/GPL/2.0/legalcode.pt" | |
| 27 | + ) | |
| 28 | + | |
| 29 | + @environment = Environment.default | |
| 30 | + @environment.enabled_plugins = ['SoftwareCommunitiesPlugin', 'CommunitiesRatingsPlugin'] | |
| 31 | + admin = create_user("adminuser").person | |
| 32 | + admin.stubs(:has_permission?).returns("true") | |
| 33 | + login_as('adminuser') | |
| 34 | + @environment.add_admin(admin) | |
| 35 | + @environment.save | |
| 36 | + end | |
| 37 | + | |
| 38 | + should "dispach additional comment fields to Softwares" do | |
| 39 | + @hash_list = software_fields | |
| 40 | + software = create_software(@hash_list) | |
| 41 | + | |
| 42 | + get :new_rating , profile: software.community.identifier | |
| 43 | + assert_template :new_rating | |
| 44 | + assert_match(/Aditional informations/, @response.body) | |
| 45 | + end | |
| 46 | + | |
| 47 | + should "NOT dispach additional comment fields only to Softwares" do | |
| 48 | + community = fast_create(Community) | |
| 49 | + | |
| 50 | + get :new_rating , profile: community.identifier | |
| 51 | + assert_template :new_rating | |
| 52 | + assert_not_match(/Aditional informations/, @response.body) | |
| 53 | + end | |
| 54 | + | |
| 55 | +end | |
| 0 | 56 | \ No newline at end of file | ... | ... |