Commit f39591188a067bb9526435a653fcd2a1f0a306b9
Exists in
master
and in
29 other branches
Merge branch 'fix_plugin_tests' of https://gitlab.com/participa/noosfero into plugins-tests
Showing
7 changed files
with
105 additions
and
105 deletions
Show diff stats
Gemfile
@@ -28,6 +28,7 @@ group :production do | @@ -28,6 +28,7 @@ group :production do | ||
28 | end | 28 | end |
29 | 29 | ||
30 | group :test do | 30 | group :test do |
31 | + gem 'test-unit', '~> 1.2.3' | ||
31 | gem 'rspec', '~> 2.10.0' | 32 | gem 'rspec', '~> 2.10.0' |
32 | gem 'rspec-rails', '~> 2.10.1' | 33 | gem 'rspec-rails', '~> 2.10.1' |
33 | gem 'mocha', '~> 1.1.0', :require => false | 34 | gem 'mocha', '~> 1.1.0', :require => false |
lib/tasks/plugins_tests.rake
@@ -104,7 +104,7 @@ def run_test(name, files) | @@ -104,7 +104,7 @@ def run_test(name, files) | ||
104 | end | 104 | end |
105 | 105 | ||
106 | def run_testrb(files) | 106 | def run_testrb(files) |
107 | - sh 'testrb', '-Itest', *files | 107 | + sh 'testrb', '-I.:test', *files |
108 | end | 108 | end |
109 | 109 | ||
110 | def run_cucumber(profile, files) | 110 | def run_cucumber(profile, files) |
plugins/comment_group/views/comment_group_plugin_profile/view_comments.rjs
@@ -8,5 +8,5 @@ page.replace_html "comment-count-#{@group_id}", @comments_count | @@ -8,5 +8,5 @@ page.replace_html "comment-count-#{@group_id}", @comments_count | ||
8 | if @no_more_pages | 8 | if @no_more_pages |
9 | page.replace_html "comments_list_group_#{@group_id}_more", "" | 9 | page.replace_html "comments_list_group_#{@group_id}_more", "" |
10 | else | 10 | else |
11 | - page.replace_html "comments_list_group_#{@group_id}_more", link_to_remote(_('More'), :url => { :profile => profile.identifier, :controller => 'comment_group_plugin_profile', :action => 'view_comments', :group_id => @group_id, :article_id => @article_id, :group_comment_page => @group_comment_page + 1}, :loaded => visual_effect(:highlight, "comments_list_group_#{@group_id}"), :method => :post, :complete => "loadCompleted(#{@group_id})") | 11 | + page.replace_html "comments_list_group_#{@group_id}_more", link_to_remote(_('More'), :url => { :profile => profile.identifier, :controller => 'comment_group_plugin_profile', :action => 'view_comments', :group_id => @group_id, :article_id => @article_id, :group_comment_page => @group_comment_page + 1}, :method => :get) |
12 | end | 12 | end |
plugins/community_block/test/functional/commmunity_block_plugin_profile_controller_test.rb
0 → 100644
@@ -0,0 +1,83 @@ | @@ -0,0 +1,83 @@ | ||
1 | +require File.dirname(__FILE__) + '/../test_helper' | ||
2 | + | ||
3 | +# Re-raise errors caught by the controller. | ||
4 | +class ProfileController | ||
5 | + append_view_path File.join(File.dirname(__FILE__) + '/../../views') | ||
6 | + def rescue_action(e) | ||
7 | + raise e | ||
8 | + end | ||
9 | +end | ||
10 | + | ||
11 | +class ProfileControllerTest < ActionController::TestCase | ||
12 | + | ||
13 | + def setup | ||
14 | + @user = create_user('testinguser').person | ||
15 | + login_as(@user.identifier) | ||
16 | + | ||
17 | + @community = fast_create(Community, :environment_id => Environment.default) | ||
18 | + @community.add_member @user | ||
19 | + @community.add_admin @user | ||
20 | + | ||
21 | + @environment = @community.environment | ||
22 | + @environment.enabled_plugins = ['CommunityBlock'] | ||
23 | + @environment.save! | ||
24 | + | ||
25 | + CommunityBlock.delete_all | ||
26 | + @box1 = create(Box, :owner => @community) | ||
27 | + @community.boxes = [@box1] | ||
28 | + | ||
29 | + @block = CommunityBlock.new | ||
30 | + @block.box = @box1 | ||
31 | + @block.save! | ||
32 | + | ||
33 | + @community.blocks<<@block | ||
34 | + @community.save! | ||
35 | + end | ||
36 | + | ||
37 | + should 'display community-block' do | ||
38 | + get :index, :profile => @community.identifier | ||
39 | + assert_tag :div, :attributes => {:class => 'community-block-logo'} | ||
40 | + assert_tag :div, :attributes => {:class => 'community-block-info'} | ||
41 | + assert_tag :div, :attributes => {:class => 'community-block-title'} | ||
42 | + assert_tag :div, :attributes => {:class => 'community-block-description'} | ||
43 | + end | ||
44 | + | ||
45 | + should 'display *leave* button when the user is logged in and is a member of the community' do | ||
46 | + get :index, :profile => @community.identifier | ||
47 | + assert_tag :span, :attributes => {:class => 'community-block-button icon-remove'} | ||
48 | + end | ||
49 | + | ||
50 | + should 'display *send email to administrators* button when the user is logged in and is a member of the community' do | ||
51 | + get :index, :profile => @community.identifier | ||
52 | + assert_match /\{"Send an e-mail":\{"href":"\/contact\/#{@community.identifier}\/new"\}\}/, @response.body | ||
53 | + end | ||
54 | + | ||
55 | + should 'display *report* button when the user is logged in and is a member of the community' do | ||
56 | + get :index, :profile => @community.identifier | ||
57 | + assert_match /\{"Report abuse":\{"href":"\/profile\/#{@community.identifier}\/report_abuse"\}\}/, @response.body | ||
58 | + end | ||
59 | + | ||
60 | + should 'display *join* button when the user is logged in and is not a member of the community' do | ||
61 | + @community.remove_member @user | ||
62 | + get :index, :profile => @community.identifier | ||
63 | + assert_tag :span, :attributes => {:class => 'community-block-button icon-add'} | ||
64 | + end | ||
65 | + | ||
66 | + should 'display *control panel* link option when the user is logged in and is community admin' do | ||
67 | + get :index, :profile => @community.identifier | ||
68 | + assert_match /\{"Control panel":\{"href":"\/myprofile\/#{@community.identifier}"\}\}/, @response.body | ||
69 | + end | ||
70 | + | ||
71 | + should 'display *join* button when the user is not logged in' do | ||
72 | + logout | ||
73 | + get :index, :profile => @community.identifier | ||
74 | + assert_tag :span, :attributes => {:class => 'community-block-button icon-add'} | ||
75 | + end | ||
76 | + | ||
77 | + should 'not display *arrow* button when the user is not logged in' do | ||
78 | + logout | ||
79 | + get :index, :profile => @community.identifier | ||
80 | + assert_no_tag :span, :attributes => {:class => 'community-block-button icon-arrow'} | ||
81 | + end | ||
82 | + | ||
83 | +end |
plugins/community_block/test/functional/commmunity_block_plugin_profile_design_controller_test.rb
@@ -1,87 +0,0 @@ | @@ -1,87 +0,0 @@ | ||
1 | -require File.dirname(__FILE__) + '/../test_helper' | ||
2 | - | ||
3 | -# Re-raise errors caught by the controller. | ||
4 | -class ProfileController | ||
5 | - append_view_path File.join(File.dirname(__FILE__) + '/../../views') | ||
6 | - def rescue_action(e) | ||
7 | - raise e | ||
8 | - end | ||
9 | -end | ||
10 | - | ||
11 | -class ProfileControllerTest < ActionController::TestCase | ||
12 | - | ||
13 | - def setup | ||
14 | - @controller = ProfileController.new | ||
15 | - @request = ActionController::TestRequest.new | ||
16 | - @response = ActionController::TestResponse.new | ||
17 | - | ||
18 | - @user = create_user('testinguser').person | ||
19 | - login_as(@user.identifier) | ||
20 | - | ||
21 | - @community = fast_create(Community, :environment_id => Environment.default) | ||
22 | - @community.add_member @user | ||
23 | - @community.add_admin @user | ||
24 | - | ||
25 | - @environment = @community.environment | ||
26 | - @environment.enabled_plugins = ['CommunityBlock'] | ||
27 | - @environment.save! | ||
28 | - | ||
29 | - CommunityBlock.delete_all | ||
30 | - @box1 = create(Box, :owner => @community) | ||
31 | - @community.boxes = [@box1] | ||
32 | - | ||
33 | - @block = CommunityBlock.new | ||
34 | - @block.box = @box1 | ||
35 | - @block.save! | ||
36 | - | ||
37 | - @community.blocks<<@block | ||
38 | - @community.save! | ||
39 | - end | ||
40 | - | ||
41 | - should 'display community-block' do | ||
42 | - get :index, :profile => @community.identifier | ||
43 | - assert_tag :div, :attributes => {:class => 'community-block-logo'} | ||
44 | - assert_tag :div, :attributes => {:class => 'community-block-info'} | ||
45 | - assert_tag :div, :attributes => {:class => 'community-block-title'} | ||
46 | - assert_tag :div, :attributes => {:class => 'community-block-description'} | ||
47 | - end | ||
48 | - | ||
49 | - should 'display *leave* button when the user is logged in and is a member of the community' do | ||
50 | - get :index, :profile => @community.identifier | ||
51 | - assert_tag :span, :attributes => {:class => 'community-block-button icon-remove'} | ||
52 | - end | ||
53 | - | ||
54 | - should 'display *send email to administrators* button when the user is logged in and is a member of the community' do | ||
55 | - get :index, :profile => @community.identifier | ||
56 | - assert_match /\{"Send an e-mail":\{"href":"\/contact\/#{@community.identifier}\/new"\}\}/, @response.body | ||
57 | - end | ||
58 | - | ||
59 | - should 'display *report* button when the user is logged in and is a member of the community' do | ||
60 | - get :index, :profile => @community.identifier | ||
61 | - assert_match /\{"Report abuse":\{"href":"\/profile\/#{@community.identifier}\/report_abuse"\}\}/, @response.body | ||
62 | - end | ||
63 | - | ||
64 | - should 'display *join* button when the user is logged in and is not a member of the community' do | ||
65 | - @community.remove_member @user | ||
66 | - get :index, :profile => @community.identifier | ||
67 | - assert_tag :span, :attributes => {:class => 'community-block-button icon-add'} | ||
68 | - end | ||
69 | - | ||
70 | - should 'display *control panel* link option when the user is logged in and is community admin' do | ||
71 | - get :index, :profile => @community.identifier | ||
72 | - assert_match /\{"Control panel":\{"href":"\/myprofile\/#{@community.identifier}"\}\}/, @response.body | ||
73 | - end | ||
74 | - | ||
75 | - should 'display *join* button when the user is not logged in' do | ||
76 | - logout | ||
77 | - get :index, :profile => @community.identifier | ||
78 | - assert_tag :span, :attributes => {:class => 'community-block-button icon-add'} | ||
79 | - end | ||
80 | - | ||
81 | - should 'not display *arrow* button when the user is not logged in' do | ||
82 | - logout | ||
83 | - get :index, :profile => @community.identifier | ||
84 | - assert_no_tag :span, :attributes => {:class => 'community-block-button icon-arrow'} | ||
85 | - end | ||
86 | - | ||
87 | -end |
plugins/community_block/views/community_block.html.erb
@@ -23,7 +23,7 @@ | @@ -23,7 +23,7 @@ | ||
23 | <%= link_to( | 23 | <%= link_to( |
24 | content_tag('span','',:class => 'community-block-button icon-arrow'), | 24 | content_tag('span','',:class => 'community-block-button icon-arrow'), |
25 | '#', | 25 | '#', |
26 | - :onclick => "toggleSubmenu(this,'',#{j links.to_json}); return false;", | 26 | + :onclick => "toggleSubmenu(this,'',#{CGI::escapeHTML(links.to_json)}); return false;", |
27 | :class => 'simplemenu-trigger') %> | 27 | :class => 'simplemenu-trigger') %> |
28 | 28 | ||
29 | <% end %> | 29 | <% end %> |
@@ -32,11 +32,11 @@ | @@ -32,11 +32,11 @@ | ||
32 | <% if profile.members.include?(user) || profile.already_request_membership?(user) %> | 32 | <% if profile.members.include?(user) || profile.already_request_membership?(user) %> |
33 | <%= link_to( | 33 | <%= link_to( |
34 | content_tag('span', '', :class => 'community-block-button icon-remove'), | 34 | content_tag('span', '', :class => 'community-block-button icon-remove'), |
35 | - profile.leave_url) %> | 35 | + profile.leave_url, :class => 'join-community') %> |
36 | <% else %> | 36 | <% else %> |
37 | <%= link_to( | 37 | <%= link_to( |
38 | content_tag('span', '', :class => 'community-block-button icon-add'), | 38 | content_tag('span', '', :class => 'community-block-button icon-add'), |
39 | - profile.join_url) %> | 39 | + profile.join_url, :class => 'join-community') %> |
40 | <% end %> | 40 | <% end %> |
41 | <% else %> | 41 | <% else %> |
42 | <%= link_to( | 42 | <%= link_to( |
plugins/community_track/test/unit/community_track_plugin_test.rb
@@ -6,10 +6,13 @@ class CommunityTrackPluginTest < ActiveSupport::TestCase | @@ -6,10 +6,13 @@ class CommunityTrackPluginTest < ActiveSupport::TestCase | ||
6 | @plugin = CommunityTrackPlugin.new | 6 | @plugin = CommunityTrackPlugin.new |
7 | @profile = fast_create(Community) | 7 | @profile = fast_create(Community) |
8 | @params = {} | 8 | @params = {} |
9 | - @plugin.stubs(:context).returns(self) | 9 | + @context = mock |
10 | + @context.stubs(:profile).returns(@profile) | ||
11 | + @context.stubs(:params).returns(@params) | ||
12 | + @plugin.stubs(:context).returns(@context) | ||
10 | end | 13 | end |
11 | 14 | ||
12 | - attr_reader :profile, :params | 15 | + attr_reader :profile, :params, :context |
13 | 16 | ||
14 | should 'has name' do | 17 | should 'has name' do |
15 | assert CommunityTrackPlugin.plugin_name | 18 | assert CommunityTrackPlugin.plugin_name |
@@ -28,37 +31,37 @@ class CommunityTrackPluginTest < ActiveSupport::TestCase | @@ -28,37 +31,37 @@ class CommunityTrackPluginTest < ActiveSupport::TestCase | ||
28 | end | 31 | end |
29 | 32 | ||
30 | should 'do not return Track as a content type if profile is not a community' do | 33 | should 'do not return Track as a content type if profile is not a community' do |
31 | - @profile = Organization.new | 34 | + context.stubs(:profile).returns(Organization.new) |
32 | assert_not_includes @plugin.content_types, CommunityTrackPlugin::Track | 35 | assert_not_includes @plugin.content_types, CommunityTrackPlugin::Track |
33 | end | 36 | end |
34 | 37 | ||
35 | should 'do not return Track as a content type if there is a parent' do | 38 | should 'do not return Track as a content type if there is a parent' do |
36 | - parent = fast_create(Blog, :profile_id => @profile.id) | ||
37 | - @params[:parent_id] = parent.id | 39 | + parent = fast_create(Blog, :profile_id => profile.id) |
40 | + params[:parent_id] = parent.id | ||
38 | assert_not_includes @plugin.content_types, CommunityTrackPlugin::Track | 41 | assert_not_includes @plugin.content_types, CommunityTrackPlugin::Track |
39 | end | 42 | end |
40 | 43 | ||
41 | should 'return Step as a content type if parent is a Track' do | 44 | should 'return Step as a content type if parent is a Track' do |
42 | - parent = fast_create(CommunityTrackPlugin::Track, :profile_id => @profile.id) | ||
43 | - @params[:parent_id] = parent.id | 45 | + parent = fast_create(CommunityTrackPlugin::Track, :profile_id => profile.id) |
46 | + params[:parent_id] = parent.id | ||
44 | assert_includes @plugin.content_types, CommunityTrackPlugin::Step | 47 | assert_includes @plugin.content_types, CommunityTrackPlugin::Step |
45 | end | 48 | end |
46 | 49 | ||
47 | should 'do not return Step as a content type if parent is not a Track' do | 50 | should 'do not return Step as a content type if parent is not a Track' do |
48 | - parent = fast_create(Blog, :profile_id => @profile.id) | ||
49 | - @params[:parent_id] = parent.id | 51 | + parent = fast_create(Blog, :profile_id => profile.id) |
52 | + params[:parent_id] = parent.id | ||
50 | assert_not_includes @plugin.content_types, CommunityTrackPlugin::Step | 53 | assert_not_includes @plugin.content_types, CommunityTrackPlugin::Step |
51 | end | 54 | end |
52 | 55 | ||
53 | should 'return Track and Step as a content type if context has no params' do | 56 | should 'return Track and Step as a content type if context has no params' do |
54 | - parent = fast_create(Blog, :profile_id => @profile.id) | ||
55 | - expects(:respond_to?).with(:params).returns(false) | 57 | + parent = fast_create(Blog, :profile_id => profile.id) |
58 | + context.expects(:respond_to?).with(:params).returns(false) | ||
56 | assert_equivalent [CommunityTrackPlugin::Step, CommunityTrackPlugin::Track], @plugin.content_types | 59 | assert_equivalent [CommunityTrackPlugin::Step, CommunityTrackPlugin::Track], @plugin.content_types |
57 | end | 60 | end |
58 | 61 | ||
59 | should 'return Track and Step as a content type if params is nil' do | 62 | should 'return Track and Step as a content type if params is nil' do |
60 | - parent = fast_create(Blog, :profile_id => @profile.id) | ||
61 | - @params = nil | 63 | + parent = fast_create(Blog, :profile_id => profile.id) |
64 | + context.stubs(:params).returns(nil) | ||
62 | assert_equivalent [CommunityTrackPlugin::Step, CommunityTrackPlugin::Track], @plugin.content_types | 65 | assert_equivalent [CommunityTrackPlugin::Step, CommunityTrackPlugin::Track], @plugin.content_types |
63 | end | 66 | end |
64 | 67 |