Commit fa22035035adf0979d85b2b8cff42d7b24cdd012

Authored by Weblate
2 parents 2dadfc26 b9800000

Merge remote-tracking branch 'origin/master'

Showing 29 changed files with 231 additions and 150 deletions   Show diff stats
Gemfile
... ... @@ -41,8 +41,9 @@ group :cucumber do
41 41 gem 'selenium-webdriver', '~> 2.39.0'
42 42 end
43 43  
44   -# include plugin gemfiles
45   -Dir.glob(File.join('config', 'plugins', '*')).each do |plugin|
46   - plugin_gemfile = File.join(plugin, 'Gemfile')
47   - eval File.read(plugin_gemfile) if File.exists?(plugin_gemfile)
  44 +# include gemfiles from enabled plugins
  45 +# plugins in baseplugins/ are not included on purpose. They should not have any
  46 +# dependencies.
  47 +Dir.glob('config/plugins/*/Gemfile').each do |gemfile|
  48 + eval File.read(gemfile)
48 49 end
... ...
app/controllers/public/account_controller.rb
... ... @@ -193,7 +193,7 @@ class AccountController < ApplicationController
193 193 else
194 194 @change_password.errors[:base] << _('Could not find any user with %s equal to "%s".') % [fields_label, params[:value]]
195 195 end
196   - rescue ActiveRecord::RecordInvald
  196 + rescue ActiveRecord::RecordInvalid
197 197 @change_password.errors[:base] << _('Could not perform password recovery for the user.')
198 198 end
199 199 end
... ...
app/models/task.rb
... ... @@ -285,8 +285,9 @@ class Task &lt; ActiveRecord::Base
285 285 # If
286 286 def send_notification(action)
287 287 if sends_email?
288   - if self.requestor
289   - TaskMailer.generic_message("task_#{action}", self)
  288 + if self.requestor && !self.requestor.notification_emails.empty?
  289 + message = TaskMailer.generic_message("task_#{action}", self)
  290 + message.deliver if message
290 291 end
291 292 end
292 293 end
... ...
app/views/task_mailer/generic_message.text.erb 0 → 100644
... ... @@ -0,0 +1,9 @@
  1 +<%= _('Dear %s,') % @requestor %>
  2 +
  3 +<%= word_wrap(@message) %>
  4 +
  5 +<%= _('Greetings,') %>
  6 +
  7 +--
  8 +<%= _('%s team.') % @environment %>
  9 +<%= @url %>
... ...
app/views/task_mailer/task_activated.text.erb
... ... @@ -1 +0,0 @@
1   -task_cancelled.text.erb
2 0 \ No newline at end of file
app/views/task_mailer/task_cancelled.text.erb
... ... @@ -1,9 +0,0 @@
1   -<%= _('Dear %s,') % @requestor %>
2   -
3   -<%= word_wrap(@message) %>
4   -
5   -<%= _('Greetings,') %>
6   -
7   ---
8   -<%= _('%s team.') % @environment %>
9   -<%= @url %>
app/views/task_mailer/task_created.text.erb
... ... @@ -1 +0,0 @@
1   -task_cancelled.text.erb
2 0 \ No newline at end of file
app/views/task_mailer/task_finished.text.erb
... ... @@ -1 +0,0 @@
1   -task_cancelled.text.erb
2 0 \ No newline at end of file
debian/control
... ... @@ -51,6 +51,7 @@ Depends:
51 51 ruby-hpricot,
52 52 ruby-nokogiri,
53 53 ruby-acts-as-taggable-on,
  54 + ruby-progressbar,
54 55 ruby-prototype-rails,
55 56 ruby-rails-autolink,
56 57 memcached,
... ...
debian/noosfero.links
... ... @@ -15,4 +15,4 @@ var/lib/noosfero-data/public/thumbnails usr/share/noosfero/public/th
15 15 usr/share/noosfero/public/designs/themes/noosfero usr/share/noosfero/public/designs/themes/default
16 16 usr/share/noosfero/public/designs/icons/tango usr/share/noosfero/public/designs/icons/default
17 17 usr/share/noosfero/script/noosfero-plugins usr/sbin/noosfero-plugins
18   -usr/share/noosfero/Gemfile.lock /dev/null
  18 +/dev/null usr/share/noosfero/Gemfile.lock
