Commit f3ac17d4c094d4f04032915a7f2da1b9ee339d0e
1 parent
a3bfec81
Exists in
staging
and in
39 other branches
rails4: fix broken tests after merge
Showing
18 changed files
with
49 additions
and
30 deletions
Show diff stats
app/controllers/application_controller.rb
| ... | ... | @@ -65,8 +65,6 @@ class ApplicationController < ActionController::Base |
| 65 | 65 | helper :language |
| 66 | 66 | |
| 67 | 67 | include DesignHelper |
| 68 | - | |
| 69 | - # Be sure to include AuthenticationSystem in Application Controller instead | |
| 70 | 68 | include AuthenticatedSystem |
| 71 | 69 | include PermissionCheck |
| 72 | 70 | ... | ... |
app/helpers/action_tracker_helper.rb
| ... | ... | @@ -67,19 +67,19 @@ module ActionTrackerHelper |
| 67 | 67 | } |
| 68 | 68 | end |
| 69 | 69 | |
| 70 | - def create_product_description | |
| 70 | + def create_product_description ta | |
| 71 | 71 | _('created the product %{title}') % { |
| 72 | 72 | title: link_to(truncate(ta.get_name), ta.get_url), |
| 73 | 73 | } |
| 74 | 74 | end |
| 75 | 75 | |
| 76 | - def update_product_description | |
| 76 | + def update_product_description ta | |
| 77 | 77 | _('updated the product %{title}') % { |
| 78 | 78 | title: link_to(truncate(ta.get_name), ta.get_url), |
| 79 | 79 | } |
| 80 | 80 | end |
| 81 | 81 | |
| 82 | - def remove_product_description | |
| 82 | + def remove_product_description ta | |
| 83 | 83 | _('removed the product %{title}') % { |
| 84 | 84 | title: truncate(ta.get_name), |
| 85 | 85 | } | ... | ... |
app/mailers/application_mailer.rb
app/models/person_notifier.rb
| ... | ... | @@ -77,9 +77,8 @@ class PersonNotifier |
| 77 | 77 | |
| 78 | 78 | end |
| 79 | 79 | |
| 80 | - class Mailer < ActionMailer::Base | |
| 80 | + class Mailer < ApplicationMailer | |
| 81 | 81 | |
| 82 | - helper ApplicationHelper | |
| 83 | 82 | helper ActionTrackerHelper |
| 84 | 83 | |
| 85 | 84 | def session |
| ... | ... | @@ -88,8 +87,8 @@ class PersonNotifier |
| 88 | 87 | |
| 89 | 88 | def content_summary(person, notifications, tasks) |
| 90 | 89 | if person.environment |
| 91 | - ActionMailer::Base.asset_host = person.environment.top_url | |
| 92 | - ActionMailer::Base.default_url_options[:host] = person.environment.default_hostname | |
| 90 | + ApplicationMailer.asset_host = person.environment.top_url | |
| 91 | + ApplicationMailer.default_url_options[:host] = person.environment.default_hostname | |
| 93 | 92 | end |
| 94 | 93 | |
| 95 | 94 | @current_theme = 'default' | ... | ... |
app/models/profile_list_block.rb
| ... | ... | @@ -16,7 +16,7 @@ class ProfileListBlock < Block |
| 16 | 16 | |
| 17 | 17 | def profile_list |
| 18 | 18 | result = nil |
| 19 | - public_profiles = profiles.public.includes([:image,:domains,:preferred_domain,:environment]) | |
| 19 | + public_profiles = profiles.is_public.includes([:image,:domains,:preferred_domain,:environment]) | |
| 20 | 20 | if !prioritize_profiles_with_image |
| 21 | 21 | result = public_profiles.all(:limit => get_limit, :order => 'profiles.updated_at DESC').sort_by{ rand } |
| 22 | 22 | elsif profiles.visible.with_image.count >= get_limit |
| ... | ... | @@ -28,7 +28,7 @@ result = public_profiles.all(:limit => get_limit, :order => 'profiles.updated_at |
| 28 | 28 | end |
| 29 | 29 | |
| 30 | 30 | def profile_count |
| 31 | - profiles.public.length | |
| 31 | + profiles.is_public.length | |
| 32 | 32 | end |
| 33 | 33 | |
| 34 | 34 | # the title of the block. Probably will be overriden in subclasses. | ... | ... |
app/views/person_notifier/mailer/_create_product.html.erb
0 → 120000
app/views/person_notifier/mailer/_favorite_enterprise.html.erb
0 → 120000
app/views/person_notifier/mailer/_remove_product.html.erb
0 → 120000
app/views/person_notifier/mailer/_update_product.html.erb
0 → 120000
app/views/profile/_create_product.html.erb
| ... | ... | @@ -3,7 +3,7 @@ |
| 3 | 3 | </div> |
| 4 | 4 | <div class='profile-activity-description'> |
| 5 | 5 | <p class='profile-activity-text'><%= link_to activity.user.short_name(nil), activity.user.url %> <%= describe activity %></p> |
| 6 | - <p class='profile-activity-time'><%= time_ago_as_sentence activity.created_at %></p> | |
| 6 | + <p class='profile-activity-time'><%= time_ago_in_words activity.created_at %></p> | |
| 7 | 7 | |
| 8 | 8 | <div class='profile-wall-actions'> |
| 9 | 9 | <%= link_to_function(_('Remove'), 'remove_item_wall(this, \'%s\', \'%s\', \'%s\'); return false ;' % [".profile-activity-item", url_for(:profile => params[:profile], :action => :remove_activity, :activity_id => activity.id, :view => params[:view]), _('Are you sure you want to remove this activity and all its replies?')]) if logged_in? && current_person == @profile %> | ... | ... |
app/views/profile/_favorite_enterprise.html.erb
| ... | ... | @@ -5,7 +5,7 @@ |
| 5 | 5 | <p class='profile-activity-text'> |
| 6 | 6 | <%= link_to activity.user.short_name(nil), activity.user.url %> <%= describe activity %> |
| 7 | 7 | </p> |
| 8 | - <p class='profile-activity-time'><%= time_ago_as_sentence activity.created_at %></p> | |
| 8 | + <p class='profile-activity-time'><%= time_ago_in_words activity.created_at %></p> | |
| 9 | 9 | |
| 10 | 10 | <div class='profile-wall-actions'> |
| 11 | 11 | <%= link_to_function(_('Remove'), 'remove_item_wall(this, \'%s\', \'%s\', \'%s\'); return false ;' % [".profile-activity-item", url_for(:profile => params[:profile], :action => :remove_activity, :activity_id => activity.id, :view => params[:view]), _('Are you sure you want to remove this activity and all its replies?')]) if logged_in? && current_person == @profile %> | ... | ... |
app/views/profile/_remove_product.html.erb
| ... | ... | @@ -2,7 +2,7 @@ |
| 2 | 2 | </div> |
| 3 | 3 | <div class='profile-activity-description'> |
| 4 | 4 | <p class='profile-activity-text'><%= link_to activity.user.short_name(nil), activity.user.url %> <%= describe activity %></p> |
| 5 | - <p class='profile-activity-time'><%= time_ago_as_sentence activity.created_at %></p> | |
| 5 | + <p class='profile-activity-time'><%= time_ago_in_words activity.created_at %></p> | |
| 6 | 6 | |
| 7 | 7 | <div class='profile-wall-actions'> |
| 8 | 8 | <%= link_to_function(_('Remove'), 'remove_item_wall(this, \'%s\', \'%s\', \'%s\'); return false ;' % [".profile-activity-item", url_for(:profile => params[:profile], :action => :remove_activity, :activity_id => activity.id, :view => params[:view]), _('Are you sure you want to remove this activity and all its replies?')]) if logged_in? && current_person == @profile %> | ... | ... |
app/views/profile/_update_product.html.erb
| ... | ... | @@ -3,7 +3,7 @@ |
| 3 | 3 | </div> |
| 4 | 4 | <div class='profile-activity-description'> |
| 5 | 5 | <p class='profile-activity-text'><%= link_to activity.user.short_name(nil), activity.user.url %> <%= describe activity %></p> |
| 6 | - <p class='profile-activity-time'><%= time_ago_as_sentence activity.created_at %></p> | |
| 6 | + <p class='profile-activity-time'><%= time_ago_in_words activity.created_at %></p> | |
| 7 | 7 | |
| 8 | 8 | <div class='profile-wall-actions'> |
| 9 | 9 | <%= link_to_function(_('Remove'), 'remove_item_wall(this, \'%s\', \'%s\', \'%s\'); return false ;' % [".profile-activity-item", url_for(:profile => params[:profile], :action => :remove_activity, :activity_id => activity.id, :view => params[:view]), _('Are you sure you want to remove this activity and all its replies?')]) if logged_in? && current_person == @profile %> | ... | ... |
config/application.rb
| ... | ... | @@ -22,11 +22,10 @@ module Noosfero |
| 22 | 22 | # -- all .rb files in that directory are automatically loaded. |
| 23 | 23 | |
| 24 | 24 | # Custom directories with classes and modules you want to be autoloadable. |
| 25 | - config.autoload_paths += %W( #{Rails.root.join('app', 'sweepers')} ) | |
| 25 | + config.autoload_paths += %W( #{config.root.join('app', 'sweepers')} ) | |
| 26 | 26 | config.autoload_paths += Dir["#{config.root}/lib"] |
| 27 | 27 | config.autoload_paths += Dir["#{config.root}/app/controllers/**/"] |
| 28 | - config.autoload_paths += %W( #{Rails.root.join('test', 'mocks', Rails.env)} ) | |
| 29 | - | |
| 28 | + config.autoload_paths += %W( #{config.root.join('test', 'mocks', Rails.env)} ) | |
| 30 | 29 | |
| 31 | 30 | # Only load the plugins named here, in the order given (default is alphabetical). |
| 32 | 31 | # :all can be used as a placeholder for all plugins not explicitly named. | ... | ... |
lib/authenticated_system.rb
| ... | ... | @@ -3,7 +3,7 @@ module AuthenticatedSystem |
| 3 | 3 | protected |
| 4 | 4 | |
| 5 | 5 | # See impl. from http://stackoverflow.com/a/2513456/670229 |
| 6 | - def self.included? base | |
| 6 | + def self.included base | |
| 7 | 7 | base.around_filter do |
| 8 | 8 | begin |
| 9 | 9 | User.current = current_user |
| ... | ... | @@ -12,7 +12,11 @@ module AuthenticatedSystem |
| 12 | 12 | # to address the thread variable leak issues in Puma/Thin webserver |
| 13 | 13 | User.current = nil |
| 14 | 14 | end |
| 15 | - end | |
| 15 | + end if base.is_a? ActionController::Base | |
| 16 | + | |
| 17 | + # Inclusion hook to make #current_user and #logged_in? | |
| 18 | + # available as ActionView helper methods. | |
| 19 | + base.send :helper_method, :current_user, :logged_in? | |
| 16 | 20 | end |
| 17 | 21 | |
| 18 | 22 | # Returns true or false if the user is logged in. |
| ... | ... | @@ -134,12 +138,6 @@ module AuthenticatedSystem |
| 134 | 138 | end |
| 135 | 139 | end |
| 136 | 140 | |
| 137 | - # Inclusion hook to make #current_user and #logged_in? | |
| 138 | - # available as ActionView helper methods. | |
| 139 | - def self.included(base) | |
| 140 | - base.send :helper_method, :current_user, :logged_in? | |
| 141 | - end | |
| 142 | - | |
| 143 | 141 | # When called with before_filter :login_from_cookie will check for an :auth_token |
| 144 | 142 | # cookie and log the user back in if apropriate |
| 145 | 143 | def login_from_cookie | ... | ... |
lib/noosfero/plugin.rb
test/functional/profile_controller_test.rb
| ... | ... | @@ -1132,7 +1132,7 @@ class ProfileControllerTest < ActionController::TestCase |
| 1132 | 1132 | ActionTracker::Record.destroy_all |
| 1133 | 1133 | 40.times{ create(ActionTracker::Record, :user_id => profile.id, :user_type => 'Profile', :verb => 'create_article', :target_id => article.id, :target_type => 'Article', :params => {'name' => article.name, 'url' => article.url, 'lead' => article.lead, 'first_image' => article.first_image})} |
| 1134 | 1134 | assert_equal 40, profile.tracked_actions.count |
| 1135 | - assert_equal 40, profile.activities.count | |
| 1135 | + assert_equal 40, profile.activities.size | |
| 1136 | 1136 | get :view_more_activities, :profile => profile.identifier, :page => 2 |
| 1137 | 1137 | assert_response :success |
| 1138 | 1138 | assert_template '_profile_activities_list' | ... | ... |
test/unit/person_notifier_test.rb
| ... | ... | @@ -163,6 +163,21 @@ class PersonNotifierTest < ActiveSupport::TestCase |
| 163 | 163 | end |
| 164 | 164 | end |
| 165 | 165 | |
| 166 | + Targets = { | |
| 167 | + create_article: -> { create Forum, profile: @profile }, | |
| 168 | + new_friendship: -> { create Friendship, person: @member, friend: @member }, | |
| 169 | + join_community: -> { @member }, | |
| 170 | + add_member_in_community: -> { create_user.person }, | |
| 171 | + upload_image: -> { create Forum, profile: @profile }, | |
| 172 | + leave_scrap: -> { create Scrap, sender: @member, receiver: @profile }, | |
| 173 | + leave_scrap_to_self: -> { create Scrap, sender: @member, receiver: @profile }, | |
| 174 | + reply_scrap_on_self: -> { create Scrap, sender: @member, receiver: @profile }, | |
| 175 | + create_product: -> { create Product, profile: @profile, product_category: create(ProductCategory, environment: Environment.default) }, | |
| 176 | + update_product: -> { create Product, profile: @profile, product_category: create(ProductCategory, environment: Environment.default) }, | |
| 177 | + remove_product: -> { create Product, profile: @profile, product_category: create(ProductCategory, environment: Environment.default) }, | |
| 178 | + favorite_enterprise: -> { create FavoriteEnterprisePerson, enterprise: create(Enterprise), person: @member }, | |
| 179 | + } | |
| 180 | + | |
| 166 | 181 | ActionTrackerConfig.verb_names.each do |verb| |
| 167 | 182 | should "render notification for verb #{verb}" do |
| 168 | 183 | @member.tracked_notifications = [] |
| ... | ... | @@ -171,14 +186,15 @@ class PersonNotifierTest < ActiveSupport::TestCase |
| 171 | 186 | a.verb = verb |
| 172 | 187 | a.user = @member |
| 173 | 188 | a.created_at = @member.notifier.notify_from + 1.day |
| 174 | - profile = create(Community) | |
| 175 | - a.target = create(Forum, profile: profile) | |
| 189 | + @profile = create(Community) | |
| 190 | + a.target = instance_exec &Targets[verb.to_sym] | |
| 176 | 191 | a.comments_count = 0 |
| 177 | 192 | a.params = { |
| 178 | 193 | 'name' => 'home', 'url' => '/', 'lead' => '', |
| 179 | 194 | 'receiver_url' => '/', 'content' => 'nothing', |
| 180 | 195 | 'friend_url' => '/', 'friend_profile_custom_icon' => [], 'friend_name' => ['joe'], |
| 181 | 196 | 'resource_name' => ['resource'], 'resource_profile_custom_icon' => [], 'resource_url' => ['/'], |
| 197 | + 'enterprise_name' => 'coop', 'enterprise_url' => '/coop', | |
| 182 | 198 | 'view_url'=> ['/'], 'thumbnail_path' => ['1'], |
| 183 | 199 | } |
| 184 | 200 | a.get_url = '' | ... | ... |