Commit 8d3b55fa2ef0906b3b40570b82b77063f88f598c

Authored by Antonio Terceiro
1 parent 60362022

Remove the "Join community popup" feature

The HTTP caching feature conflicts with it. This was a crappy feature,
anyway.

(ActionItem1608)
app/controllers/public/profile_controller.rb
1 class ProfileController < PublicController 1 class ProfileController < PublicController
2 2
3 needs_profile 3 needs_profile
4 - before_filter :check_access_to_profile, :except => [:join, :refuse_join, :refuse_for_now, :index] 4 + before_filter :check_access_to_profile, :except => [:join, :index]
5 before_filter :store_before_join, :only => [:join] 5 before_filter :store_before_join, :only => [:join]
6 - before_filter :login_required, :only => [:join, :refuse_join, :leave, :unblock] 6 + before_filter :login_required, :only => [:join, :leave, :unblock]
7 7
8 helper TagsHelper 8 helper TagsHelper
9 9
@@ -112,20 +112,6 @@ class ProfileController &lt; PublicController @@ -112,20 +112,6 @@ class ProfileController &lt; PublicController
112 end 112 end
113 end 113 end
114 114
115 - def refuse_join  
116 - p = current_user.person  
117 - p.refused_communities << profile  
118 - p.save  
119 - redirect_to profile.url  
120 - end  
121 -  
122 - def refuse_for_now  
123 - session[:no_asking] ||= []  
124 - session[:no_asking].shift if session[:no_asking].size >= 10  
125 - session[:no_asking] << profile.id  
126 - render :text => '', :layout => false  
127 - end  
128 -  
129 def unblock 115 def unblock
130 if current_user.person.is_admin?(profile.environment) 116 if current_user.person.is_admin?(profile.environment)
131 profile.unblock 117 profile.unblock
app/helpers/application_helper.rb
@@ -939,20 +939,6 @@ module ApplicationHelper @@ -939,20 +939,6 @@ module ApplicationHelper
939 end 939 end
940 end 940 end
941 941
942 - def ask_to_join?  
943 - return if !environment.enabled?(:join_community_popup)  
944 - return if params[:action] == 'join'  
945 - return unless profile && profile.kind_of?(Community)  
946 - if (session[:no_asking] && session[:no_asking].include?(profile.id))  
947 - return false  
948 - end  
949 - if logged_in?  
950 - user.ask_to_join?(profile)  
951 - else  
952 - true  
953 - end  
954 - end  
955 -  
956 def icon_theme_stylesheet_path 942 def icon_theme_stylesheet_path
957 theme_path = "/designs/icons/#{environment.icon_theme}/style.css" 943 theme_path = "/designs/icons/#{environment.icon_theme}/style.css"
958 if File.exists?(File.join(RAILS_ROOT, 'public', theme_path)) 944 if File.exists?(File.join(RAILS_ROOT, 'public', theme_path))
app/models/environment.rb
@@ -93,7 +93,6 @@ class Environment &lt; ActiveRecord::Base @@ -93,7 +93,6 @@ class Environment &lt; ActiveRecord::Base
93 'disable_contact_person' => _('Disable contact for people'), 93 'disable_contact_person' => _('Disable contact for people'),
94 'disable_contact_community' => _('Disable contact for groups/communities'), 94 'disable_contact_community' => _('Disable contact for groups/communities'),
95 'enterprise_registration' => __('Enterprise registration'), 95 'enterprise_registration' => __('Enterprise registration'),
96 - 'join_community_popup' => _('Ask users to join a group/community with a popup'),  
97 96
98 'enterprise_activation' => __('Enable activation of enterprises'), 97 'enterprise_activation' => __('Enable activation of enterprises'),
99 'wysiwyg_editor_for_environment_home' => _('Use WYSIWYG editor to edit environment home page'), 98 'wysiwyg_editor_for_environment_home' => _('Use WYSIWYG editor to edit environment home page'),
app/views/blocks/profile_info_actions/community.rhtml
@@ -19,5 +19,11 @@ @@ -19,5 +19,11 @@
19 </li> 19 </li>
20 <% end %> 20 <% end %>
21 21
  22 + <% else %>
  23 +
  24 + <li>
  25 + <%= link_to content_tag('span', _('Join')), profile.join_url, :class => 'button with-text icon-add', :title => _('Join this community') %>
  26 + </li>
  27 +