... ...
lib/tasks/ci.rake
... ... @@ -10,6 +10,15 @@ namespace :ci do
10 10 File.exist?(f)
11 11 end
12 12  
  13 + changed_plugin_files = changed_files.select do |f|
  14 + f.split(File::SEPARATOR).first == 'plugins'
  15 + end
  16 + changed_plugins = changed_plugin_files.map do |f|
  17 + f.split(File::SEPARATOR)[1]
  18 + end.uniq
  19 +
  20 + changed_files -= changed_plugin_files
  21 +
13 22 # explicitly changed tests
14 23 tests = changed_files.select { |f| f =~ /test\/.*_test\.rb$/ }
15 24 features = changed_files.select { |f| f =~ /\.feature$/ }
... ... @@ -27,6 +36,13 @@ namespace :ci do
27 36 sh 'testrb', '-Itest', *tests unless tests.empty?
28 37 sh 'cucumber', *features unless features.empty?
29 38 sh 'cucumber', '-p', 'selenium', *features unless features.empty?
  39 +
  40 + changed_plugins.each do |plugin|
  41 + task = "test:noosfero_plugins:#{plugin}"
  42 + puts "Running #{task}"
  43 + Rake::Task[task].execute
  44 + end
  45 +
30 46 end
31 47  
32 48 end
... ...
lib/tasks/plugins_tests.rake
... ... @@ -104,7 +104,7 @@ def run_test(name, files)
104 104 end
105 105  
106 106 def run_testrb(files)
107   - sh 'testrb', '-Itest', *files
  107 + sh 'testrb', '-I.:test', *files
108 108 end
109 109  
110 110 def run_cucumber(profile, files)
... ...
plugins/comment_group/views/comment_group_plugin_profile/view_comments.rjs
... ... @@ -8,5 +8,5 @@ page.replace_html &quot;comment-count-#{@group_id}&quot;, @comments_count
8 8 if @no_more_pages
9 9 page.replace_html "comments_list_group_#{@group_id}_more", ""
10 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 12 end
... ...
plugins/community_block/test/functional/commmunity_block_plugin_profile_controller_test.rb 0 → 100644
... ... @@ -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 /\{&quot;Send an e-mail&quot;:\{&quot;href&quot;:&quot;\/contact\/#{@community.identifier}\/new&quot;\}\}/, @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 /\{&quot;Report abuse&quot;:\{&quot;href&quot;:&quot;\/profile\/#{@community.identifier}\/report_abuse&quot;\}\}/, @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 /\{&quot;Control panel&quot;:\{&quot;href&quot;:&quot;\/myprofile\/#{@community.identifier}&quot;\}\}/, @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   -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 /\{&quot;Send an e-mail&quot;:\{&quot;href&quot;:&quot;\/contact\/#{@community.identifier}\/new&quot;\}\}/, @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 /\{&quot;Report abuse&quot;:\{&quot;href&quot;:&quot;\/profile\/#{@community.identifier}\/report_abuse&quot;\}\}/, @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 /\{&quot;Control panel&quot;:\{&quot;href&quot;:&quot;\/myprofile\/#{@community.identifier}&quot;\}\}/, @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 23 <%= link_to(
24 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 27 :class => 'simplemenu-trigger') %>
28 28  
29 29 <% end %>
... ... @@ -32,11 +32,11 @@
32 32 <% if profile.members.include?(user) || profile.already_request_membership?(user) %>
33 33 <%= link_to(
34 34 content_tag('span', '', :class => 'community-block-button icon-remove'),
35   - profile.leave_url) %>
  35 + profile.leave_url, :class => 'join-community') %>
36 36 <% else %>
37 37 <%= link_to(
38 38 content_tag('span', '', :class => 'community-block-button icon-add'),
39   - profile.join_url) %>
  39 + profile.join_url, :class => 'join-community') %>
