Commit b2e08160e08a0bba5881f0e23b4fd7702717fc0f
Exists in
master
and in
29 other branches
Merge branch 'master' of gitlab.com:noosfero/noosfero
Showing
7 changed files
with
49 additions
and
25 deletions
Show diff stats
app/helpers/boxes_helper.rb
... | ... | @@ -227,7 +227,7 @@ module BoxesHelper |
227 | 227 | |
228 | 228 | # DEPRECATED. Do not use this. |
229 | 229 | def import_blocks_stylesheets(options = {}) |
230 | - @blocks_css_files ||= current_blocks.map{|b|'blocks/' + block.class.name.to_css_class}.uniq | |
230 | + @blocks_css_files ||= current_blocks.map{|block|'blocks/' + block.class.name.to_css_class}.uniq | |
231 | 231 | stylesheet_import(@blocks_css_files, options) |
232 | 232 | end |
233 | 233 | def block_css_classes(block) | ... | ... |
test/functional/mailconf_controller_test.rb
... | ... | @@ -2,16 +2,17 @@ require File.dirname(__FILE__) + '/../test_helper' |
2 | 2 | |
3 | 3 | class MailconfControllerTest < ActionController::TestCase |
4 | 4 | |
5 | - all_fixtures | |
6 | - | |
7 | 5 | def setup |
8 | 6 | @controller = MailconfController.new |
9 | 7 | @request = ActionController::TestRequest.new |
10 | 8 | @response = ActionController::TestResponse.new |
9 | + User.destroy_all | |
10 | + @user = create_user('ze') | |
11 | 11 | |
12 | 12 | MailConf.stubs(:enabled?).returns(true) |
13 | 13 | MailConf.stubs(:webmail_url).returns('http://web.mail.net/') |
14 | 14 | end |
15 | + attr_accessor :user | |
15 | 16 | |
16 | 17 | should 'check if mail is enabled' do |
17 | 18 | MailConf.expects(:enabled?).returns(false) |
... | ... | @@ -29,7 +30,8 @@ class MailconfControllerTest < ActionController::TestCase |
29 | 30 | end |
30 | 31 | |
31 | 32 | should 'not be edited by others' do |
32 | - login_as('johndoe') | |
33 | + another = create_user('johndoe') | |
34 | + login_as(another.login) | |
33 | 35 | get :index, :profile => 'ze' |
34 | 36 | assert_response 403 |
35 | 37 | end |
... | ... | @@ -43,7 +45,7 @@ class MailconfControllerTest < ActionController::TestCase |
43 | 45 | should 'expose user to templates' do |
44 | 46 | login_as('ze') |
45 | 47 | get :index, :profile => 'ze' |
46 | - assert_equal users(:ze), assigns(:user) | |
48 | + assert_equal user, assigns(:user) | |
47 | 49 | end |
48 | 50 | |
49 | 51 | should 'present enable/disable for e-mail use' do |
... | ... | @@ -58,7 +60,7 @@ class MailconfControllerTest < ActionController::TestCase |
58 | 60 | |
59 | 61 | should 'display correctly the state false of e-mail enable/disable' do |
60 | 62 | login_as('ze') |
61 | - users(:ze).update_attributes!(:enable_email => false) | |
63 | + user.update_attributes!(:enable_email => false) | |
62 | 64 | get :index, :profile => 'ze' |
63 | 65 | assert_tag :tag => 'a', :content => 'Enable e-Mail' |
64 | 66 | assert_no_tag :tag => 'a', :content => 'Disable e-Mail', :attributes => { :href => '/myprofile/ze/mailconf/disable' } |
... | ... | @@ -91,7 +93,7 @@ class MailconfControllerTest < ActionController::TestCase |
91 | 93 | |
92 | 94 | should 'save mail enable/disable as false' do |
93 | 95 | login_as('ze') |
94 | - assert users(:ze).enable_email! | |
96 | + assert user.enable_email! | |
95 | 97 | post :disable, :profile => 'ze' |
96 | 98 | assert !Profile['ze'].user.enable_email |
97 | 99 | end |
... | ... | @@ -122,8 +124,8 @@ class MailconfControllerTest < ActionController::TestCase |
122 | 124 | |
123 | 125 | should 'not display input for enable/disable e-mail when has pending_enable_email' do |
124 | 126 | login_as('ze') |
125 | - users(:ze).update_attribute(:environment_id, Environment.default.id) | |
126 | - EmailActivation.create!(:requestor => users(:ze).person, :target => Environment.default) | |
127 | + user.update_attribute(:environment_id, Environment.default.id) | |
128 | + EmailActivation.create!(:requestor => user.person, :target => Environment.default) | |
127 | 129 | get :index, :profile => 'ze' |
128 | 130 | assert_no_tag :tag => 'input', :attributes => {:name => 'user[enable_email]', :type => 'checkbox'} |
129 | 131 | end | ... | ... |
test/functional/profile_controller_test.rb
... | ... | @@ -1383,17 +1383,21 @@ class ProfileControllerTest < ActionController::TestCase |
1383 | 1383 | assert_equal "Comment successfully added.", assigns(:message) |
1384 | 1384 | end |
1385 | 1385 | |
1386 | - should 'display comment in wall if user was removed' do | |
1386 | + should 'display comment in wall if user was removed after click in view all comments' do | |
1387 | 1387 | UserStampSweeper.any_instance.stubs(:current_user).returns(profile) |
1388 | 1388 | article = TinyMceArticle.create!(:profile => profile, :name => 'An article about free software') |
1389 | 1389 | to_be_removed = create_user('removed_user').person |
1390 | 1390 | comment = Comment.create!(:author => to_be_removed, :title => 'Test Comment', :body => 'My author does not exist =(', :source_id => article.id, :source_type => 'Article') |
1391 | 1391 | to_be_removed.destroy |
1392 | 1392 | |
1393 | + activity = ActionTracker::Record.last | |
1394 | + | |
1393 | 1395 | login_as(profile.identifier) |
1394 | - get :index, :profile => profile.identifier | |
1396 | + get :more_comments, :profile => profile.identifier, :activity => activity.id, :comment_page => 1, :tab_action => 'wall' | |
1395 | 1397 | |
1396 | - assert_tag :tag => 'span', :content => '(removed user)', :attributes => {:class => 'comment-user-status comment-user-status-wall icon-user-removed'} | |
1398 | + assert_select_rjs :insert_html do | |
1399 | + assert_select 'span', :content => '(removed user)', :attributes => {:class => 'comment-user-status comment-user-status-wall icon-user-removed'} | |
1400 | + end | |
1397 | 1401 | end |
1398 | 1402 | |
1399 | 1403 | should 'not display spam comments in wall' do |
... | ... | @@ -1407,7 +1411,7 @@ class ProfileControllerTest < ActionController::TestCase |
1407 | 1411 | assert !/This article makes me hungry/.match(@response.body), 'Spam comment was shown!' |
1408 | 1412 | end |
1409 | 1413 | |
1410 | - should 'display comment in wall from non logged users' do | |
1414 | + should 'display comment in wall from non logged users after click in view all comments' do | |
1411 | 1415 | UserStampSweeper.any_instance.stubs(:current_user).returns(profile) |
1412 | 1416 | article = TinyMceArticle.create!(:profile => profile, :name => 'An article about free software') |
1413 | 1417 | comment = Comment.create!(:name => 'outside user', :email => 'outside@localhost.localdomain', :title => 'Test Comment', :body => 'My author does not exist =(', :source_id => article.id, :source_type => 'Article') |
... | ... | @@ -1415,7 +1419,14 @@ class ProfileControllerTest < ActionController::TestCase |
1415 | 1419 | login_as(profile.identifier) |
1416 | 1420 | get :index, :profile => profile.identifier |
1417 | 1421 | |
1418 | - assert_tag :tag => 'span', :content => '(unauthenticated user)', :attributes => {:class => 'comment-user-status comment-user-status-wall icon-user-unknown'} | |
1422 | + activity = ActionTracker::Record.last | |
1423 | + | |
1424 | + login_as(profile.identifier) | |
1425 | + get :more_comments, :profile => profile.identifier, :activity => activity.id, :comment_page => 1, :tab_action => 'wall' | |
1426 | + | |
1427 | + assert_select_rjs :insert_html do | |
1428 | + assert_select 'span', :content => '(unauthenticated user)', :attributes => {:class => 'comment-user-status comment-user-status-wall icon-user-unknown'} | |
1429 | + end | |
1419 | 1430 | end |
1420 | 1431 | |
1421 | 1432 | should 'add locale on mailing' do | ... | ... |
test/functional/users_controller_test.rb
... | ... | @@ -11,10 +11,16 @@ class UsersControllerTest < ActionController::TestCase |
11 | 11 | @request = ActionController::TestRequest.new |
12 | 12 | @response = ActionController::TestResponse.new |
13 | 13 | |
14 | - admin_user = create_user_with_permission('adminuser', 'manage_environment_users', Environment.default) | |
14 | + Environment.destroy_all | |
15 | + @environment = fast_create(Environment, :is_default => true) | |
16 | + | |
17 | + | |
18 | + admin_user = create_user_with_permission('adminuser', 'manage_environment_users', environment) | |
15 | 19 | login_as('adminuser') |
16 | 20 | end |
17 | 21 | |
22 | + attr_accessor :environment | |
23 | + | |
18 | 24 | should 'not access without right permission' do |
19 | 25 | create_user('guest') |
20 | 26 | login_as 'guest' |
... | ... | @@ -63,6 +69,7 @@ class UsersControllerTest < ActionController::TestCase |
63 | 69 | |
64 | 70 | should 'set admin role' do |
65 | 71 | person = create_user.person |
72 | + Role.create!(:name => 'Admin', :key => 'environment_administrator', :environment_id => environment.id, :permissions => ['view_environment_admin_panel']) | |
66 | 73 | assert_equal false, person.is_admin? |
67 | 74 | post :set_admin_role, :id => person.id, :q => '' |
68 | 75 | person.reload |
... | ... | @@ -70,8 +77,9 @@ class UsersControllerTest < ActionController::TestCase |
70 | 77 | end |
71 | 78 | |
72 | 79 | should 'reset admin role' do |
73 | - environment = Environment.default | |
74 | 80 | person = create_user.person |
81 | + Role.create!(:name => 'Admin', :key => 'environment_administrator', :environment_id => environment.id, :permissions => ['view_environment_admin_panel']) | |
82 | + | |
75 | 83 | environment.add_admin(person) |
76 | 84 | assert person.is_admin? |
77 | 85 | ... | ... |
test/integration/forgot_password_test.rb
... | ... | @@ -19,7 +19,7 @@ class ForgotPasswordTest < ActionController::IntegrationTest |
19 | 19 | assert_response :success |
20 | 20 | assert_tag :tag => 'form', :attributes => { :action => '/account/forgot_password', :method => 'post' } |
21 | 21 | |
22 | - post '/account/forgot_password', :change_password => { :field => 'login', :value => 'forgotten', :environment_id => Environment.default.id } | |
22 | + post '/account/forgot_password', :field => 'login', :value => 'forgotten', :environment_id => Environment.default.id | |
23 | 23 | |
24 | 24 | assert_response :success |
25 | 25 | assert_template 'password_recovery_sent' |
... | ... | @@ -52,7 +52,7 @@ class ForgotPasswordTest < ActionController::IntegrationTest |
52 | 52 | assert_response :success |
53 | 53 | assert_tag :tag => 'form', :attributes => { :action => '/account/forgot_password', :method => 'post' } |
54 | 54 | |
55 | - post '/account/forgot_password', :change_password => { :field => 'email', :value => 'forgotten@localhost.localdomain', :environment_id => Environment.default.id } | |
55 | + post '/account/forgot_password', :field => 'email', :value => 'forgotten@localhost.localdomain', :environment_id => Environment.default.id | |
56 | 56 | |
57 | 57 | assert_response :success |
58 | 58 | assert_template 'password_recovery_sent' | ... | ... |
test/unit/profile_test.rb
... | ... | @@ -1300,7 +1300,6 @@ class ProfileTest < ActiveSupport::TestCase |
1300 | 1300 | |
1301 | 1301 | should 'list folder articles' do |
1302 | 1302 | profile = fast_create(Profile) |
1303 | - Article.destroy_all | |
1304 | 1303 | p1 = Folder.create!(:name => 'parent1', :profile => profile) |
1305 | 1304 | p2 = Blog.create!(:name => 'parent2', :profile => profile) |
1306 | 1305 | |
... | ... | @@ -1761,7 +1760,7 @@ class ProfileTest < ActiveSupport::TestCase |
1761 | 1760 | env = fast_create(Environment) |
1762 | 1761 | roles = %w(foo bar profile_foo profile_bar).map{ |r| Role.create!(:name => r, :environment_id => env.id, :permissions => ["some"]) } |
1763 | 1762 | Role.create! :name => 'test', :environment_id => env.id + 1 |
1764 | - assert_equal roles, Profile::Roles.all_roles(env.id) | |
1763 | + assert_equivalent roles, Profile::Roles.all_roles(env.id) | |
1765 | 1764 | end |
1766 | 1765 | |
1767 | 1766 | should 'define method for role' do | ... | ... |
test/unit/user_test.rb
... | ... | @@ -337,10 +337,8 @@ class UserTest < ActiveSupport::TestCase |
337 | 337 | Person.any_instance.stubs(:created_at).returns(DateTime.parse('16-08-2010')) |
338 | 338 | expected_hash = { |
339 | 339 | 'login' => 'x_and_y', 'is_admin' => true, 'since_month' => 8, |
340 | - 'chat_enabled' => false, 'since_year' => 2010, 'avatar' => | |
341 | - 'http://www.gravatar.com/avatar/a0517761d5125820c28d87860bc7c02e?only_path=false&d=&size=20', | |
342 | - 'email_domain' => nil, 'amount_of_friends' => 0, | |
343 | - 'friends_list' => {}, 'enterprises' => [], | |
340 | + 'chat_enabled' => false, 'since_year' => 2010, 'email_domain' => nil, | |
341 | + 'amount_of_friends' => 0, 'friends_list' => {}, 'enterprises' => [], | |
344 | 342 | } |
345 | 343 | |
346 | 344 | assert_equal expected_hash['login'], person.user.data_hash['login'] |
... | ... | @@ -348,7 +346,13 @@ class UserTest < ActiveSupport::TestCase |
348 | 346 | assert_equal expected_hash['since_month'], person.user.data_hash['since_month'] |
349 | 347 | assert_equal expected_hash['chat_enabled'], person.user.data_hash['chat_enabled'] |
350 | 348 | assert_equal expected_hash['since_year'], person.user.data_hash['since_year'] |
351 | - assert_equal expected_hash['avatar'], person.user.data_hash['avatar'] | |
349 | + | |
350 | + # Avatar stuff | |
351 | + assert_match 'http://www.gravatar.com/avatar/a0517761d5125820c28d87860bc7c02e', person.user.data_hash['avatar'] | |
352 | + assert_match 'only_path=false', person.user.data_hash['avatar'] | |
353 | + assert_match 'd=', person.user.data_hash['avatar'] | |
354 | + assert_match 'size=20', person.user.data_hash['avatar'] | |
355 | + | |
352 | 356 | assert_equal expected_hash['email_domain'], person.user.data_hash['email_domain'] |
353 | 357 | assert_equal expected_hash['amount_of_friends'], person.user.data_hash['amount_of_friends'] |
354 | 358 | assert_equal expected_hash['friends_list'], person.user.data_hash['friends_list'] | ... | ... |