From 816d1df6020874a1fc2eca093a6e2fc11e732bf2 Mon Sep 17 00:00:00 2001 From: Braulio Bhavamitra Date: Mon, 30 Mar 2015 16:01:19 -0300 Subject: [PATCH] rails4: 'from' scope is reserved on rails4 --- plugins/custom_forms/controllers/custom_forms_plugin_myprofile_controller.rb | 4 ++-- plugins/custom_forms/lib/custom_forms_plugin/form.rb | 4 ++-- plugins/custom_forms/lib/custom_forms_plugin/membership_survey.rb | 2 +- plugins/custom_forms/lib/ext/role_assignment_trigger.rb | 8 ++++---- plugins/custom_forms/test/unit/custom_forms_plugin/form_test.rb | 8 ++++---- plugins/custom_forms/test/unit/custom_forms_plugin/membership_survey_test.rb | 2 +- plugins/spaminator/controllers/spaminator_plugin_admin_controller.rb | 6 +++--- plugins/spaminator/lib/spaminator_plugin/report.rb | 2 +- plugins/spaminator/test/unit/spaminator_plugin/report_test.rb | 2 +- 9 files changed, 19 insertions(+), 19 deletions(-) diff --git a/plugins/custom_forms/controllers/custom_forms_plugin_myprofile_controller.rb b/plugins/custom_forms/controllers/custom_forms_plugin_myprofile_controller.rb index 6e684f0..73cfd92 100644 --- a/plugins/custom_forms/controllers/custom_forms_plugin_myprofile_controller.rb +++ b/plugins/custom_forms/controllers/custom_forms_plugin_myprofile_controller.rb @@ -4,7 +4,7 @@ class CustomFormsPluginMyprofileController < MyProfileController protect 'post_content', :profile def index - @forms = CustomFormsPlugin::Form.from(profile) + @forms = CustomFormsPlugin::Form.from_profile(profile) end def new @@ -94,7 +94,7 @@ class CustomFormsPluginMyprofileController < MyProfileController def pending @form = CustomFormsPlugin::Form.find(params[:id]) - @pendings = CustomFormsPlugin::AdmissionSurvey.from(@form.profile).pending.select {|task| task.form_id == @form.id}.map {|a| {:profile => a.target, :time => a.created_at} } + @pendings = CustomFormsPlugin::AdmissionSurvey.from_profile(@form.profile).pending.select {|task| task.form_id == @form.id}.map {|a| {:profile => a.target, :time => a.created_at} } @sort_by = params[:sort_by] @pendings = @pendings.sort_by { |s| s[:profile].name } if @sort_by == 'user' diff --git a/plugins/custom_forms/lib/custom_forms_plugin/form.rb b/plugins/custom_forms/lib/custom_forms_plugin/form.rb index e3f27c7..1c92789 100644 --- a/plugins/custom_forms/lib/custom_forms_plugin/form.rb +++ b/plugins/custom_forms/lib/custom_forms_plugin/form.rb @@ -25,7 +25,7 @@ class CustomFormsPlugin::Form < Noosfero::Plugin::ActiveRecord tasks.each {|task| task.cancel} end - scope :from, lambda {|profile| {:conditions => {:profile_id => profile.id}}} + scope :from_profile, lambda {|profile| {:conditions => {:profile_id => profile.id}}} scope :on_memberships, {:conditions => {:on_membership => true, :for_admission => false}} scope :for_admissions, {:conditions => {:for_admission => true}} =begin @@ -84,6 +84,6 @@ class CustomFormsPlugin::Form < Noosfero::Plugin::ActiveRecord end def period_range - errors.add(:base, _('The time range selected is invalid.')) if ending < begining + errors.add(:base, _('The time range selected is invalid.')) if ending < begining end end diff --git a/plugins/custom_forms/lib/custom_forms_plugin/membership_survey.rb b/plugins/custom_forms/lib/custom_forms_plugin/membership_survey.rb index a87c071..377f49f 100644 --- a/plugins/custom_forms/lib/custom_forms_plugin/membership_survey.rb +++ b/plugins/custom_forms/lib/custom_forms_plugin/membership_survey.rb @@ -5,7 +5,7 @@ class CustomFormsPlugin::MembershipSurvey < Task include CustomFormsPlugin::Helper - scope :from, lambda {|profile| {:conditions => {:requestor_id => profile.id}}} + scope :from_profile, lambda {|profile| {:conditions => {:requestor_id => profile.id}}} def perform form = CustomFormsPlugin::Form.find(form_id) diff --git a/plugins/custom_forms/lib/ext/role_assignment_trigger.rb b/plugins/custom_forms/lib/ext/role_assignment_trigger.rb index 3348819..85af090 100644 --- a/plugins/custom_forms/lib/ext/role_assignment_trigger.rb +++ b/plugins/custom_forms/lib/ext/role_assignment_trigger.rb @@ -7,7 +7,7 @@ module RoleAssignmentTrigger person = ra.accessor ok = !profile.nil? && !person.nil? && profile.environment.present? if ok && profile.environment.plugin_enabled?(CustomFormsPlugin) && !person.is_member_of?(profile) - CustomFormsPlugin::Form.from(profile).on_memberships.each do |form| + CustomFormsPlugin::Form.from_profile(profile).on_memberships.each do |form| CustomFormsPlugin::MembershipSurvey.create!(:requestor => profile, :target => person, :form_id => form.id) end end @@ -21,7 +21,7 @@ module RoleAssignmentTrigger person = ra.accessor ok = !profile.nil? && !person.nil? && profile.environment.present? if ok && profile.environment.plugin_enabled?(CustomFormsPlugin) && !person.is_member_of?(profile) - CustomFormsPlugin::Form.from(profile).for_admissions.each do |form| + CustomFormsPlugin::Form.from_profile(profile).for_admissions.each do |form| admission_task_pending = person.tasks.pending.select {|task| task.kind_of?(CustomFormsPlugin::AdmissionSurvey) && task.form_id == form.id }.present? admission_task_finished = person.tasks.finished.select {|task| task.kind_of?(CustomFormsPlugin::AdmissionSurvey) && task.form_id == form.id }.present? @@ -39,11 +39,11 @@ module RoleAssignmentTrigger person = ra.accessor ok = !profile.nil? && !person.nil? && profile.environment.present? if ok && profile.environment.plugin_enabled?(CustomFormsPlugin) && !person.is_member_of?(profile) - CustomFormsPlugin::Form.from(profile).on_memberships.each do |form| + CustomFormsPlugin::Form.from_profile(profile).on_memberships.each do |form| task = person.tasks.pending.select {|task| task.kind_of?(CustomFormsPlugin::MembershipSurvey) && task.form_id == form.id}.first task.cancel if task end - CustomFormsPlugin::Form.from(profile).for_admissions.each do |form| + CustomFormsPlugin::Form.from_profile(profile).for_admissions.each do |form| task = person.tasks.pending.select {|task| task.kind_of?(CustomFormsPlugin::MembershipSurvey) && task.form_id == form.id}.first task.cancel if task end diff --git a/plugins/custom_forms/test/unit/custom_forms_plugin/form_test.rb b/plugins/custom_forms/test/unit/custom_forms_plugin/form_test.rb index 74f81c3..132d323 100644 --- a/plugins/custom_forms/test/unit/custom_forms_plugin/form_test.rb +++ b/plugins/custom_forms/test/unit/custom_forms_plugin/form_test.rb @@ -179,7 +179,7 @@ class CustomFormsPlugin::FormTest < ActiveSupport::TestCase f1 = CustomFormsPlugin::Form.create!(:name => 'Free Software', :profile => profile) f2 = CustomFormsPlugin::Form.create!(:name => 'Open Source', :profile => profile) f3 = CustomFormsPlugin::Form.create!(:name => 'Free Software', :profile => another_profile) - scope = CustomFormsPlugin::Form.from(profile) + scope = CustomFormsPlugin::Form.from_profile(profile) assert_equal ActiveRecord::Relation, scope.class assert_includes scope, f1 @@ -192,7 +192,7 @@ class CustomFormsPlugin::FormTest < ActiveSupport::TestCase f1 = CustomFormsPlugin::Form.create!(:name => 'On membership 1', :profile => profile, :on_membership => true) f2 = CustomFormsPlugin::Form.create!(:name => 'On membership 2', :profile => profile, :on_membership => true) f3 = CustomFormsPlugin::Form.create!(:name => 'Not on memberhsip', :profile => profile, :on_membership => false) - scope = CustomFormsPlugin::Form.from(profile).on_memberships + scope = CustomFormsPlugin::Form.from_profile(profile).on_memberships assert_equal ActiveRecord::Relation, scope.class assert_includes scope, f1 @@ -223,7 +223,7 @@ class CustomFormsPlugin::FormTest < ActiveSupport::TestCase f1 = CustomFormsPlugin::Form.create!(:name => 'For admission 1', :profile => profile, :for_admission => true) f2 = CustomFormsPlugin::Form.create!(:name => 'For admission 2', :profile => profile, :for_admission => true) f3 = CustomFormsPlugin::Form.create!(:name => 'Not for admission', :profile => profile, :for_admission => false) - scope = CustomFormsPlugin::Form.from(profile).for_admissions + scope = CustomFormsPlugin::Form.from_profile(profile).for_admissions assert_equal ActiveRecord::Relation, scope.class assert_includes scope, f1 @@ -235,7 +235,7 @@ class CustomFormsPlugin::FormTest < ActiveSupport::TestCase profile = fast_create(Profile) f1 = CustomFormsPlugin::Form.create!(:name => 'On membership', :profile => profile, :on_membership => true) f2 = CustomFormsPlugin::Form.create!(:name => 'For admission', :profile => profile, :on_membership => true, :for_admission => true) - scope = CustomFormsPlugin::Form.from(profile).on_memberships + scope = CustomFormsPlugin::Form.from_profile(profile).on_memberships assert_equal ActiveRecord::Relation, scope.class assert_includes scope, f1 diff --git a/plugins/custom_forms/test/unit/custom_forms_plugin/membership_survey_test.rb b/plugins/custom_forms/test/unit/custom_forms_plugin/membership_survey_test.rb index 00e3713..0862615 100644 --- a/plugins/custom_forms/test/unit/custom_forms_plugin/membership_survey_test.rb +++ b/plugins/custom_forms/test/unit/custom_forms_plugin/membership_survey_test.rb @@ -35,7 +35,7 @@ class CustomFormsPlugin::MembershipSurveyTest < ActiveSupport::TestCase form = CustomFormsPlugin::Form.create!(:name => 'Simple Form', :profile => profile) task1 = CustomFormsPlugin::MembershipSurvey.create!(:form_id => form.id, :target => person, :requestor => profile) task2 = CustomFormsPlugin::MembershipSurvey.create!(:form_id => form.id, :target => person, :requestor => fast_create(Profile)) - scope = CustomFormsPlugin::MembershipSurvey.from(profile) + scope = CustomFormsPlugin::MembershipSurvey.from_profile(profile) assert_equal ActiveRecord::Relation, scope.class assert_includes scope, task1 diff --git a/plugins/spaminator/controllers/spaminator_plugin_admin_controller.rb b/plugins/spaminator/controllers/spaminator_plugin_admin_controller.rb index dad88b5..ce761bb 100644 --- a/plugins/spaminator/controllers/spaminator_plugin_admin_controller.rb +++ b/plugins/spaminator/controllers/spaminator_plugin_admin_controller.rb @@ -3,8 +3,8 @@ class SpaminatorPluginAdminController < AdminController def index @settings ||= Noosfero::Plugin::Settings.new(environment, SpaminatorPlugin, params[:settings]) - @reports_count = SpaminatorPlugin::Report.from(environment).count - @reports = SpaminatorPlugin::Report.from(environment).order('created_at desc').limit(3) + @reports_count = SpaminatorPlugin::Report.from_environment(environment).count + @reports = SpaminatorPlugin::Report.from_environment(environment).order('created_at desc').limit(3) @next_run = settings.period.to_i + ((settings.last_run || Date.today).to_date - Date.today) if request.post? settings.period = nil if settings.period.blank? @@ -40,7 +40,7 @@ class SpaminatorPluginAdminController < AdminController end def reports - @reports = SpaminatorPlugin::Report.from(environment).order('created_at desc') + @reports = SpaminatorPlugin::Report.from_environment(environment).order('created_at desc') end private diff --git a/plugins/spaminator/lib/spaminator_plugin/report.rb b/plugins/spaminator/lib/spaminator_plugin/report.rb index bb7cb77..2ca8eb0 100644 --- a/plugins/spaminator/lib/spaminator_plugin/report.rb +++ b/plugins/spaminator/lib/spaminator_plugin/report.rb @@ -7,7 +7,7 @@ class SpaminatorPlugin::Report < Noosfero::Plugin::ActiveRecord attr_accessible :environment - scope :from, lambda { |environment| {:conditions => {:environment_id => environment}}} + scope :from_environment, lambda { |environment| {:conditions => {:environment_id => environment}}} after_initialize do |report| report.failed = {:people => [], :comments => []} if report.failed.blank? diff --git a/plugins/spaminator/test/unit/spaminator_plugin/report_test.rb b/plugins/spaminator/test/unit/spaminator_plugin/report_test.rb index 353e127..9b97c6b 100644 --- a/plugins/spaminator/test/unit/spaminator_plugin/report_test.rb +++ b/plugins/spaminator/test/unit/spaminator_plugin/report_test.rb @@ -19,7 +19,7 @@ class SpaminatorPlugin::ReportTest < ActiveSupport::TestCase r3 = SpaminatorPlugin::Report.create(:environment => environment) r4 = SpaminatorPlugin::Report.create(:environment => fast_create(Environment)) - reports = SpaminatorPlugin::Report.from(environment) + reports = SpaminatorPlugin::Report.from_environment(environment) assert_equal ActiveRecord::Relation, reports.class assert_includes reports, r1 -- libgit2 0.21.2