Commit b741bc26c8bb0ce20b6568126b7ade19b4e7bee0
Exists in
master
and in
28 other branches
Merge branch 'stable'
Conflicts: po/pt/noosfero.po
Showing
11 changed files
with
150 additions
and
23 deletions
Show diff stats
app/controllers/public/account_controller.rb
@@ -17,7 +17,7 @@ class AccountController < ApplicationController | @@ -17,7 +17,7 @@ class AccountController < ApplicationController | ||
17 | def login | 17 | def login |
18 | @user = User.new | 18 | @user = User.new |
19 | @person = @user.build_person | 19 | @person = @user.build_person |
20 | - store_location(request.referer) | 20 | + store_location(request.referer) unless session[:return_to] |
21 | return unless request.post? | 21 | return unless request.post? |
22 | self.current_user = User.authenticate(params[:user][:login], params[:user][:password]) if params[:user] | 22 | self.current_user = User.authenticate(params[:user][:login], params[:user][:password]) if params[:user] |
23 | if logged_in? | 23 | if logged_in? |
@@ -290,4 +290,5 @@ class AccountController < ApplicationController | @@ -290,4 +290,5 @@ class AccountController < ApplicationController | ||
290 | redirect_back_or_default(:controller => 'home') | 290 | redirect_back_or_default(:controller => 'home') |
291 | end | 291 | end |
292 | end | 292 | end |
293 | + | ||
293 | end | 294 | end |
app/controllers/public/profile_controller.rb
@@ -55,6 +55,7 @@ class ProfileController < PublicController | @@ -55,6 +55,7 @@ class ProfileController < PublicController | ||
55 | end | 55 | end |
56 | 56 | ||
57 | def join | 57 | def join |
58 | + store_location(request.referer) | ||
58 | @wizard = params[:wizard] | 59 | @wizard = params[:wizard] |
59 | if request.post? && params[:confirmation] | 60 | if request.post? && params[:confirmation] |
60 | profile.add_member(current_user.person) | 61 | profile.add_member(current_user.person) |
@@ -65,7 +66,6 @@ class ProfileController < PublicController | @@ -65,7 +66,6 @@ class ProfileController < PublicController | ||
65 | redirect_to_before_join | 66 | redirect_to_before_join |
66 | end | 67 | end |
67 | else | 68 | else |
68 | - store_location(request.referer) | ||
69 | if request.xhr? | 69 | if request.xhr? |
70 | render :layout => false | 70 | render :layout => false |
71 | end | 71 | end |
app/models/comment.rb
@@ -21,9 +21,9 @@ class Comment < ActiveRecord::Base | @@ -21,9 +21,9 @@ class Comment < ActiveRecord::Base | ||
21 | 21 | ||
22 | def author_name | 22 | def author_name |
23 | if author | 23 | if author |
24 | - author.name | 24 | + author.short_name |
25 | else | 25 | else |
26 | - name | 26 | + author_id ? '' : name |
27 | end | 27 | end |
28 | end | 28 | end |
29 | 29 | ||
@@ -39,6 +39,14 @@ class Comment < ActiveRecord::Base | @@ -39,6 +39,14 @@ class Comment < ActiveRecord::Base | ||
39 | article.view_url.merge(:anchor => anchor) | 39 | article.view_url.merge(:anchor => anchor) |
40 | end | 40 | end |
41 | 41 | ||
42 | + def message | ||
43 | + author_id ? _('(removed user)') : ('<br />' + _('(unauthenticated user)')) | ||
44 | + end | ||
45 | + | ||
46 | + def removed_user_image | ||
47 | + '/images/icons-app/user_icon_size-minor.png' | ||
48 | + end | ||
49 | + | ||
42 | def anchor | 50 | def anchor |
43 | "comment-#{id}" | 51 | "comment-#{id}" |
44 | end | 52 | end |
app/views/content_viewer/_comment.rhtml
@@ -8,15 +8,16 @@ | @@ -8,15 +8,16 @@ | ||
8 | <% end %> | 8 | <% end %> |
9 | 9 | ||
10 | <% if comment.author %> | 10 | <% if comment.author %> |
11 | - <%= link_to content_tag( 'span', comment.author.short_name, :class => 'comment-info' ), comment.author.url, | 11 | + <%= link_to content_tag( 'span', comment.author_name, :class => 'comment-info' ), comment.author.url, |
12 | :class => 'comment-picture', | 12 | :class => 'comment-picture', |
13 | :style => 'background-image:url(%s)' % profile_icon(comment.author, :minor) | 13 | :style => 'background-image:url(%s)' % profile_icon(comment.author, :minor) |
14 | %> | 14 | %> |
15 | <% else %> | 15 | <% else %> |
16 | <%# unauthenticated user: display gravatar icon %> | 16 | <%# unauthenticated user: display gravatar icon %> |
17 | - <%= content_tag 'span', content_tag('span', comment.name + '<br/>'+ _('(unauthenticated user)'), :class => 'comment-info'), | 17 | + <% url_image = comment.author_id ? comment.removed_user_image : str_gravatar_url_for( comment.email, :size => 50 ) %> |
18 | + <%= content_tag 'span', content_tag('span', comment.author_name + comment.message, :class => 'comment-info'), | ||
18 | :class => 'comment-picture', | 19 | :class => 'comment-picture', |
19 | - :style => 'background-image:url(%s)' % str_gravatar_url_for( comment.email, :size => 50 ) | 20 | + :style => 'background-image:url(%s)' % url_image |
20 | %> | 21 | %> |
21 | <% end %> | 22 | <% end %> |
22 | 23 |
app/views/shared/join_community_popup.rhtml
1 | <div id='join-community-popup'> | 1 | <div id='join-community-popup'> |
2 | <h3> <%= __('Do you want to join this community?') %> </h3> | 2 | <h3> <%= __('Do you want to join this community?') %> </h3> |
3 | 3 | ||
4 | - <% button_bar do %> | ||
5 | - <% if logged_in? %> | ||
6 | - <%= button(:ok, _('Yes'), profile.join_url.merge(:confirmation => '1'), :method => :post) %> | ||
7 | - <% else %> | ||
8 | - <%= button(:ok, _('Yes'), profile.join_url) %> | 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? %> | ||
9 | <% end %> | 10 | <% end %> |
10 | - <%= 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()') %> | ||
11 | - <%= button(:cancel, _('No and don\'t ask again'), :controller => 'profile', :action => 'refuse_join', :profile => profile.identifier) if logged_in? %> | ||
12 | <% end %> | 11 | <% end %> |
13 | </div> | 12 | </div> |
14 | <%= draggable_element('join-community-popup') %> | 13 | <%= draggable_element('join-community-popup') %> |
@@ -0,0 +1,61 @@ | @@ -0,0 +1,61 @@ | ||
1 | +Feature: join a community | ||
2 | + As a user | ||
3 | + I want to join a community | ||
4 | + In order to interact with other people | ||
5 | + | ||
6 | + Background: | ||
7 | + Given the following users | ||
8 | + | login | name | | ||
9 | + | joaosilva | Joao Silva | | ||
10 | + Given the following communities | ||
11 | + | identifier | name | | ||
12 | + | sample-community | Sample Community | | ||
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 "I want to participate" | ||
51 | + And I fill in the following: | ||
52 | + | e-mail | jose@domain.br | | ||
53 | + | Username | joseoliveira | | ||
54 | + | Password | 123456 | | ||
55 | + | Password confirmation | 123456 | | ||
56 | + | Full 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" |
@@ -0,0 +1,41 @@ | @@ -0,0 +1,41 @@ | ||
1 | +Feature: login | ||
2 | + As a user | ||
3 | + I want to login | ||
4 | + In order to view pages logged in | ||
5 | + | ||
6 | + Background: | ||
7 | + Given the following users | ||
8 | + | login | name | | ||
9 | + | joaosilva | Joao Silva | | ||
10 | + | ||
11 | + Scenario: login from portal homepage | ||
12 | + Given I am not logged in | ||
13 | + And I go to the homepage | ||
14 | + And I fill in the following: | ||
15 | + | Username | joaosilva | | ||
16 | + | Password | 123456 | | ||
17 | + When I press "Log in" | ||
18 | + Then I should be on the homepage | ||
19 | + | ||
20 | + Scenario: login from some profile page | ||
21 | + Given I am not logged in | ||
22 | + And the following users | ||
23 | + | login | name | | ||
24 | + | mariasilva | Maria Silva | | ||
25 | + And I go to Maria Silva's homepage | ||
26 | + And I follow "Login" | ||
27 | + And I fill in the following: | ||
28 | + | Username | joaosilva | | ||
29 | + | Password | 123456 | | ||
30 | + When I press "Log in" | ||
31 | + Then I should be on Maria Silva's homepage | ||
32 | + | ||
33 | + Scenario: view my control panel | ||
34 | + Given I am not logged in | ||
35 | + And I go to Joao Silva's control panel | ||
36 | + And I should be on login page | ||
37 | + And I fill in the following: | ||
38 | + | Username | joaosilva | | ||
39 | + | Password | 123456 | | ||
40 | + When I press "Log in" | ||
41 | + Then I should be on Joao Silva's control panel |
po/pt/noosfero.po
@@ -13,7 +13,7 @@ msgid "" | @@ -13,7 +13,7 @@ msgid "" | ||
13 | msgstr "" | 13 | msgstr "" |
14 | "Project-Id-Version: noosfero 0.20.0\n" | 14 | "Project-Id-Version: noosfero 0.20.0\n" |
15 | "POT-Creation-Date: 2009-09-29 18:56-0300\n" | 15 | "POT-Creation-Date: 2009-09-29 18:56-0300\n" |
16 | -"PO-Revision-Date: 2009-11-04 16:22-0300\n" | 16 | +"PO-Revision-Date: 2009-11-13 16:02-0300\n" |
17 | "Last-Translator: Joenio Costa <joenio@colivre.coop.br>\n" | 17 | "Last-Translator: Joenio Costa <joenio@colivre.coop.br>\n" |
18 | "Language-Team: LANGUAGE <LL@li.org>\n" | 18 | "Language-Team: LANGUAGE <LL@li.org>\n" |
19 | "MIME-Version: 1.0\n" | 19 | "MIME-Version: 1.0\n" |
@@ -1373,7 +1373,7 @@ msgstr "Este bloco apresenta os integrantes de um coletivo." | @@ -1373,7 +1373,7 @@ msgstr "Este bloco apresenta os integrantes de um coletivo." | ||
1373 | 1373 | ||
1374 | #: app/models/profile_info_block.rb:4 | 1374 | #: app/models/profile_info_block.rb:4 |
1375 | msgid "Profile information block" | 1375 | msgid "Profile information block" |
1376 | -msgstr "Bloco de informações do profile" | 1376 | +msgstr "Bloco de informações do perfil" |
1377 | 1377 | ||
1378 | #: app/models/profile_info_block.rb:8 | 1378 | #: app/models/profile_info_block.rb:8 |
1379 | msgid "" | 1379 | msgid "" |
@@ -1385,7 +1385,7 @@ msgstr "" | @@ -1385,7 +1385,7 @@ msgstr "" | ||
1385 | 1385 | ||
1386 | #: app/models/profile_list_block.rb:6 | 1386 | #: app/models/profile_list_block.rb:6 |
1387 | msgid "A block that displays random profiles" | 1387 | msgid "A block that displays random profiles" |
1388 | -msgstr "Um bloco que apresenta profiles aleatórios" | 1388 | +msgstr "Um bloco que apresenta perfis aleatórios" |
1389 | 1389 | ||
1390 | #: app/models/profile_list_block.rb:55 | 1390 | #: app/models/profile_list_block.rb:55 |
1391 | msgid "{#} People or Groups" | 1391 | msgid "{#} People or Groups" |
@@ -2004,7 +2004,7 @@ msgstr "Empreendimentos Favoritos" | @@ -2004,7 +2004,7 @@ msgstr "Empreendimentos Favoritos" | ||
2004 | 2004 | ||
2005 | #: app/models/favorite_enterprises_block.rb:8 | 2005 | #: app/models/favorite_enterprises_block.rb:8 |
2006 | msgid "This block lists the favorite enterprises of the user." | 2006 | msgid "This block lists the favorite enterprises of the user." |
2007 | -msgstr "Este block lista os empreendimentos favoritos to usuário." | 2007 | +msgstr "Este bloco lista os empreendimentos favoritos do usuário." |
2008 | 2008 | ||
2009 | #: app/models/favorite_enterprises_block.rb:12 | 2009 | #: app/models/favorite_enterprises_block.rb:12 |
2010 | msgid "A block that displays your favorite enterprises" | 2010 | msgid "A block that displays your favorite enterprises" |
@@ -2020,7 +2020,7 @@ msgstr "categorizaçãoperfil" | @@ -2020,7 +2020,7 @@ msgstr "categorizaçãoperfil" | ||
2020 | 2020 | ||
2021 | #: app/models/tags_block.rb:8 | 2021 | #: app/models/tags_block.rb:8 |
2022 | msgid "Block listing content count by tag" | 2022 | msgid "Block listing content count by tag" |
2023 | -msgstr "Block que lista a contagem de conteúdo por tag" | 2023 | +msgstr "Bloco que lista a contagem de conteúdo por tag" |
2024 | 2024 | ||
2025 | #: app/models/tags_block.rb:12 | 2025 | #: app/models/tags_block.rb:12 |
2026 | msgid "tags" | 2026 | msgid "tags" |
@@ -2881,7 +2881,7 @@ msgstr "Conteúdo recente" | @@ -2881,7 +2881,7 @@ msgstr "Conteúdo recente" | ||
2881 | 2881 | ||
2882 | #: app/models/recent_documents_block.rb:12 | 2882 | #: app/models/recent_documents_block.rb:12 |
2883 | msgid "This block lists your recent content." | 2883 | msgid "This block lists your recent content." |
2884 | -msgstr "Este block listas seu conteúdo recent." | 2884 | +msgstr "Este bloco listas seu conteúdo recente." |
2885 | 2885 | ||
2886 | #: app/models/recent_documents_block.rb:31 | 2886 | #: app/models/recent_documents_block.rb:31 |
2887 | msgid "All content" | 2887 | msgid "All content" |
test/functional/content_viewer_controller_test.rb
@@ -883,4 +883,16 @@ class ContentViewerControllerTest < Test::Unit::TestCase | @@ -883,4 +883,16 @@ class ContentViewerControllerTest < Test::Unit::TestCase | ||
883 | post :view_page, :profile => profile.identifier, :page => [ 'myarticle' ], :comment => { :title => 'crap!', :body => 'I think that this article is crap' } | 883 | post :view_page, :profile => profile.identifier, :page => [ 'myarticle' ], :comment => { :title => 'crap!', :body => 'I think that this article is crap' } |
884 | assert_not_equal yesterday, assigns(:page).updated_at | 884 | assert_not_equal yesterday, assigns(:page).updated_at |
885 | end | 885 | end |
886 | + | ||
887 | + should 'display message if user was removed' do | ||
888 | + article = profile.articles.create(:name => 'comment test') | ||
889 | + to_be_removed = create_user('removed_user').person | ||
890 | + comment = article.comments.create(:author => to_be_removed, :title => 'Test Comment', :body => 'My author does not exist =(') | ||
891 | + to_be_removed.destroy | ||
892 | + | ||
893 | + get :view_page, :profile => profile.identifier, :page => article.explode_path | ||
894 | + | ||
895 | + assert_tag :tag => 'span', :content => '(removed user)', :attributes => {:class => 'comment-info'} | ||
896 | + end | ||
897 | + | ||
886 | end | 898 | end |
test/functional/profile_controller_test.rb
@@ -601,7 +601,7 @@ class ProfileControllerTest < Test::Unit::TestCase | @@ -601,7 +601,7 @@ class ProfileControllerTest < Test::Unit::TestCase | ||
601 | login_as(profile.identifier) | 601 | login_as(profile.identifier) |
602 | 602 | ||
603 | assert_nil @request.session[:return_to] | 603 | assert_nil @request.session[:return_to] |
604 | - @request.expects(:referer).returns("/profile/redirect_to") | 604 | + @request.expects(:referer).returns("/profile/redirect_to").at_least_once |
605 | 605 | ||
606 | get :join, :profile => community.identifier | 606 | get :join, :profile => community.identifier |
607 | 607 | ||
@@ -611,7 +611,7 @@ class ProfileControllerTest < Test::Unit::TestCase | @@ -611,7 +611,7 @@ class ProfileControllerTest < Test::Unit::TestCase | ||
611 | should 'redirect to stored location after join community' do | 611 | should 'redirect to stored location after join community' do |
612 | community = Community.create!(:name => 'my test community') | 612 | community = Community.create!(:name => 'my test community') |
613 | 613 | ||
614 | - @request.session[:return_to] = "/profile/#{community.identifier}/to_go" | 614 | + @request.expects(:referer).returns("/profile/#{community.identifier}/to_go") |
615 | login_as(profile.identifier) | 615 | login_as(profile.identifier) |
616 | 616 | ||
617 | post :join, :profile => community.identifier, :confirmation => '1' | 617 | post :join, :profile => community.identifier, :confirmation => '1' |
@@ -632,7 +632,7 @@ class ProfileControllerTest < Test::Unit::TestCase | @@ -632,7 +632,7 @@ class ProfileControllerTest < Test::Unit::TestCase | ||
632 | should 'redirect to location before login after join community' do | 632 | should 'redirect to location before login after join community' do |
633 | community = Community.create!(:name => 'my test community') | 633 | community = Community.create!(:name => 'my test community') |
634 | 634 | ||
635 | - @request.session[:before_join] = "/profile/#{community.identifier}/to_go" | 635 | + @request.expects(:referer).returns("/profile/#{community.identifier}/to_go") |
636 | login_as(profile.identifier) | 636 | login_as(profile.identifier) |
637 | 637 | ||
638 | post :join, :profile => community.identifier, :confirmation => '1' | 638 | post :join, :profile => community.identifier, :confirmation => '1' |
test/unit/comment_test.rb
@@ -78,6 +78,10 @@ class CommentTest < Test::Unit::TestCase | @@ -78,6 +78,10 @@ class CommentTest < Test::Unit::TestCase | ||
78 | assert_equal 'anonymous coward', Comment.new(:name => 'anonymous coward').author_name | 78 | assert_equal 'anonymous coward', Comment.new(:name => 'anonymous coward').author_name |
79 | end | 79 | end |
80 | 80 | ||
81 | + should 'provide empty text for author name if user was removed ' do | ||
82 | + assert_equal '', Comment.new(:author_id => 9999).author_name | ||
83 | + end | ||
84 | + | ||
81 | should "provide author e-mail for athenticated authors" do | 85 | should "provide author e-mail for athenticated authors" do |
82 | owner = create_user('testuser').person | 86 | owner = create_user('testuser').person |
83 | assert_equal owner.email, Comment.new(:author => owner).author_email | 87 | assert_equal owner.email, Comment.new(:author => owner).author_email |