22 <% end %> 28 <% end %>
23 </ul> 29 </ul>
app/views/shared/join_community_popup.rhtml
@@ -1,13 +0,0 @@ @@ -1,13 +0,0 @@
1 -<div id='join-community-popup'>  
2 - <h3> <%= __('Do you want to join this community?') %> </h3>  
3 -  
4 - <% form_tag(profile.join_url) do %>  
5 - <%= hidden_field(:confirmation, 1) if logged_in? %>  
6 - <% button_bar do %>  
7 - <%= submit_button(:ok,"Yes") %>  
8 - <%= button_to_remote(:cancel, _('Not now'), :url => profile.join_url.merge({:controller => 'profile', :action => 'refuse_for_now', :profile => profile.identifier}), :loaded => '$("join-community-popup").hide()') %>  
9 - <%= button(:cancel, _('No and don\'t ask again'), :controller => 'profile', :action => 'refuse_join', :profile => profile.identifier) if logged_in? %>  
10 - <% end %>  
11 - <% end %>  
12 -</div>  
13 -<%= draggable_element('join-community-popup') %>  
app/views/shared/noosfero_layout_features.rhtml
@@ -2,10 +2,6 @@ @@ -2,10 +2,6 @@
2 <%= render :file => 'shared/theme_test_panel' %> 2 <%= render :file => 'shared/theme_test_panel' %>
3 <% end %> 3 <% end %>
4 4
5 - <% if ask_to_join? %>  
6 - <%= render :file => 'shared/join_community_popup' %>  
7 - <% end %>  
8 -  
9 <script type="text/javascript"> 5 <script type="text/javascript">
10 $$("a").each(function(a){ 6 $$("a").each(function(a){
11 if ( a.href == document.location.href ) { 7 if ( a.href == document.location.href ) {
features/join_community.feature
@@ -11,70 +11,14 @@ Feature: join a community @@ -11,70 +11,14 @@ Feature: join a community
11 | identifier | name | 11 | identifier | name |
12 | sample-community | Sample Community | 12 | sample-community | Sample Community |
13 13
14 - Scenario: a logged user asks to join a community with "join_community_popup"  
15 - Given feature "join_community_popup" is enabled on environment  
16 - And I am logged in as "joaosilva"  
17 - And I go to Sample Community's homepage  
18 - And I press "Yes"  
19 - Then I should be on Sample Community's homepage  
20 - And "Joao Silva" should be a member of "Sample Community"  
21 -  
22 - Scenario: a logged user asks to join a community without "join_community_popup"  
23 - Given feature "join_community_popup" is disabled on environment  
24 - And I am logged in as "joaosilva"  
25 - And I am on Sample Community's homepage  
26 - And I follow "Join"  
27 - And I should see "Are you sure you want to join Sample Community?"  
28 - When I press "Yes, I want to join."  
29 - Then "Joao Silva" should be a member of "Sample Community"  
30 -  
31 - Scenario: a not logged user asks join a community  
32 - Given feature "join_community_popup" is enabled on environment  
33 - And I am not logged in  
34 - And I go to Sample Community's homepage  
35 - And I press "Yes"  
36 - And I fill in the following:  
37 - | Username | joaosilva |  
38 - | Password | 123456 |  
39 - And I press "Log in"  
40 - And I should see "Are you sure you want to join Sample Community?"  
41 - When I press "Yes, I want to join"  
42 - Then I should be on Sample Community's homepage  
43 - And "Joao Silva" should be a member of "Sample Community"  
44 -  
45 - Scenario: a non-user ask to join a community  
46 - Given feature "join_community_popup" is enabled on environment  
47 - And I am not logged in  
48 - And I go to Sample Community's homepage  
49 - And I press "Yes"  
50 - And I follow "New user"  
51 - And I fill in the following within ".no-boxes":  
52 - | e-mail | jose@domain.br |  
53 - | Username | joseoliveira |  
54 - | Password | 123456 |  
55 - | Password confirmation | 123456 |  
56 - | Name | Jose Oliveira |  
57 - And I press "Sign up"  
58 - And I should see "Are you sure you want to join Sample Community?"  
59 - When I press "Yes, I want to join"  
60 - Then I should be on Sample Community's homepage  
61 - And "Jose Oliveira" should be a member of "Sample Community"  
62 -  
63 Scenario: ask confirmation before join community 14 Scenario: ask confirmation before join community
64 - Given I am on the homepage  
65 - And the following communities  
66 - | name |  
67 - | Community to join |  
68 - And I am logged in as "joaosilva"  
69 - When I am on /profile/community-to-join/join  
70 - Then I should see "Are you sure you want to join Community to join" 15 + Given I am logged in as "joaosilva"
  16 + And I am on Sample Community's homepage
  17 + When I follow "Join"
  18 + Then I should see "Are you sure you want to join Sample Community"
71 19
72 Scenario: dont ask confirmation before join community if already member 20 Scenario: dont ask confirmation before join community if already member
73 - Given I am on the homepage  
74 - And the following communities  
75 - | name |  
76 - | Community to join |  
77 - And joaosilva is member of community-to-join 21 + Given joaosilva is member of sample-community
78 And I am logged in as "joaosilva" 22 And I am logged in as "joaosilva"
79 - When I am on /profile/community-to-join/join 23 + When I go to /profile/sample-community
80 Then I should not see "Are you sure you want to join Community to join" 24 Then I should not see "Are you sure you want to join Community to join"
test/functional/profile_controller_test.rb
@@ -462,39 +462,6 @@ class ProfileControllerTest &lt; Test::Unit::TestCase @@ -462,39 +462,6 @@ class ProfileControllerTest &lt; Test::Unit::TestCase
462 assert_redirected_to :controller => 'account', :action => 'login' 462 assert_redirected_to :controller => 'account', :action => 'login'
463 end 463 end
464 464
465 - should 'require login to refuse join community' do  
466 - community = Community.create!(:name => 'my test community', :closed => true)  
467 - get :refuse_join, :profile => community.identifier  
468 -  
469 - assert_redirected_to :controller => 'account', :action => 'login'  
470 - end  
471 -  
472 - should 'register join refusal' do  
473 - community = Community.create!(:name => 'my test community', :closed => true)  
474 - login_as @profile.identifier  
475 -  
476 - get :refuse_join, :profile => community.identifier  
477 -  
478 - p = Person.find(@profile.id)  
479 - assert_includes p.refused_communities, community  
480 - end  
481 -  
482 - should 'register in session join refusal' do  
483 - community = Community.create!(:name => 'my test community')  
484 - get :refuse_for_now, :profile => community.identifier  
485 -  
486 - assert_not_nil session[:no_asking]  
487 - assert_includes session[:no_asking], community.id  
488 - end  
489 -  
490 - should 'record only 10 communities in session' do  
491 - @request.session[:no_asking] = (1..10).to_a  
492 - community = Community.create!(:name => 'my test community')  
493 - get :refuse_for_now, :profile => community.identifier  
494 -  
495 - assert_equal ((2..10).to_a + [community.id]), @request.session[:no_asking]  
496 - end  
497 -  
498 should 'present confirmation before leaving a profile' do 465 should 'present confirmation before leaving a profile' do
499 community = Community.create!(:name => 'my test community') 466 community = Community.create!(:name => 'my test community')
500 community.add_member(profile) 467 community.add_member(profile)
test/unit/application_helper_test.rb
@@ -390,145 +390,6 @@ class ApplicationHelperTest &lt; Test::Unit::TestCase @@ -390,145 +390,6 @@ class ApplicationHelperTest &lt; Test::Unit::TestCase
390 assert_equal '<span>SIGNUP_FIELD</span>', optional_field(profile, 'field', 'SIGNUP_FIELD') 390 assert_equal '<span>SIGNUP_FIELD</span>', optional_field(profile, 'field', 'SIGNUP_FIELD')
391 end 391 end
392 392
393 - should 'not ask_to_join unless profile defined' do  
394 - stubs(:params).returns({})  
395 -  
396 - e = Environment.default  
397 - e.stubs(:enabled?).with(:join_community_popup).returns(true)  
398 - stubs(:environment).returns(e)  
399 -  
400 - stubs(:profile).returns(nil)  
401 - assert ! ask_to_join?  
402 - end  
403 -  
404 - should 'not ask_to_join unless profile is community' do  
405 - stubs(:params).returns({})  
406 - e = Environment.default  
407 - e.stubs(:enabled?).with(:join_community_popup).returns(true)  
408 - stubs(:environment).returns(e)  
409 -  
410 - p = create_user('test_user').person  
411 - stubs(:profile).returns(p)  
412 - assert ! ask_to_join?  
413 - end  
414 -  
415 - should 'not ask_to_join if action join' do  
416 - expects(:params).returns({:action => 'join'})  
417 -  
418 - e = Environment.default  
419 - e.stubs(:enabled?).with(:join_community_popup).returns(true)  
420 - stubs(:environment).returns(e)  
421 -  
422 - c = fast_create(Community, :name => 'test_comm', :identifier => 'test_comm')  
423 - stubs(:profile).returns(c)  
424 - stubs(:logged_in?).returns(false)  
425 - assert ! ask_to_join?  
426 - end  
427 -  
428 - should 'ask_to_join if its not logged and in a community' do  
429 - stubs(:params).returns({})  
430 -  
431 - e = Environment.default  
432 - e.stubs(:enabled?).with(:join_community_popup).returns(true)  
433 - stubs(:environment).returns(e)  
434 -  
435 - c = fast_create(Community, :name => 'test_comm', :identifier => 'test_comm')  
436 - stubs(:profile).returns(c)  
437 - stubs(:logged_in?).returns(false)  
438 - assert ask_to_join?  
439 - end  
440 -  
441 - should 'ask_to_join if user say so' do  
442 - stubs(:params).returns({})  
443 -  
444 - e = Environment.default  
445 - e.stubs(:enabled?).with(:join_community_popup).returns(true)  
446 - stubs(:environment).returns(e)  
447 -  
448 - c = fast_create(Community, :name => 'test_comm', :identifier => 'test_comm')  
449 - stubs(:profile).returns(c)  
450 - stubs(:logged_in?).returns(true)  
451 - p = create_user('test_user').person  
452 - p.stubs(:ask_to_join?).with(c).returns(true)  
453 - stubs(:user).returns(p)  
454 -  
455 - assert ask_to_join?  
456 - end  
457 -  
458 - should 'not ask_to_join if user say no' do  
459 - stubs(:params).returns({})  
460 -  
461 - e = Environment.default  
462 - e.stubs(:enabled?).with(:join_community_popup).returns(true)  
463 - stubs(:environment).returns(e)  
464 - c = fast_create(Community, :name => 'test_comm', :identifier => 'test_comm')  
465 - stubs(:profile).returns(c)  
466 - stubs(:logged_in?).returns(true)  
467 - p = create_user('test_user').person  
468 - p.stubs(:ask_to_join?).with(c).returns(false)  
469 - stubs(:user).returns(p)  
470 -  
471 - assert !ask_to_join?  
472 - end  
473 -  
474 - should 'not ask_to_join if environment say no even if its not logged and in a community' do  
475 - stubs(:params).returns({})  
476 -  
477 - e = Environment.default  
478 - e.stubs(:enabled?).with(:join_community_popup).returns(false)  
479 - stubs(:environment).returns(e)  
480 - c = fast_create(Community, :name => 'test_comm', :identifier => 'test_comm')  
481 - stubs(:profile).returns(c)  
482 - stubs(:logged_in?).returns(false)  
483 - assert !ask_to_join?  
484 - end  
485 -  
486 - should 'not ask_to_join if environment say no even if user say so' do  
487 - stubs(:params).returns({})  
488 -  
489 - e = Environment.default  
490 - e.stubs(:enabled?).with(:join_community_popup).returns(false)  
491 - stubs(:environment).returns(e)  
492 - c = fast_create(Community, :name => 'test_comm', :identifier => 'test_comm')  
493 - stubs(:profile).returns(c)  
494 - stubs(:logged_in?).returns(true)  
495 - p = create_user('test_user').person  
496 - p.stubs(:ask_to_join?).with(c).returns(true)  
497 - stubs(:user).returns(p)  
498 -  
499 - assert !ask_to_join?  
500 - end  
501 -  
502 - should 'not ask_to_join if its recorded in the session' do  
503 - stubs(:params).returns({})  
504 -  
505 - e = Environment.default  
506 - e.stubs(:enabled?).with(:join_community_popup).returns(true)  
507 - stubs(:environment).returns(e)  
508 -  
509 - c = fast_create(Community, :name => 'test_comm', :identifier => 'test_comm')  
510 - stubs(:profile).returns(c)  
511 - stubs(:logged_in?).returns(false)  
512 - stubs(:session).returns({:no_asking => [c.id]})  
513 -  
514 - assert !ask_to_join?  
515 - end  
516 -  
517 - should 'not ask_to_join if its recorded in the session even for authenticated users' do  
518 - stubs(:params).returns({})  
519 -  
520 - e = Environment.default  
521 - e.stubs(:enabled?).with(:join_community_popup).returns(true)  
522 - stubs(:environment).returns(e)  
523 -  
524 - c = fast_create(Community, :name => 'test_comm', :identifier => 'test_comm')  
525 - stubs(:profile).returns(c)  
526 - stubs(:logged_in?).returns(true)  
527 - stubs(:session).returns({:no_asking => [c.id]})  
528 -  
529 - assert !ask_to_join?  
530 - end  
531 -  
532 should 'use default icon theme when there is no stylesheet file for the current icon theme' do 393 should 'use default icon theme when there is no stylesheet file for the current icon theme' do
533 e = Environment.default 394 e = Environment.default
534 e.icon_theme = 'something-very-unlikely' 395 e.icon_theme = 'something-very-unlikely'