diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 0e21a96..9cc1c7a 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -8,6 +8,8 @@ module ApplicationHelper include PermissionNameHelper + include UrlHelper + include ModalHelper include BoxesHelper diff --git a/app/helpers/url_helper.rb b/app/helpers/url_helper.rb new file mode 100644 index 0000000..01fb3a7 --- /dev/null +++ b/app/helpers/url_helper.rb @@ -0,0 +1,7 @@ +module UrlHelper + + def back_url + 'javascript:history.back()' + end + +end diff --git a/app/models/article.rb b/app/models/article.rb index 6ac31e0..73df0ac 100644 --- a/app/models/article.rb +++ b/app/models/article.rb @@ -789,7 +789,7 @@ class Article < ActiveRecord::Base end def activity - ActionTracker::Record.find_by_target_type_and_target_id 'Article', self.id + ActionTracker::Record.where(target_type: 'Article', target_id: self.id).first end def create_activity diff --git a/app/models/environment.rb b/app/models/environment.rb index ca13af3..a563760 100644 --- a/app/models/environment.rb +++ b/app/models/environment.rb @@ -960,7 +960,7 @@ class Environment < ActiveRecord::Base end def highlighted_products_with_image(options = {}) - self.products.where(highlighted: true).joins(:image) + self.products.where(highlighted: true).joins(:image).order('created_at ASC') end settings_items :home_cache_in_minutes, :type => :integer, :default => 5 diff --git a/app/models/event.rb b/app/models/event.rb index dbcb332..cfa63ea 100644 --- a/app/models/event.rb +++ b/app/models/event.rb @@ -36,7 +36,7 @@ class Event < Article scope :by_day, -> (date) { 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)', - {:start_date => date.beginning_of_day, :end_date => date.end_of_day}). + start_date: date.beginning_of_day, end_date: date.end_of_day). order('start_date ASC') } diff --git a/plugins/driven_signup/Gemfile b/plugins/driven_signup/Gemfile new file mode 100644 index 0000000..78209f7 --- /dev/null +++ b/plugins/driven_signup/Gemfile @@ -0,0 +1,2 @@ +gem 'slim' + diff --git a/plugins/driven_signup/controllers/public/driven_signup_plugin/account_controller.rb b/plugins/driven_signup/controllers/public/driven_signup_plugin/account_controller.rb index 3d3afca..de37355 100644 --- a/plugins/driven_signup/controllers/public/driven_signup_plugin/account_controller.rb +++ b/plugins/driven_signup/controllers/public/driven_signup_plugin/account_controller.rb @@ -25,9 +25,11 @@ class DrivenSignupPlugin::AccountController < PublicController protected - def default_url_options - # avoid rails' use_relative_controller! - {use_route: '/'} + # inherit routes from core skipping use_relative_controller! + def url_for options + options[:controller] = "/#{options[:controller]}" if options.is_a? Hash + super options end + helper_method :url_for end diff --git a/plugins/driven_signup/test/functional/account_controller_test.rb b/plugins/driven_signup/test/functional/account_controller_test.rb deleted file mode 100644 index 8b901e9..0000000 --- a/plugins/driven_signup/test/functional/account_controller_test.rb +++ /dev/null @@ -1,45 +0,0 @@ -require 'test_helper' - -# Re-raise errors caught by the controller. -class AccountController; def rescue_action(e) raise e end; end - -class AccountControllerTest < ActionController::TestCase - - def setup - @controller = AccountController.new - @request = ActionController::TestRequest.new - @response = ActionController::TestResponse.new - - e = Environment.default - e.enable 'skip_new_user_email_confirmation', true - disable_signup_bot_check e - end - - should 'use the parameters' do - community = create Community, name: 'base', identifier: 'base1' - subcommunity = create Community, name: 'sub', identifier: 'base11' - subcommunity.reload - - # simulate DrivenSignupPlugin::AccountController - session[:driven_signup] = true - session[:base_organization] = community.identifier - session[:find_suborganization] = true - session[:suborganization_members_limit] = 50 - - post :signup, user: {login: 'quire', password: 'quire', password_confirmation: 'quire', name: 'quire', email: 'test@example.com'} - assert_response :redirect - assert_redirected_to subcommunity.url - - user = Profile['quire'] - assert user - assert_includes subcommunity.members, user - end - - private - - def disable_signup_bot_check environment = Environment.default - environment.min_signup_delay = 0 - environment.save! - end - -end diff --git a/plugins/driven_signup/test/integration/account_controller_test.rb b/plugins/driven_signup/test/integration/account_controller_test.rb new file mode 100644 index 0000000..1dd6fe4 --- /dev/null +++ b/plugins/driven_signup/test/integration/account_controller_test.rb @@ -0,0 +1,44 @@ +require 'test_helper' + +# Re-raise errors caught by the controller. +class AccountController; def rescue_action(e) raise e end; end + +class AccountControllerTest < ActionDispatch::IntegrationTest + + def setup + @controller = AccountController.new + @request = ActionController::TestRequest.new + @response = ActionController::TestResponse.new + + e = Environment.default + e.enable 'skip_new_user_email_confirmation', true + disable_signup_bot_check e + end + + should 'use the parameters' do + token = '131324' + Environment.default.driven_signup_auths.create! token: token + community = create Community, name: 'base', identifier: 'base1' + subcommunity = create Community, name: 'sub', identifier: 'base11' + subcommunity.reload + + # simulate DrivenSignupPlugin::AccountController + session[:driven_signup] = true + session[:base_organization] = community.identifier + session[:find_suborganization] = true + session[:suborganization_members_limit] = 50 + + post url_for(controller: 'driven_signup_plugin/account', action: :signup, token: token, signup: {login: 'quire', name: 'quire', email: 'test@example.com'}) + assert_response :redirect + assert_redirected_to url_for(controller: '/account', action: :signup, user: {login: 'quire', email: 'test@example.com',}, + profile_data: {name: 'quire'}) + end + + private + + def disable_signup_bot_check environment = Environment.default + environment.min_signup_delay = 0 + environment.save! + end + +end diff --git a/plugins/fb_app/controllers/public/fb_app_plugin_page_tab_controller.rb b/plugins/fb_app/controllers/public/fb_app_plugin_page_tab_controller.rb index 39c2239..142a23e 100644 --- a/plugins/fb_app/controllers/public/fb_app_plugin_page_tab_controller.rb +++ b/plugins/fb_app/controllers/public/fb_app_plugin_page_tab_controller.rb @@ -88,7 +88,7 @@ class FbAppPluginPageTabController < FbAppPluginController end def enterprise_search - scope = environment.enterprises.enabled.public + scope = environment.enterprises.enabled.is_public @query = params[:query] @profiles = scope.limit(10).order('name ASC'). where(['name ILIKE ? OR name ILIKE ? OR identifier LIKE ?', "#{@query}%", "% #{@query}%", "#{@query}%"]) diff --git a/plugins/oauth_client/lib/ext/profile.rb b/plugins/oauth_client/lib/ext/profile.rb index b0ca647..c657b89 100644 --- a/plugins/oauth_client/lib/ext/profile.rb +++ b/plugins/oauth_client/lib/ext/profile.rb @@ -1,8 +1,10 @@ require_dependency 'profile' -class Profile +Profile.descendants.each do |subclass| + subclass.class_eval do - has_many :oauth_auths, class_name: 'OauthClientPlugin::Auth', dependent: :destroy - has_many :oauth_providers, through: :oauth_auths, source: :provider + has_many :oauth_auths, foreign_key: :profile_id, class_name: 'OauthClientPlugin::Auth', dependent: :destroy + has_many :oauth_providers, through: :oauth_auths, source: :provider + end end diff --git a/plugins/open_graph/controllers/myprofile/open_graph_plugin/myprofile_controller.rb b/plugins/open_graph/controllers/myprofile/open_graph_plugin/myprofile_controller.rb index 5603be9..c10f15a 100644 --- a/plugins/open_graph/controllers/myprofile/open_graph_plugin/myprofile_controller.rb +++ b/plugins/open_graph/controllers/myprofile/open_graph_plugin/myprofile_controller.rb @@ -4,11 +4,11 @@ class OpenGraphPlugin::MyprofileController < MyProfileController before_filter :set_context def enterprise_search - scope = environment.enterprises.enabled.public + scope = environment.enterprises.enabled.is_public profile_search scope end def community_search - scope = environment.communities.public + scope = environment.communities.is_public profile_search scope end def friend_search @@ -38,10 +38,13 @@ class OpenGraphPlugin::MyprofileController < MyProfileController OpenGraphPlugin.context = self.context end - def default_url_options - # avoid rails' use_relative_controller! - {use_route: '/'} + # inherit routes from core skipping use_relative_controller! + def url_for options + options[:controller] = "/#{options[:controller]}" if options.is_a? Hash + super options end + helper_method :url_for + end diff --git a/plugins/open_graph/lib/ext/profile.rb b/plugins/open_graph/lib/ext/profile.rb index 09e144f..cd0fe06 100644 --- a/plugins/open_graph/lib/ext/profile.rb +++ b/plugins/open_graph/lib/ext/profile.rb @@ -7,11 +7,21 @@ Profile.descendants.each do |subclass| subclass.class_eval do attr_accessible :open_graph_settings + has_many :open_graph_tracks, class_name: 'OpenGraphPlugin::Track', source: :tracker_id, foreign_key: :tracker_id + + has_many :open_graph_activities, class_name: 'OpenGraphPlugin::Activity', source: :tracker_id, foreign_key: :tracker_id + + has_many :open_graph_track_configs, class_name: 'OpenGraphPlugin::TrackConfig', source: :tracker_id, foreign_key: :tracker_id + OpenGraphPlugin::TrackConfig::Types.each do |track, klass| klass = "OpenGraphPlugin::#{klass}".constantize attributes = "#{klass.association}_attributes" profile_ids = "open_graph_#{track}_profiles_ids" + association = klass.association + has_many association, class_name: klass.name, foreign_key: :tracker_id + accepts_nested_attributes_for association, allow_destroy: true, reject_if: :open_graph_reject_empty_object_type + attr_accessible attributes attr_accessible profile_ids end @@ -27,19 +37,11 @@ class Profile end alias_method :open_graph_settings=, :open_graph_settings - has_many :open_graph_tracks, class_name: 'OpenGraphPlugin::Track', source: :tracker_id, foreign_key: :tracker_id - - has_many :open_graph_activities, class_name: 'OpenGraphPlugin::Activity', source: :tracker_id, foreign_key: :tracker_id - - has_many :open_graph_track_configs, class_name: 'OpenGraphPlugin::TrackConfig', source: :tracker_id, foreign_key: :tracker_id OpenGraphPlugin::TrackConfig::Types.each do |track, klass| klass = "OpenGraphPlugin::#{klass}".constantize association = klass.association profile_ids = "open_graph_#{track}_profiles_ids" - has_many association, class_name: klass.name, foreign_key: :tracker_id - accepts_nested_attributes_for association, allow_destroy: true, reject_if: :open_graph_reject_empty_object_type - define_method "#{profile_ids}=" do |ids| cids = self.send(association).order('created_at ASC').map(&:object_data_id) nids = if ids.is_a? Array then ids else ids.split ',' end diff --git a/plugins/open_graph/lib/open_graph_plugin/settings.rb b/plugins/open_graph/lib/open_graph_plugin/settings.rb index 9bf7970..55095d5 100644 --- a/plugins/open_graph/lib/open_graph_plugin/settings.rb +++ b/plugins/open_graph/lib/open_graph_plugin/settings.rb @@ -6,7 +6,7 @@ class OpenGraphPlugin::Settings < Noosfero::Plugin::Settings OpenGraphPlugin::TrackConfig::Types.each do |track, klass| define_method "#{track}_track_enabled=" do |value| - super ActiveRecord::ConnectionAdapters::Column.value_to_boolean(value) + super ActiveRecord::Type::Boolean.new.send :cast_value, value end end diff --git a/plugins/open_graph/models/open_graph_plugin/enterprise_track_config.rb b/plugins/open_graph/models/open_graph_plugin/enterprise_track_config.rb index 3138559..38a995f 100644 --- a/plugins/open_graph/models/open_graph_plugin/enterprise_track_config.rb +++ b/plugins/open_graph/models/open_graph_plugin/enterprise_track_config.rb @@ -14,7 +14,7 @@ class OpenGraphPlugin::EnterpriseTrackConfig < OpenGraphPlugin::TrackConfig end def self.profile_track_objects profile - (profile.enterprises.public.enabled + profile.favorite_enterprises.public.enabled).uniq + (profile.enterprises.is_public.enabled + profile.favorite_enterprises.is_public.enabled).uniq end end diff --git a/plugins/open_graph/views/open_graph_plugin/myprofile/_track_enterprise.html.erb b/plugins/open_graph/views/open_graph_plugin/myprofile/_track_enterprise.html.erb index 481ffb5..b6f0e1c 100644 --- a/plugins/open_graph/views/open_graph_plugin/myprofile/_track_enterprise.html.erb +++ b/plugins/open_graph/views/open_graph_plugin/myprofile/_track_enterprise.html.erb @@ -13,7 +13,7 @@ <%= t('open_graph_plugin.views.track.config.enterprise.memberships') %>
- <% user.enterprises.public.enabled.each do |enterprise| %> + <% user.enterprises.is_public.enabled.each do |enterprise| %> <%= profile_image_link enterprise, :portrait, :div %> <% end %>
@@ -26,7 +26,7 @@ <% if user.favorite_enterprises.present? %>
- <% user.favorite_enterprises.public.enabled.each do |enterprise| %> + <% user.favorite_enterprises.is_public.enabled.each do |enterprise| %> <%= profile_image_link enterprise, :portrait, :div %> <% end %>
diff --git a/plugins/responsive/test/unit/foo_plugin_test.rb b/plugins/responsive/test/unit/foo_plugin_test.rb deleted file mode 100644 index 71d51e0..0000000 --- a/plugins/responsive/test/unit/foo_plugin_test.rb +++ /dev/null @@ -1,10 +0,0 @@ -require File.dirname(__FILE__) + '/../../../../test/test_helper' - -class FooPluginTest < ActiveSupport::TestCase - def test_foo - FooPlugin::Bar.create! - end - def test_monkey_patch - Profile.new.bar - end -end diff --git a/plugins/site_tour/test/functional/site_tour_plugin_admin_controller_test.rb b/plugins/site_tour/test/functional/site_tour_plugin_admin_controller_test.rb index 00acc2b..1171668 100644 --- a/plugins/site_tour/test/functional/site_tour_plugin_admin_controller_test.rb +++ b/plugins/site_tour/test/functional/site_tour_plugin_admin_controller_test.rb @@ -1,4 +1,4 @@ -require File.dirname(__FILE__) + '/../test_helper' +require 'test_helper' class SiteTourPluginAdminControllerTest < ActionController::TestCase diff --git a/plugins/site_tour/test/functional/site_tour_plugin_public_controller_test.rb b/plugins/site_tour/test/functional/site_tour_plugin_public_controller_test.rb index 416d4e2..e51518f 100644 --- a/plugins/site_tour/test/functional/site_tour_plugin_public_controller_test.rb +++ b/plugins/site_tour/test/functional/site_tour_plugin_public_controller_test.rb @@ -1,4 +1,4 @@ -require File.dirname(__FILE__) + '/../test_helper' +require 'test_helper' class SiteTourPluginPublicControllerTest < ActionController::TestCase diff --git a/plugins/site_tour/test/unit/site_tour_helper_test.rb b/plugins/site_tour/test/unit/site_tour_helper_test.rb index fcca9d7..ca0065f 100644 --- a/plugins/site_tour/test/unit/site_tour_helper_test.rb +++ b/plugins/site_tour/test/unit/site_tour_helper_test.rb @@ -1,4 +1,4 @@ -require File.dirname(__FILE__) + '/../test_helper' +require 'test_helper' class SiteTourHelperTest < ActionView::TestCase diff --git a/plugins/site_tour/test/unit/site_tour_plugin_test.rb b/plugins/site_tour/test/unit/site_tour_plugin_test.rb index cefd3bf..5a42f7d 100644 --- a/plugins/site_tour/test/unit/site_tour_plugin_test.rb +++ b/plugins/site_tour/test/unit/site_tour_plugin_test.rb @@ -1,4 +1,4 @@ -require File.dirname(__FILE__) + '/../test_helper' +require 'test_helper' class SiteTourPluginTest < ActionView::TestCase diff --git a/plugins/site_tour/test/unit/tour_block_test.rb b/plugins/site_tour/test/unit/tour_block_test.rb index 46e9dbb..af9f009 100644 --- a/plugins/site_tour/test/unit/tour_block_test.rb +++ b/plugins/site_tour/test/unit/tour_block_test.rb @@ -1,4 +1,4 @@ -require File.dirname(__FILE__) + '/../test_helper' +require 'test_helper' class TrackListBlockTest < ActionView::TestCase diff --git a/plugins/stoa/config.yml b/plugins/stoa/config.yml new file mode 100644 index 0000000..8335f30 --- /dev/null +++ b/plugins/stoa/config.yml @@ -0,0 +1 @@ +salt: '123456789' diff --git a/test/functional/search_controller_test.rb b/test/functional/search_controller_test.rb index 4fff75c..8bc4862 100644 --- a/test/functional/search_controller_test.rb +++ b/test/functional/search_controller_test.rb @@ -316,7 +316,7 @@ class SearchControllerTest < ActionController::TestCase ev1 = create_event(person, :name => 'event 1', :category_ids => [@category.id], :start_date => ten_days_ago) ev2 = create_event(person, :name => 'event 2', :category_ids => [@category.id], :start_date => DateTime.now - 2.month) - get :events, :day => ten_days_ago.day, :month => ten_days_ago.month, :year => ten_days_ago.year + get :events, day: ten_days_ago.day+1.second, month: ten_days_ago.month, year: ten_days_ago.year assert_equal [ev1], assigns(:events) end @@ -326,10 +326,10 @@ class SearchControllerTest < ActionController::TestCase ev1 = create_event(person, :name => 'event 1', :start_date => ten_days_ago) ev1.categories = [@category] - + ev2 = create_event(person, :name => 'event 2', :start_date => ten_days_ago) - get :events, :day => ten_days_ago.day, :month => ten_days_ago.month, :year => ten_days_ago.year, :category_path => @category.path.split('/') + get :events, day: ten_days_ago.day+1.second, month: ten_days_ago.month, year: ten_days_ago.year, category_path: @category.path.split('/') assert_equal [ev1], assigns(:events) end diff --git a/test/unit/article_test.rb b/test/unit/article_test.rb index 46f6255..a9f710d 100644 --- a/test/unit/article_test.rb +++ b/test/unit/article_test.rb @@ -1089,12 +1089,13 @@ class ArticleTest < ActiveSupport::TestCase ActionTracker::Record.destroy_all community = fast_create(Community) - member_1 = create_user.person + User.current = create_user + member_1 = User.current.person community.add_member(member_1) article = create TinyMceArticle, :name => 'Tracked Article 1', :profile_id => community.id first_activity = article.activity - assert_equal [first_activity], ActionTracker::Record.find_all_by_verb('create_article') + assert_equal [first_activity], ActionTracker::Record.where(verb: 'create_article') process_delayed_job_queue assert_equal 2, ActionTrackerNotification.find_all_by_action_tracker_id(first_activity.id).count diff --git a/test/unit/scrap_test.rb b/test/unit/scrap_test.rb index f314144..09886c2 100644 --- a/test/unit/scrap_test.rb +++ b/test/unit/scrap_test.rb @@ -123,7 +123,8 @@ class ScrapTest < ActiveSupport::TestCase end should "notify leave_scrap action tracker verb to friends and itself" do - p1 = create_user.person + User.current = create_user + p1 = User.current.person p2 = create_user.person p1.add_friend(p2) process_delayed_job_queue @@ -141,7 +142,8 @@ class ScrapTest < ActiveSupport::TestCase end should "notify leave_scrap action tracker verb to members of the communities and the community itself" do - p = create_user.person + User.current = create_user + p = User.current.person c = fast_create(Community) c.add_member(p) ActionTrackerNotification.delete_all @@ -175,7 +177,8 @@ class ScrapTest < ActiveSupport::TestCase end should "notify leave_scrap_to_self action tracker verb to friends and itself" do - p1 = create_user.person + User.current = create_user + p1 = User.current.person p2 = create_user.person p1.add_friend(p2) ActionTrackerNotification.delete_all @@ -290,7 +293,8 @@ class ScrapTest < ActiveSupport::TestCase end should 'create activity with reply_scrap_on_self when top_root scrap receiver is the same as sender' do - s, r = create_user.person, create_user.person + User.current = create_user + s, r = User.current.person, create_user.person root = create(Scrap, :sender_id => s.id, :receiver_id => r.id) assert_difference 'ActionTracker::Record.count', 1 do reply = create(Scrap, :sender => r, :receiver => s, :scrap_id => root.id, :content => 'sample') -- libgit2 0.21.2