Commit 816d1df6020874a1fc2eca093a6e2fc11e732bf2
1 parent
77c8eca9
Exists in
master
and in
20 other branches
rails4: 'from' scope is reserved on rails4
Showing
9 changed files
with
19 additions
and
19 deletions
Show diff stats
plugins/custom_forms/controllers/custom_forms_plugin_myprofile_controller.rb
@@ -4,7 +4,7 @@ class CustomFormsPluginMyprofileController < MyProfileController | @@ -4,7 +4,7 @@ class CustomFormsPluginMyprofileController < MyProfileController | ||
4 | protect 'post_content', :profile | 4 | protect 'post_content', :profile |
5 | 5 | ||
6 | def index | 6 | def index |
7 | - @forms = CustomFormsPlugin::Form.from(profile) | 7 | + @forms = CustomFormsPlugin::Form.from_profile(profile) |
8 | end | 8 | end |
9 | 9 | ||
10 | def new | 10 | def new |
@@ -94,7 +94,7 @@ class CustomFormsPluginMyprofileController < MyProfileController | @@ -94,7 +94,7 @@ class CustomFormsPluginMyprofileController < MyProfileController | ||
94 | 94 | ||
95 | def pending | 95 | def pending |
96 | @form = CustomFormsPlugin::Form.find(params[:id]) | 96 | @form = CustomFormsPlugin::Form.find(params[:id]) |
97 | - @pendings = CustomFormsPlugin::AdmissionSurvey.from(@form.profile).pending.select {|task| task.form_id == @form.id}.map {|a| {:profile => a.target, :time => a.created_at} } | 97 | + @pendings = CustomFormsPlugin::AdmissionSurvey.from_profile(@form.profile).pending.select {|task| task.form_id == @form.id}.map {|a| {:profile => a.target, :time => a.created_at} } |
98 | 98 | ||
99 | @sort_by = params[:sort_by] | 99 | @sort_by = params[:sort_by] |
100 | @pendings = @pendings.sort_by { |s| s[:profile].name } if @sort_by == 'user' | 100 | @pendings = @pendings.sort_by { |s| s[:profile].name } if @sort_by == 'user' |
plugins/custom_forms/lib/custom_forms_plugin/form.rb
@@ -25,7 +25,7 @@ class CustomFormsPlugin::Form < Noosfero::Plugin::ActiveRecord | @@ -25,7 +25,7 @@ class CustomFormsPlugin::Form < Noosfero::Plugin::ActiveRecord | ||
25 | tasks.each {|task| task.cancel} | 25 | tasks.each {|task| task.cancel} |
26 | end | 26 | end |
27 | 27 | ||
28 | - scope :from, lambda {|profile| {:conditions => {:profile_id => profile.id}}} | 28 | + scope :from_profile, lambda {|profile| {:conditions => {:profile_id => profile.id}}} |
29 | scope :on_memberships, {:conditions => {:on_membership => true, :for_admission => false}} | 29 | scope :on_memberships, {:conditions => {:on_membership => true, :for_admission => false}} |
30 | scope :for_admissions, {:conditions => {:for_admission => true}} | 30 | scope :for_admissions, {:conditions => {:for_admission => true}} |
31 | =begin | 31 | =begin |
@@ -84,6 +84,6 @@ class CustomFormsPlugin::Form < Noosfero::Plugin::ActiveRecord | @@ -84,6 +84,6 @@ class CustomFormsPlugin::Form < Noosfero::Plugin::ActiveRecord | ||
84 | end | 84 | end |
85 | 85 | ||
86 | def period_range | 86 | def period_range |
87 | - errors.add(:base, _('The time range selected is invalid.')) if ending < begining | 87 | + errors.add(:base, _('The time range selected is invalid.')) if ending < begining |
88 | end | 88 | end |
89 | end | 89 | end |
plugins/custom_forms/lib/custom_forms_plugin/membership_survey.rb
@@ -5,7 +5,7 @@ class CustomFormsPlugin::MembershipSurvey < Task | @@ -5,7 +5,7 @@ class CustomFormsPlugin::MembershipSurvey < Task | ||
5 | 5 | ||
6 | include CustomFormsPlugin::Helper | 6 | include CustomFormsPlugin::Helper |
7 | 7 | ||
8 | - scope :from, lambda {|profile| {:conditions => {:requestor_id => profile.id}}} | 8 | + scope :from_profile, lambda {|profile| {:conditions => {:requestor_id => profile.id}}} |
9 | 9 | ||
10 | def perform | 10 | def perform |
11 | form = CustomFormsPlugin::Form.find(form_id) | 11 | form = CustomFormsPlugin::Form.find(form_id) |
plugins/custom_forms/lib/ext/role_assignment_trigger.rb
@@ -7,7 +7,7 @@ module RoleAssignmentTrigger | @@ -7,7 +7,7 @@ module RoleAssignmentTrigger | ||
7 | person = ra.accessor | 7 | person = ra.accessor |
8 | ok = !profile.nil? && !person.nil? && profile.environment.present? | 8 | ok = !profile.nil? && !person.nil? && profile.environment.present? |
9 | if ok && profile.environment.plugin_enabled?(CustomFormsPlugin) && !person.is_member_of?(profile) | 9 | if ok && profile.environment.plugin_enabled?(CustomFormsPlugin) && !person.is_member_of?(profile) |
10 | - CustomFormsPlugin::Form.from(profile).on_memberships.each do |form| | 10 | + CustomFormsPlugin::Form.from_profile(profile).on_memberships.each do |form| |
11 | CustomFormsPlugin::MembershipSurvey.create!(:requestor => profile, :target => person, :form_id => form.id) | 11 | CustomFormsPlugin::MembershipSurvey.create!(:requestor => profile, :target => person, :form_id => form.id) |
12 | end | 12 | end |
13 | end | 13 | end |
@@ -21,7 +21,7 @@ module RoleAssignmentTrigger | @@ -21,7 +21,7 @@ module RoleAssignmentTrigger | ||
21 | person = ra.accessor | 21 | person = ra.accessor |
22 | ok = !profile.nil? && !person.nil? && profile.environment.present? | 22 | ok = !profile.nil? && !person.nil? && profile.environment.present? |
23 | if ok && profile.environment.plugin_enabled?(CustomFormsPlugin) && !person.is_member_of?(profile) | 23 | if ok && profile.environment.plugin_enabled?(CustomFormsPlugin) && !person.is_member_of?(profile) |
24 | - CustomFormsPlugin::Form.from(profile).for_admissions.each do |form| | 24 | + CustomFormsPlugin::Form.from_profile(profile).for_admissions.each do |form| |
25 | admission_task_pending = person.tasks.pending.select {|task| task.kind_of?(CustomFormsPlugin::AdmissionSurvey) && task.form_id == form.id }.present? | 25 | admission_task_pending = person.tasks.pending.select {|task| task.kind_of?(CustomFormsPlugin::AdmissionSurvey) && task.form_id == form.id }.present? |
26 | admission_task_finished = person.tasks.finished.select {|task| task.kind_of?(CustomFormsPlugin::AdmissionSurvey) && task.form_id == form.id }.present? | 26 | admission_task_finished = person.tasks.finished.select {|task| task.kind_of?(CustomFormsPlugin::AdmissionSurvey) && task.form_id == form.id }.present? |
27 | 27 | ||
@@ -39,11 +39,11 @@ module RoleAssignmentTrigger | @@ -39,11 +39,11 @@ module RoleAssignmentTrigger | ||
39 | person = ra.accessor | 39 | person = ra.accessor |
40 | ok = !profile.nil? && !person.nil? && profile.environment.present? | 40 | ok = !profile.nil? && !person.nil? && profile.environment.present? |
41 | if ok && profile.environment.plugin_enabled?(CustomFormsPlugin) && !person.is_member_of?(profile) | 41 | if ok && profile.environment.plugin_enabled?(CustomFormsPlugin) && !person.is_member_of?(profile) |
42 | - CustomFormsPlugin::Form.from(profile).on_memberships.each do |form| | 42 | + CustomFormsPlugin::Form.from_profile(profile).on_memberships.each do |form| |
43 | task = person.tasks.pending.select {|task| task.kind_of?(CustomFormsPlugin::MembershipSurvey) && task.form_id == form.id}.first | 43 | task = person.tasks.pending.select {|task| task.kind_of?(CustomFormsPlugin::MembershipSurvey) && task.form_id == form.id}.first |
44 | task.cancel if task | 44 | task.cancel if task |
45 | end | 45 | end |
46 | - CustomFormsPlugin::Form.from(profile).for_admissions.each do |form| | 46 | + CustomFormsPlugin::Form.from_profile(profile).for_admissions.each do |form| |
47 | task = person.tasks.pending.select {|task| task.kind_of?(CustomFormsPlugin::MembershipSurvey) && task.form_id == form.id}.first | 47 | task = person.tasks.pending.select {|task| task.kind_of?(CustomFormsPlugin::MembershipSurvey) && task.form_id == form.id}.first |
48 | task.cancel if task | 48 | task.cancel if task |
49 | end | 49 | end |
plugins/custom_forms/test/unit/custom_forms_plugin/form_test.rb
@@ -179,7 +179,7 @@ class CustomFormsPlugin::FormTest < ActiveSupport::TestCase | @@ -179,7 +179,7 @@ class CustomFormsPlugin::FormTest < ActiveSupport::TestCase | ||
179 | f1 = CustomFormsPlugin::Form.create!(:name => 'Free Software', :profile => profile) | 179 | f1 = CustomFormsPlugin::Form.create!(:name => 'Free Software', :profile => profile) |
180 | f2 = CustomFormsPlugin::Form.create!(:name => 'Open Source', :profile => profile) | 180 | f2 = CustomFormsPlugin::Form.create!(:name => 'Open Source', :profile => profile) |
181 | f3 = CustomFormsPlugin::Form.create!(:name => 'Free Software', :profile => another_profile) | 181 | f3 = CustomFormsPlugin::Form.create!(:name => 'Free Software', :profile => another_profile) |
182 | - scope = CustomFormsPlugin::Form.from(profile) | 182 | + scope = CustomFormsPlugin::Form.from_profile(profile) |
183 | 183 | ||
184 | assert_equal ActiveRecord::Relation, scope.class | 184 | assert_equal ActiveRecord::Relation, scope.class |
185 | assert_includes scope, f1 | 185 | assert_includes scope, f1 |
@@ -192,7 +192,7 @@ class CustomFormsPlugin::FormTest < ActiveSupport::TestCase | @@ -192,7 +192,7 @@ class CustomFormsPlugin::FormTest < ActiveSupport::TestCase | ||
192 | f1 = CustomFormsPlugin::Form.create!(:name => 'On membership 1', :profile => profile, :on_membership => true) | 192 | f1 = CustomFormsPlugin::Form.create!(:name => 'On membership 1', :profile => profile, :on_membership => true) |
193 | f2 = CustomFormsPlugin::Form.create!(:name => 'On membership 2', :profile => profile, :on_membership => true) | 193 | f2 = CustomFormsPlugin::Form.create!(:name => 'On membership 2', :profile => profile, :on_membership => true) |
194 | f3 = CustomFormsPlugin::Form.create!(:name => 'Not on memberhsip', :profile => profile, :on_membership => false) | 194 | f3 = CustomFormsPlugin::Form.create!(:name => 'Not on memberhsip', :profile => profile, :on_membership => false) |
195 | - scope = CustomFormsPlugin::Form.from(profile).on_memberships | 195 | + scope = CustomFormsPlugin::Form.from_profile(profile).on_memberships |
196 | 196 | ||
197 | assert_equal ActiveRecord::Relation, scope.class | 197 | assert_equal ActiveRecord::Relation, scope.class |
198 | assert_includes scope, f1 | 198 | assert_includes scope, f1 |
@@ -223,7 +223,7 @@ class CustomFormsPlugin::FormTest < ActiveSupport::TestCase | @@ -223,7 +223,7 @@ class CustomFormsPlugin::FormTest < ActiveSupport::TestCase | ||
223 | f1 = CustomFormsPlugin::Form.create!(:name => 'For admission 1', :profile => profile, :for_admission => true) | 223 | f1 = CustomFormsPlugin::Form.create!(:name => 'For admission 1', :profile => profile, :for_admission => true) |
224 | f2 = CustomFormsPlugin::Form.create!(:name => 'For admission 2', :profile => profile, :for_admission => true) | 224 | f2 = CustomFormsPlugin::Form.create!(:name => 'For admission 2', :profile => profile, :for_admission => true) |
225 | f3 = CustomFormsPlugin::Form.create!(:name => 'Not for admission', :profile => profile, :for_admission => false) | 225 | f3 = CustomFormsPlugin::Form.create!(:name => 'Not for admission', :profile => profile, :for_admission => false) |
226 | - scope = CustomFormsPlugin::Form.from(profile).for_admissions | 226 | + scope = CustomFormsPlugin::Form.from_profile(profile).for_admissions |
227 | 227 | ||
228 | assert_equal ActiveRecord::Relation, scope.class | 228 | assert_equal ActiveRecord::Relation, scope.class |
229 | assert_includes scope, f1 | 229 | assert_includes scope, f1 |
@@ -235,7 +235,7 @@ class CustomFormsPlugin::FormTest < ActiveSupport::TestCase | @@ -235,7 +235,7 @@ class CustomFormsPlugin::FormTest < ActiveSupport::TestCase | ||
235 | profile = fast_create(Profile) | 235 | profile = fast_create(Profile) |
236 | f1 = CustomFormsPlugin::Form.create!(:name => 'On membership', :profile => profile, :on_membership => true) | 236 | f1 = CustomFormsPlugin::Form.create!(:name => 'On membership', :profile => profile, :on_membership => true) |
237 | f2 = CustomFormsPlugin::Form.create!(:name => 'For admission', :profile => profile, :on_membership => true, :for_admission => true) | 237 | f2 = CustomFormsPlugin::Form.create!(:name => 'For admission', :profile => profile, :on_membership => true, :for_admission => true) |
238 | - scope = CustomFormsPlugin::Form.from(profile).on_memberships | 238 | + scope = CustomFormsPlugin::Form.from_profile(profile).on_memberships |
239 | 239 | ||
240 | assert_equal ActiveRecord::Relation, scope.class | 240 | assert_equal ActiveRecord::Relation, scope.class |
241 | assert_includes scope, f1 | 241 | assert_includes scope, f1 |
plugins/custom_forms/test/unit/custom_forms_plugin/membership_survey_test.rb
@@ -35,7 +35,7 @@ class CustomFormsPlugin::MembershipSurveyTest < ActiveSupport::TestCase | @@ -35,7 +35,7 @@ class CustomFormsPlugin::MembershipSurveyTest < ActiveSupport::TestCase | ||
35 | form = CustomFormsPlugin::Form.create!(:name => 'Simple Form', :profile => profile) | 35 | form = CustomFormsPlugin::Form.create!(:name => 'Simple Form', :profile => profile) |
36 | task1 = CustomFormsPlugin::MembershipSurvey.create!(:form_id => form.id, :target => person, :requestor => profile) | 36 | task1 = CustomFormsPlugin::MembershipSurvey.create!(:form_id => form.id, :target => person, :requestor => profile) |
37 | task2 = CustomFormsPlugin::MembershipSurvey.create!(:form_id => form.id, :target => person, :requestor => fast_create(Profile)) | 37 | task2 = CustomFormsPlugin::MembershipSurvey.create!(:form_id => form.id, :target => person, :requestor => fast_create(Profile)) |
38 | - scope = CustomFormsPlugin::MembershipSurvey.from(profile) | 38 | + scope = CustomFormsPlugin::MembershipSurvey.from_profile(profile) |
39 | 39 | ||
40 | assert_equal ActiveRecord::Relation, scope.class | 40 | assert_equal ActiveRecord::Relation, scope.class |
41 | assert_includes scope, task1 | 41 | assert_includes scope, task1 |
plugins/spaminator/controllers/spaminator_plugin_admin_controller.rb
@@ -3,8 +3,8 @@ class SpaminatorPluginAdminController < AdminController | @@ -3,8 +3,8 @@ class SpaminatorPluginAdminController < AdminController | ||
3 | 3 | ||
4 | def index | 4 | def index |
5 | @settings ||= Noosfero::Plugin::Settings.new(environment, SpaminatorPlugin, params[:settings]) | 5 | @settings ||= Noosfero::Plugin::Settings.new(environment, SpaminatorPlugin, params[:settings]) |
6 | - @reports_count = SpaminatorPlugin::Report.from(environment).count | ||
7 | - @reports = SpaminatorPlugin::Report.from(environment).order('created_at desc').limit(3) | 6 | + @reports_count = SpaminatorPlugin::Report.from_environment(environment).count |
7 | + @reports = SpaminatorPlugin::Report.from_environment(environment).order('created_at desc').limit(3) | ||
8 | @next_run = settings.period.to_i + ((settings.last_run || Date.today).to_date - Date.today) | 8 | @next_run = settings.period.to_i + ((settings.last_run || Date.today).to_date - Date.today) |
9 | if request.post? | 9 | if request.post? |
10 | settings.period = nil if settings.period.blank? | 10 | settings.period = nil if settings.period.blank? |
@@ -40,7 +40,7 @@ class SpaminatorPluginAdminController < AdminController | @@ -40,7 +40,7 @@ class SpaminatorPluginAdminController < AdminController | ||
40 | end | 40 | end |
41 | 41 | ||
42 | def reports | 42 | def reports |
43 | - @reports = SpaminatorPlugin::Report.from(environment).order('created_at desc') | 43 | + @reports = SpaminatorPlugin::Report.from_environment(environment).order('created_at desc') |
44 | end | 44 | end |
45 | 45 | ||
46 | private | 46 | private |
plugins/spaminator/lib/spaminator_plugin/report.rb
@@ -7,7 +7,7 @@ class SpaminatorPlugin::Report < Noosfero::Plugin::ActiveRecord | @@ -7,7 +7,7 @@ class SpaminatorPlugin::Report < Noosfero::Plugin::ActiveRecord | ||
7 | 7 | ||
8 | attr_accessible :environment | 8 | attr_accessible :environment |
9 | 9 | ||
10 | - scope :from, lambda { |environment| {:conditions => {:environment_id => environment}}} | 10 | + scope :from_environment, lambda { |environment| {:conditions => {:environment_id => environment}}} |
11 | 11 | ||
12 | after_initialize do |report| | 12 | after_initialize do |report| |
13 | report.failed = {:people => [], :comments => []} if report.failed.blank? | 13 | report.failed = {:people => [], :comments => []} if report.failed.blank? |
plugins/spaminator/test/unit/spaminator_plugin/report_test.rb
@@ -19,7 +19,7 @@ class SpaminatorPlugin::ReportTest < ActiveSupport::TestCase | @@ -19,7 +19,7 @@ class SpaminatorPlugin::ReportTest < ActiveSupport::TestCase | ||
19 | r3 = SpaminatorPlugin::Report.create(:environment => environment) | 19 | r3 = SpaminatorPlugin::Report.create(:environment => environment) |
20 | r4 = SpaminatorPlugin::Report.create(:environment => fast_create(Environment)) | 20 | r4 = SpaminatorPlugin::Report.create(:environment => fast_create(Environment)) |
21 | 21 | ||
22 | - reports = SpaminatorPlugin::Report.from(environment) | 22 | + reports = SpaminatorPlugin::Report.from_environment(environment) |
23 | 23 | ||
24 | assert_equal ActiveRecord::Relation, reports.class | 24 | assert_equal ActiveRecord::Relation, reports.class |
25 | assert_includes reports, r1 | 25 | assert_includes reports, r1 |