40 40 <% end %>
41 41 <% else %>
42 42 <%= link_to(
... ...
plugins/community_track/test/functional/community_track_plugin_content_viewer_controller_test.rb
... ... @@ -101,9 +101,6 @@ class ContentViewerControllerTest &lt; ActionController::TestCase
101 101 should 'render tracks in track list block' do
102 102 @block = CommunityTrackPlugin::TrackListBlock.create!(:box => @profile.boxes.last)
103 103 get :view_page, @step.url
104   - file = File.open('result.html', 'w+')
105   - file.write(@response.body)
106   - file.close
107 104 assert_tag :tag => 'div', :attributes => { :class => "item category_#{@track.category_name}" }, :descendant => { :tag => 'div', :attributes => { :class => 'steps' }, :descendant => { :tag => 'span', :attributes => { :class => "step #{@block.status_class(@step)}" } } }
108 105 end
109 106  
... ...
plugins/community_track/test/unit/community_track_plugin_test.rb
... ... @@ -6,10 +6,13 @@ class CommunityTrackPluginTest &lt; ActiveSupport::TestCase
6 6 @plugin = CommunityTrackPlugin.new
7 7 @profile = fast_create(Community)
8 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 13 end
11 14  
12   - attr_reader :profile, :params
  15 + attr_reader :profile, :params, :context
13 16  
14 17 should 'has name' do
15 18 assert CommunityTrackPlugin.plugin_name
... ... @@ -28,37 +31,37 @@ class CommunityTrackPluginTest &lt; ActiveSupport::TestCase
28 31 end
29 32  
30 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 35 assert_not_includes @plugin.content_types, CommunityTrackPlugin::Track
33 36 end
34 37  
35 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 41 assert_not_includes @plugin.content_types, CommunityTrackPlugin::Track
39 42 end
40 43  
41 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 47 assert_includes @plugin.content_types, CommunityTrackPlugin::Step
45 48 end
46 49  
47 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 53 assert_not_includes @plugin.content_types, CommunityTrackPlugin::Step
51 54 end
52 55  
53 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 59 assert_equivalent [CommunityTrackPlugin::Step, CommunityTrackPlugin::Track], @plugin.content_types
57 60 end
58 61  
59 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 65 assert_equivalent [CommunityTrackPlugin::Step, CommunityTrackPlugin::Track], @plugin.content_types
63 66 end
64 67  
... ...
plugins/custom_forms/test/functional/custom_forms_plugin_myprofile_controller_test.rb
... ... @@ -226,7 +226,7 @@ class CustomFormsPluginMyprofileControllerTest &lt; ActionController::TestCase
226 226 end
227 227  
228 228 should 'list pending submissions for a form' do
229   - person = fast_create(Person)
  229 + person = create_user('john').person
230 230 form = CustomFormsPlugin::Form.create!(:profile => profile, :name => 'Free Software', :for_admission => true)
231 231 task = CustomFormsPlugin::AdmissionSurvey.create!(:form_id => form.id, :target => person, :requestor => profile)
232 232  
... ...
plugins/custom_forms/test/unit/custom_forms_plugin/admission_survey_test.rb
... ... @@ -3,7 +3,7 @@ require File.dirname(__FILE__) + &#39;/../../../../../test/test_helper&#39;
3 3 class CustomFormsPlugin::AdmissionSurveyTest < ActiveSupport::TestCase
4 4 should 'add member to community on perform' do
5 5 profile = fast_create(Community)
6   - person = fast_create(Person)
  6 + person = create_user('john').person
7 7 form = CustomFormsPlugin::Form.create!(:name => 'Simple Form', :profile => profile)
8 8 task = CustomFormsPlugin::AdmissionSurvey.create!(:form_id => form.id, :target => person, :requestor => profile)
9 9  
... ...
plugins/custom_forms/test/unit/custom_forms_plugin/form_test.rb
... ... @@ -244,7 +244,7 @@ class CustomFormsPlugin::FormTest &lt; ActiveSupport::TestCase
244 244  
245 245 should 'cancel survey tasks after removing a form' do
246 246 profile = fast_create(Profile)
247   - person = fast_create(Person)
  247 + person = create_user('john').person
248 248  
249 249 form1 = CustomFormsPlugin::Form.create!(:name => 'Free Software', :profile => profile)
250 250 form2 = CustomFormsPlugin::Form.create!(:name => 'Operation System', :profile => profile)
... ...
plugins/custom_forms/test/unit/custom_forms_plugin/membership_survey_test.rb
... ... @@ -13,7 +13,7 @@ class CustomFormsPlugin::MembershipSurveyTest &lt; ActiveSupport::TestCase
13 13  
14 14 should 'create submission with answers on perform' do
15 15 profile = fast_create(Profile)
16   - person = fast_create(Person)
  16 + person = create_user('john').person
17 17 form = CustomFormsPlugin::Form.create!(:name => 'Simple Form', :profile => profile)
18 18 field = CustomFormsPlugin::Field.create!(:name => 'Name', :form => form)
19 19 task = CustomFormsPlugin::MembershipSurvey.create!(:form_id => form.id, :submission => {field.id.to_s => 'Jack'}, :target => person, :requestor => profile)
... ... @@ -31,7 +31,7 @@ class CustomFormsPlugin::MembershipSurveyTest &lt; ActiveSupport::TestCase
31 31  
32 32 should 'have a scope that retrieves all tasks requested by profile' do
33 33 profile = fast_create(Profile)
34   - person = fast_create(Person)
  34 + person = create_user('john').person
35 35 form = CustomFormsPlugin::Form.create!(:name => 'Simple Form', :profile => profile)
36 36 task1 = CustomFormsPlugin::MembershipSurvey.create!(:form_id => form.id, :target => person, :requestor => profile)
37 37 task2 = CustomFormsPlugin::MembershipSurvey.create!(:form_id => form.id, :target => person, :requestor => fast_create(Profile))
... ...
plugins/custom_forms/test/unit/ext/role_assingment_test.rb
... ... @@ -5,7 +5,7 @@ class RoleAssignmentsTest &lt; ActiveSupport::TestCase
5 5 environment = Environment.default
6 6 environment.enable_plugin(CustomFormsPlugin)
7 7 organization = fast_create(Organization)
8   - person = fast_create(Person)
  8 + person = create_user('john').person
9 9 f1 = CustomFormsPlugin::Form.create!(:profile => organization, :name => 'Form 1', :on_membership => true)
10 10 f2 = CustomFormsPlugin::Form.create!(:profile => organization, :name => 'Form 2', :on_membership => true)
11 11 f3 = CustomFormsPlugin::Form.create!(:profile => organization, :name => 'Form 3', :on_membership => false)
... ... @@ -19,7 +19,7 @@ class RoleAssignmentsTest &lt; ActiveSupport::TestCase
19 19 environment = Environment.default
20 20 environment.enable_plugin(CustomFormsPlugin)
21 21 organization = fast_create(Organization)
22   - person = fast_create(Person)
  22 + person = create_user('john').person
23 23 form = CustomFormsPlugin::Form.create!(:profile => organization, :name => 'Form', :on_membership => true, :access => 'associated')
24 24  
25 25 assert_difference 'CustomFormsPlugin::MembershipSurvey.count', 1 do
... ... @@ -31,7 +31,7 @@ class RoleAssignmentsTest &lt; ActiveSupport::TestCase
31 31 environment = Environment.default
32 32 environment.enable_plugin(CustomFormsPlugin)
33 33 organization = fast_create(Organization)
34   - person = fast_create(Person)
  34 + person = create_user('john').person
35 35 form1 = CustomFormsPlugin::Form.create!(:profile => organization, :name => 'Form 1', :on_membership => true)
36 36 organization.add_member(person)
37 37  
... ... @@ -59,7 +59,7 @@ class RoleAssignmentsTest &lt; ActiveSupport::TestCase
59 59 environment = Environment.default
60 60 environment.enable_plugin(CustomFormsPlugin)
61 61 organization = fast_create(Organization)
62   - person = fast_create(Person)
  62 + person = create_user('john').person
63 63 f1 = CustomFormsPlugin::Form.create!(:profile => organization, :name => 'Form 1', :for_admission => true)
64 64 f2 = CustomFormsPlugin::Form.create!(:profile => organization, :name => 'Form 2', :for_admission => true)
65 65 f3 = CustomFormsPlugin::Form.create!(:profile => organization, :name => 'Form 3', :for_admission => false)
... ...
plugins/remote_user/lib/remote_user_plugin.rb
... ... @@ -13,17 +13,27 @@ class RemoteUserPlugin &lt; Noosfero::Plugin
13 13  
14 14 begin
15 15 remote_user = request.headers["HTTP_REMOTE_USER"]
  16 + user_data = request.env['HTTP_REMOTE_USER_DATA']
16 17  
17   - if remote_user.nil?
  18 + if remote_user.blank?
18 19 if logged_in?
19 20 self.current_user.forget_me
20 21 reset_session
21 22 end
22 23 else
  24 + if user_data.blank?
  25 + remote_user_email = remote_user + '@remote.user'
  26 + remote_user_name = remote_user
  27 + else
  28 + user_data = JSON.parse(user_data)
  29 + remote_user_email = user_data['email']
  30 + remote_user_name = user_data['name']
  31 + end
  32 +
23 33 if !logged_in?
24 34 self.current_user = User.find_by_login(remote_user)
25 35 unless self.current_user
26   - self.current_user = User.create!(:login => remote_user, :email => (remote_user + '@remote.user'), :password => ('pw4'+remote_user), :password_confirmation => ('pw4'+remote_user))
  36 + self.current_user = User.create!(:login => remote_user, :email => remote_user_email, :name => remote_user_name, :password => ('pw4'+remote_user), :password_confirmation => ('pw4'+remote_user))
27 37 self.current_user.activate
28 38 end
29 39 self.current_user.save!
... ... @@ -34,7 +44,7 @@ class RemoteUserPlugin &lt; Noosfero::Plugin
34 44  
35 45 self.current_user = User.find_by_login(remote_user)
36 46 unless self.current_user
37   - self.current_user = User.create!(:login => remote_user, :email => (remote_user + '@remote.user'), :password => ('pw4'+remote_user), :password_confirmation => ('pw4'+remote_user))
  47 + self.current_user = User.create!(:login => remote_user, :email => remote_user_email, :name => remote_user_name, :password => ('pw4'+remote_user), :password_confirmation => ('pw4'+remote_user))
38 48 self.current_user.activate
39 49 end
40 50 self.current_user.save!
... ...
plugins/remote_user/test/functional/remote_user_plugin_test.rb
... ... @@ -42,26 +42,64 @@ class AccountControllerTest &lt; ActionController::TestCase
42 42 assert_equal user2.id, session[:user]
43 43 end
44 44  
45   - should 'create a new user if the remote user does not exist' do
  45 + should 'create a new user with remote_user_data if the remote user does not exist' do
46 46 User.destroy_all
47 47  
48 48 assert_equal 0, User.count
49 49  
50 50 @request.env["HTTP_REMOTE_USER"] = "testuser"
  51 + @request.env["CONTENT_TYPE"] = "application/json"
  52 + @request.env["HTTP_REMOTE_USER_DATA"] = '{"email":"testuser@domain.com", "name":"Test User"}'
51 53 get :index
52 54  
53 55 assert_equal 1, User.count
54 56 assert_equal "testuser", User.last.login
55 57 assert_equal true, User.last.activated?
56 58 assert_equal User.last.id, session[:user]
  59 + assert_equal "Test User", User.last.name
  60 + assert_equal "testuser@domain.com", User.last.email
57 61 end
58 62  
59   - should 'create a new user even if there is a logged user but the remote user is different' do
  63 + should 'create a new user with remote_user_data even if there is a logged user but the remote user is different' do
60 64 user = create_user('testuser', :email => 'testuser@example.com', :password => 'test', :password_confirmation => 'test')
61 65 user.activate
62 66  
63 67 login_as user.login
64 68  
  69 + @request.env["HTTP_REMOTE_USER"] = 'another_user'
  70 + @request.env["CONTENT_TYPE"] = "application/json"
  71 + @request.env["HTTP_REMOTE_USER_DATA"] = '{"email":"another_user@domain.com", "name":"Another User"}'
  72 + get :index
  73 +
  74 + assert_equal 2, User.count
  75 + assert_equal "another_user", User.last.login
  76 + assert_equal true, User.last.activated?
  77 + assert_equal User.last.id, session[:user]
  78 + assert_equal "Another User", User.last.name
  79 + assert_equal "another_user@domain.com", User.last.email
  80 + end
  81 +
  82 + should 'create a new user without remote_user_data if the remote user does not exist' do
  83 + User.destroy_all
  84 +
  85 + assert_equal 0, User.count
  86 +
  87 + @request.env["HTTP_REMOTE_USER"] = "testuser"
  88 + get :index
  89 +
  90 + assert_equal 1, User.count
  91 + assert_equal "testuser", User.last.login
  92 + assert_equal true, User.last.activated?
  93 + assert_equal User.last.id, session[:user]
  94 + assert_equal "testuser", User.last.name
  95 + assert_equal "testuser@remote.user", User.last.email
  96 + end
  97 +
  98 + should 'create a new user without remote_user_data even if there is a logged user but the remote user is different' do
  99 + user = create_user('testuser', :email => 'testuser@example.com', :password => 'test', :password_confirmation => 'test')
  100 + user.activate
  101 +
  102 + login_as user.login
65 103  
66 104 @request.env["HTTP_REMOTE_USER"] = 'another_user'
67 105 get :index
... ... @@ -70,5 +108,23 @@ class AccountControllerTest &lt; ActionController::TestCase
70 108 assert_equal "another_user", User.last.login
71 109 assert_equal true, User.last.activated?
72 110 assert_equal User.last.id, session[:user]
  111 + assert_equal "another_user", User.last.name
  112 + assert_equal "another_user@remote.user", User.last.email
  113 + end
  114 +
  115 + should 'logout if there is a current logged user but not a remote user' do
  116 + user1 = create_user('testuser', :email => 'testuser@example.com', :password => 'test', :password_confirmation => 'test')
  117 + user1.activate
  118 +
  119 + login_as user1.login
  120 +
  121 + get :index
  122 +
  123 + assert session[:user].blank?
  124 +
  125 + @request.env["HTTP_REMOTE_USER"] = ""
  126 + get :index
  127 +
  128 + assert session[:user].blank?
73 129 end
74 130 end
... ...
plugins/solr/install.rb
... ... @@ -8,7 +8,6 @@ Dir[tasks_dir].each do |file|
8 8 load file
9 9 end
10 10  
11   -begin
12   - Rake::Task['solr:download'].invoke
13   -rescue Exception => exception
14   -end
  11 +puts 'To download solr:'
  12 +puts '$ cd plugins/solr'
  13 +puts '$ rake solr:download'
... ...
plugins/spaminator/test/unit/spaminator_plugin/spaminator_test.rb
... ... @@ -50,6 +50,7 @@ class SpaminatorPlugin::SpaminatorTest &lt; ActiveSupport::TestCase
50 50 end
51 51  
52 52 should 'process only people from the environment and that are not abusers' do
  53 + Person.delete_all
53 54 p1 = fast_create(Person)
54 55 p2 = fast_create(Person)
55 56 p3 = fast_create(Person, :environment_id => fast_create(Environment))
... ...
script/noosfero-plugins
... ... @@ -98,9 +98,12 @@ _enable(){
98 98 dependencies_ok=true
99 99 dependencies_file="$source/dependencies.rb"
100 100 if [ -e $source/Gemfile ]; then
101   - if ! (cd $source && bundle --local); then
  101 + gemfile=$(mktemp --tmpdir=.)
  102 + cat Gemfile $source/Gemfile > $gemfile
  103 + if ! RUBYOPT='' BUNDLE_GEMFILE="$gemfile" bundle --local --quiet; then
102 104 dependencies_ok=false
103 105 fi
  106 + rm -f $gemfile $gemfile.lock
104 107 fi
105 108 if ! run $dependencies_file; then
106 109 dependencies_ok=false
... ...
test/unit/task_mailer_test.rb
... ... @@ -18,7 +18,7 @@ class TaskMailerTest &lt; ActiveSupport::TestCase
18 18 task.expects(:target_notification_description).returns('the task')
19 19  
20 20 requestor = mock()
21   - requestor.expects(:notification_emails).returns(['requestor@example.com'])
  21 + requestor.expects(:notification_emails).returns(['requestor@example.com']).at_least_once
22 22 requestor.expects(:name).returns('my name')
23 23  
24 24 environment = mock()
... ... @@ -41,7 +41,7 @@ class TaskMailerTest &lt; ActiveSupport::TestCase
41 41 task.expects(:target_notification_description).returns('the task')
42 42  
43 43 requestor = mock()
44   - requestor.expects(:notification_emails).returns(['requestor@example.com'])
  44 + requestor.expects(:notification_emails).returns(['requestor@example.com']).at_least_once
45 45 requestor.expects(:name).returns('my name')
46 46  
47 47 environment = mock()
... ... @@ -65,7 +65,7 @@ class TaskMailerTest &lt; ActiveSupport::TestCase
65 65 task.expects(:target_notification_description).returns('the task')
66 66  
67 67 requestor = mock()
68   - requestor.expects(:notification_emails).returns(['requestor@example.com'])
  68 + requestor.expects(:notification_emails).returns(['requestor@example.com']).at_least_once
69 69 requestor.expects(:name).returns('my name')
70 70  
71 71 environment = mock()
... ...