Commit 8548bd8a82b1356435f76c34560a5e8a3c6d3aa1
1 parent
b9d2cc07
Exists in
master
and in
20 other branches
rails4: fix units and plugins tests
Showing
26 changed files
with
111 additions
and
96 deletions
Show diff stats
app/helpers/application_helper.rb
app/models/article.rb
... | ... | @@ -789,7 +789,7 @@ class Article < ActiveRecord::Base |
789 | 789 | end |
790 | 790 | |
791 | 791 | def activity |
792 | - ActionTracker::Record.find_by_target_type_and_target_id 'Article', self.id | |
792 | + ActionTracker::Record.where(target_type: 'Article', target_id: self.id).first | |
793 | 793 | end |
794 | 794 | |
795 | 795 | def create_activity | ... | ... |
app/models/environment.rb
... | ... | @@ -960,7 +960,7 @@ class Environment < ActiveRecord::Base |
960 | 960 | end |
961 | 961 | |
962 | 962 | def highlighted_products_with_image(options = {}) |
963 | - self.products.where(highlighted: true).joins(:image) | |
963 | + self.products.where(highlighted: true).joins(:image).order('created_at ASC') | |
964 | 964 | end |
965 | 965 | |
966 | 966 | settings_items :home_cache_in_minutes, :type => :integer, :default => 5 | ... | ... |
app/models/event.rb
... | ... | @@ -36,7 +36,7 @@ class Event < Article |
36 | 36 | |
37 | 37 | scope :by_day, -> (date) { |
38 | 38 | where('start_date >= :start_date AND start_date <= :end_date AND end_date IS NULL OR (start_date <= :end_date AND end_date >= :start_date)', |
39 | - {:start_date => date.beginning_of_day, :end_date => date.end_of_day}). | |
39 | + start_date: date.beginning_of_day, end_date: date.end_of_day). | |
40 | 40 | order('start_date ASC') |
41 | 41 | } |
42 | 42 | ... | ... |
plugins/driven_signup/controllers/public/driven_signup_plugin/account_controller.rb
... | ... | @@ -25,9 +25,11 @@ class DrivenSignupPlugin::AccountController < PublicController |
25 | 25 | |
26 | 26 | protected |
27 | 27 | |
28 | - def default_url_options | |
29 | - # avoid rails' use_relative_controller! | |
30 | - {use_route: '/'} | |
28 | + # inherit routes from core skipping use_relative_controller! | |
29 | + def url_for options | |
30 | + options[:controller] = "/#{options[:controller]}" if options.is_a? Hash | |
31 | + super options | |
31 | 32 | end |
33 | + helper_method :url_for | |
32 | 34 | |
33 | 35 | end | ... | ... |
plugins/driven_signup/test/functional/account_controller_test.rb
... | ... | @@ -1,45 +0,0 @@ |
1 | -require 'test_helper' | |
2 | - | |
3 | -# Re-raise errors caught by the controller. | |
4 | -class AccountController; def rescue_action(e) raise e end; end | |
5 | - | |
6 | -class AccountControllerTest < ActionController::TestCase | |
7 | - | |
8 | - def setup | |
9 | - @controller = AccountController.new | |
10 | - @request = ActionController::TestRequest.new | |
11 | - @response = ActionController::TestResponse.new | |
12 | - | |
13 | - e = Environment.default | |
14 | - e.enable 'skip_new_user_email_confirmation', true | |
15 | - disable_signup_bot_check e | |
16 | - end | |
17 | - | |
18 | - should 'use the parameters' do | |
19 | - community = create Community, name: 'base', identifier: 'base1' | |
20 | - subcommunity = create Community, name: 'sub', identifier: 'base11' | |
21 | - subcommunity.reload | |
22 | - | |
23 | - # simulate DrivenSignupPlugin::AccountController | |
24 | - session[:driven_signup] = true | |
25 | - session[:base_organization] = community.identifier | |
26 | - session[:find_suborganization] = true | |
27 | - session[:suborganization_members_limit] = 50 | |
28 | - | |
29 | - post :signup, user: {login: 'quire', password: 'quire', password_confirmation: 'quire', name: 'quire', email: 'test@example.com'} | |
30 | - assert_response :redirect | |
31 | - assert_redirected_to subcommunity.url | |
32 | - | |
33 | - user = Profile['quire'] | |
34 | - assert user | |
35 | - assert_includes subcommunity.members, user | |
36 | - end | |
37 | - | |
38 | - private | |
39 | - | |
40 | - def disable_signup_bot_check environment = Environment.default | |
41 | - environment.min_signup_delay = 0 | |
42 | - environment.save! | |
43 | - end | |
44 | - | |
45 | -end |
plugins/driven_signup/test/integration/account_controller_test.rb
0 → 100644
... | ... | @@ -0,0 +1,44 @@ |
1 | +require 'test_helper' | |
2 | + | |
3 | +# Re-raise errors caught by the controller. | |
4 | +class AccountController; def rescue_action(e) raise e end; end | |
5 | + | |
6 | +class AccountControllerTest < ActionDispatch::IntegrationTest | |
7 | + | |
8 | + def setup | |
9 | + @controller = AccountController.new | |
10 | + @request = ActionController::TestRequest.new | |
11 | + @response = ActionController::TestResponse.new | |
12 | + | |
13 | + e = Environment.default | |
14 | + e.enable 'skip_new_user_email_confirmation', true | |
15 | + disable_signup_bot_check e | |
16 | + end | |
17 | + | |
18 | + should 'use the parameters' do | |
19 | + token = '131324' | |
20 | + Environment.default.driven_signup_auths.create! token: token | |
21 | + community = create Community, name: 'base', identifier: 'base1' | |
22 | + subcommunity = create Community, name: 'sub', identifier: 'base11' | |
23 | + subcommunity.reload | |
24 | + | |
25 | + # simulate DrivenSignupPlugin::AccountController | |
26 | + session[:driven_signup] = true | |
27 | + session[:base_organization] = community.identifier | |
28 | + session[:find_suborganization] = true | |
29 | + session[:suborganization_members_limit] = 50 | |
30 | + | |
31 | + post url_for(controller: 'driven_signup_plugin/account', action: :signup, token: token, signup: {login: 'quire', name: 'quire', email: 'test@example.com'}) | |
32 | + assert_response :redirect | |
33 | + assert_redirected_to url_for(controller: '/account', action: :signup, user: {login: 'quire', email: 'test@example.com',}, | |
34 | + profile_data: {name: 'quire'}) | |
35 | + end | |
36 | + | |
37 | + private | |
38 | + | |
39 | + def disable_signup_bot_check environment = Environment.default | |
40 | + environment.min_signup_delay = 0 | |
41 | + environment.save! | |
42 | + end | |
43 | + | |
44 | +end | ... | ... |
plugins/fb_app/controllers/public/fb_app_plugin_page_tab_controller.rb
... | ... | @@ -88,7 +88,7 @@ class FbAppPluginPageTabController < FbAppPluginController |
88 | 88 | end |
89 | 89 | |
90 | 90 | def enterprise_search |
91 | - scope = environment.enterprises.enabled.public | |
91 | + scope = environment.enterprises.enabled.is_public | |
92 | 92 | @query = params[:query] |
93 | 93 | @profiles = scope.limit(10).order('name ASC'). |
94 | 94 | where(['name ILIKE ? OR name ILIKE ? OR identifier LIKE ?', "#{@query}%", "% #{@query}%", "#{@query}%"]) | ... | ... |
plugins/oauth_client/lib/ext/profile.rb
1 | 1 | require_dependency 'profile' |
2 | 2 | |
3 | -class Profile | |
3 | +Profile.descendants.each do |subclass| | |
4 | + subclass.class_eval do | |
4 | 5 | |
5 | - has_many :oauth_auths, class_name: 'OauthClientPlugin::Auth', dependent: :destroy | |
6 | - has_many :oauth_providers, through: :oauth_auths, source: :provider | |
6 | + has_many :oauth_auths, foreign_key: :profile_id, class_name: 'OauthClientPlugin::Auth', dependent: :destroy | |
7 | + has_many :oauth_providers, through: :oauth_auths, source: :provider | |
7 | 8 | |
9 | + end | |
8 | 10 | end | ... | ... |
plugins/open_graph/controllers/myprofile/open_graph_plugin/myprofile_controller.rb
... | ... | @@ -4,11 +4,11 @@ class OpenGraphPlugin::MyprofileController < MyProfileController |
4 | 4 | before_filter :set_context |
5 | 5 | |
6 | 6 | def enterprise_search |
7 | - scope = environment.enterprises.enabled.public | |
7 | + scope = environment.enterprises.enabled.is_public | |
8 | 8 | profile_search scope |
9 | 9 | end |
10 | 10 | def community_search |
11 | - scope = environment.communities.public | |
11 | + scope = environment.communities.is_public | |
12 | 12 | profile_search scope |
13 | 13 | end |
14 | 14 | def friend_search |
... | ... | @@ -38,10 +38,13 @@ class OpenGraphPlugin::MyprofileController < MyProfileController |
38 | 38 | OpenGraphPlugin.context = self.context |
39 | 39 | end |
40 | 40 | |
41 | - def default_url_options | |
42 | - # avoid rails' use_relative_controller! | |
43 | - {use_route: '/'} | |
41 | + # inherit routes from core skipping use_relative_controller! | |
42 | + def url_for options | |
43 | + options[:controller] = "/#{options[:controller]}" if options.is_a? Hash | |
44 | + super options | |
44 | 45 | end |
46 | + helper_method :url_for | |
47 | + | |
45 | 48 | |
46 | 49 | end |
47 | 50 | ... | ... |
plugins/open_graph/lib/ext/profile.rb
... | ... | @@ -7,11 +7,21 @@ Profile.descendants.each do |subclass| |
7 | 7 | subclass.class_eval do |
8 | 8 | attr_accessible :open_graph_settings |
9 | 9 | |
10 | + has_many :open_graph_tracks, class_name: 'OpenGraphPlugin::Track', source: :tracker_id, foreign_key: :tracker_id | |
11 | + | |
12 | + has_many :open_graph_activities, class_name: 'OpenGraphPlugin::Activity', source: :tracker_id, foreign_key: :tracker_id | |
13 | + | |
14 | + has_many :open_graph_track_configs, class_name: 'OpenGraphPlugin::TrackConfig', source: :tracker_id, foreign_key: :tracker_id | |
15 | + | |
10 | 16 | OpenGraphPlugin::TrackConfig::Types.each do |track, klass| |
11 | 17 | klass = "OpenGraphPlugin::#{klass}".constantize |
12 | 18 | attributes = "#{klass.association}_attributes" |
13 | 19 | profile_ids = "open_graph_#{track}_profiles_ids" |
14 | 20 | |
21 | + association = klass.association | |
22 | + has_many association, class_name: klass.name, foreign_key: :tracker_id | |
23 | + accepts_nested_attributes_for association, allow_destroy: true, reject_if: :open_graph_reject_empty_object_type | |
24 | + | |
15 | 25 | attr_accessible attributes |
16 | 26 | attr_accessible profile_ids |
17 | 27 | end |
... | ... | @@ -27,19 +37,11 @@ class Profile |
27 | 37 | end |
28 | 38 | alias_method :open_graph_settings=, :open_graph_settings |
29 | 39 | |
30 | - has_many :open_graph_tracks, class_name: 'OpenGraphPlugin::Track', source: :tracker_id, foreign_key: :tracker_id | |
31 | - | |
32 | - has_many :open_graph_activities, class_name: 'OpenGraphPlugin::Activity', source: :tracker_id, foreign_key: :tracker_id | |
33 | - | |
34 | - has_many :open_graph_track_configs, class_name: 'OpenGraphPlugin::TrackConfig', source: :tracker_id, foreign_key: :tracker_id | |
35 | 40 | OpenGraphPlugin::TrackConfig::Types.each do |track, klass| |
36 | 41 | klass = "OpenGraphPlugin::#{klass}".constantize |
37 | 42 | association = klass.association |
38 | 43 | profile_ids = "open_graph_#{track}_profiles_ids" |
39 | 44 | |
40 | - has_many association, class_name: klass.name, foreign_key: :tracker_id | |
41 | - accepts_nested_attributes_for association, allow_destroy: true, reject_if: :open_graph_reject_empty_object_type | |
42 | - | |
43 | 45 | define_method "#{profile_ids}=" do |ids| |
44 | 46 | cids = self.send(association).order('created_at ASC').map(&:object_data_id) |
45 | 47 | nids = if ids.is_a? Array then ids else ids.split ',' end | ... | ... |
plugins/open_graph/lib/open_graph_plugin/settings.rb
... | ... | @@ -6,7 +6,7 @@ class OpenGraphPlugin::Settings < Noosfero::Plugin::Settings |
6 | 6 | |
7 | 7 | OpenGraphPlugin::TrackConfig::Types.each do |track, klass| |
8 | 8 | define_method "#{track}_track_enabled=" do |value| |
9 | - super ActiveRecord::ConnectionAdapters::Column.value_to_boolean(value) | |
9 | + super ActiveRecord::Type::Boolean.new.send :cast_value, value | |
10 | 10 | end |
11 | 11 | end |
12 | 12 | ... | ... |
plugins/open_graph/models/open_graph_plugin/enterprise_track_config.rb
... | ... | @@ -14,7 +14,7 @@ class OpenGraphPlugin::EnterpriseTrackConfig < OpenGraphPlugin::TrackConfig |
14 | 14 | end |
15 | 15 | |
16 | 16 | def self.profile_track_objects profile |
17 | - (profile.enterprises.public.enabled + profile.favorite_enterprises.public.enabled).uniq | |
17 | + (profile.enterprises.is_public.enabled + profile.favorite_enterprises.is_public.enabled).uniq | |
18 | 18 | end |
19 | 19 | |
20 | 20 | end | ... | ... |
plugins/open_graph/views/open_graph_plugin/myprofile/_track_enterprise.html.erb
... | ... | @@ -13,7 +13,7 @@ |
13 | 13 | <%= t('open_graph_plugin.views.track.config.enterprise.memberships') %> |
14 | 14 | </h1> |
15 | 15 | <div class="open-graph-enterprises-list"> |
16 | - <% user.enterprises.public.enabled.each do |enterprise| %> | |
16 | + <% user.enterprises.is_public.enabled.each do |enterprise| %> | |
17 | 17 | <%= profile_image_link enterprise, :portrait, :div %> |
18 | 18 | <% end %> |
19 | 19 | </div> |
... | ... | @@ -26,7 +26,7 @@ |
26 | 26 | </h1> |
27 | 27 | <% if user.favorite_enterprises.present? %> |
28 | 28 | <div class="open-graph-enterprises-list"> |
29 | - <% user.favorite_enterprises.public.enabled.each do |enterprise| %> | |
29 | + <% user.favorite_enterprises.is_public.enabled.each do |enterprise| %> | |
30 | 30 | <%= profile_image_link enterprise, :portrait, :div %> |
31 | 31 | <% end %> |
32 | 32 | </div> | ... | ... |
plugins/responsive/test/unit/foo_plugin_test.rb
plugins/site_tour/test/functional/site_tour_plugin_admin_controller_test.rb
plugins/site_tour/test/functional/site_tour_plugin_public_controller_test.rb
plugins/site_tour/test/unit/site_tour_helper_test.rb
plugins/site_tour/test/unit/site_tour_plugin_test.rb
plugins/site_tour/test/unit/tour_block_test.rb
... | ... | @@ -0,0 +1 @@ |
1 | +salt: '123456789' | ... | ... |
test/functional/search_controller_test.rb
... | ... | @@ -316,7 +316,7 @@ class SearchControllerTest < ActionController::TestCase |
316 | 316 | ev1 = create_event(person, :name => 'event 1', :category_ids => [@category.id], :start_date => ten_days_ago) |
317 | 317 | ev2 = create_event(person, :name => 'event 2', :category_ids => [@category.id], :start_date => DateTime.now - 2.month) |
318 | 318 | |
319 | - get :events, :day => ten_days_ago.day, :month => ten_days_ago.month, :year => ten_days_ago.year | |
319 | + get :events, day: ten_days_ago.day+1.second, month: ten_days_ago.month, year: ten_days_ago.year | |
320 | 320 | assert_equal [ev1], assigns(:events) |
321 | 321 | end |
322 | 322 | |
... | ... | @@ -326,10 +326,10 @@ class SearchControllerTest < ActionController::TestCase |
326 | 326 | |
327 | 327 | ev1 = create_event(person, :name => 'event 1', :start_date => ten_days_ago) |
328 | 328 | ev1.categories = [@category] |
329 | - | |
329 | + | |
330 | 330 | ev2 = create_event(person, :name => 'event 2', :start_date => ten_days_ago) |
331 | 331 | |
332 | - get :events, :day => ten_days_ago.day, :month => ten_days_ago.month, :year => ten_days_ago.year, :category_path => @category.path.split('/') | |
332 | + get :events, day: ten_days_ago.day+1.second, month: ten_days_ago.month, year: ten_days_ago.year, category_path: @category.path.split('/') | |
333 | 333 | |
334 | 334 | assert_equal [ev1], assigns(:events) |
335 | 335 | end | ... | ... |
test/unit/article_test.rb
... | ... | @@ -1089,12 +1089,13 @@ class ArticleTest < ActiveSupport::TestCase |
1089 | 1089 | ActionTracker::Record.destroy_all |
1090 | 1090 | |
1091 | 1091 | community = fast_create(Community) |
1092 | - member_1 = create_user.person | |
1092 | + User.current = create_user | |
1093 | + member_1 = User.current.person | |
1093 | 1094 | community.add_member(member_1) |
1094 | 1095 | |
1095 | 1096 | article = create TinyMceArticle, :name => 'Tracked Article 1', :profile_id => community.id |
1096 | 1097 | first_activity = article.activity |
1097 | - assert_equal [first_activity], ActionTracker::Record.find_all_by_verb('create_article') | |
1098 | + assert_equal [first_activity], ActionTracker::Record.where(verb: 'create_article') | |
1098 | 1099 | |
1099 | 1100 | process_delayed_job_queue |
1100 | 1101 | assert_equal 2, ActionTrackerNotification.find_all_by_action_tracker_id(first_activity.id).count | ... | ... |
test/unit/scrap_test.rb
... | ... | @@ -123,7 +123,8 @@ class ScrapTest < ActiveSupport::TestCase |
123 | 123 | end |
124 | 124 | |
125 | 125 | should "notify leave_scrap action tracker verb to friends and itself" do |
126 | - p1 = create_user.person | |
126 | + User.current = create_user | |
127 | + p1 = User.current.person | |
127 | 128 | p2 = create_user.person |
128 | 129 | p1.add_friend(p2) |
129 | 130 | process_delayed_job_queue |
... | ... | @@ -141,7 +142,8 @@ class ScrapTest < ActiveSupport::TestCase |
141 | 142 | end |
142 | 143 | |
143 | 144 | should "notify leave_scrap action tracker verb to members of the communities and the community itself" do |
144 | - p = create_user.person | |
145 | + User.current = create_user | |
146 | + p = User.current.person | |
145 | 147 | c = fast_create(Community) |
146 | 148 | c.add_member(p) |
147 | 149 | ActionTrackerNotification.delete_all |
... | ... | @@ -175,7 +177,8 @@ class ScrapTest < ActiveSupport::TestCase |
175 | 177 | end |
176 | 178 | |
177 | 179 | should "notify leave_scrap_to_self action tracker verb to friends and itself" do |
178 | - p1 = create_user.person | |
180 | + User.current = create_user | |
181 | + p1 = User.current.person | |
179 | 182 | p2 = create_user.person |
180 | 183 | p1.add_friend(p2) |
181 | 184 | ActionTrackerNotification.delete_all |
... | ... | @@ -290,7 +293,8 @@ class ScrapTest < ActiveSupport::TestCase |
290 | 293 | end |
291 | 294 | |
292 | 295 | should 'create activity with reply_scrap_on_self when top_root scrap receiver is the same as sender' do |
293 | - s, r = create_user.person, create_user.person | |
296 | + User.current = create_user | |
297 | + s, r = User.current.person, create_user.person | |
294 | 298 | root = create(Scrap, :sender_id => s.id, :receiver_id => r.id) |
295 | 299 | assert_difference 'ActionTracker::Record.count', 1 do |
296 | 300 | reply = create(Scrap, :sender => r, :receiver => s, :scrap_id => root.id, :content => 'sample') | ... | ... |