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 | 4 | protect 'post_content', :profile |
5 | 5 | |
6 | 6 | def index |
7 | - @forms = CustomFormsPlugin::Form.from(profile) | |
7 | + @forms = CustomFormsPlugin::Form.from_profile(profile) | |
8 | 8 | end |
9 | 9 | |
10 | 10 | def new |
... | ... | @@ -94,7 +94,7 @@ class CustomFormsPluginMyprofileController < MyProfileController |
94 | 94 | |
95 | 95 | def pending |
96 | 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 | 99 | @sort_by = params[:sort_by] |
100 | 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 | 25 | tasks.each {|task| task.cancel} |
26 | 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 | 29 | scope :on_memberships, {:conditions => {:on_membership => true, :for_admission => false}} |
30 | 30 | scope :for_admissions, {:conditions => {:for_admission => true}} |
31 | 31 | =begin |
... | ... | @@ -84,6 +84,6 @@ class CustomFormsPlugin::Form < Noosfero::Plugin::ActiveRecord |
84 | 84 | end |
85 | 85 | |
86 | 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 | 88 | end |
89 | 89 | end | ... | ... |
plugins/custom_forms/lib/custom_forms_plugin/membership_survey.rb
... | ... | @@ -5,7 +5,7 @@ class CustomFormsPlugin::MembershipSurvey < Task |
5 | 5 | |
6 | 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 | 10 | def perform |
11 | 11 | form = CustomFormsPlugin::Form.find(form_id) | ... | ... |
plugins/custom_forms/lib/ext/role_assignment_trigger.rb
... | ... | @@ -7,7 +7,7 @@ module RoleAssignmentTrigger |
7 | 7 | person = ra.accessor |
8 | 8 | ok = !profile.nil? && !person.nil? && profile.environment.present? |
9 | 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 | 11 | CustomFormsPlugin::MembershipSurvey.create!(:requestor => profile, :target => person, :form_id => form.id) |
12 | 12 | end |
13 | 13 | end |
... | ... | @@ -21,7 +21,7 @@ module RoleAssignmentTrigger |
21 | 21 | person = ra.accessor |
22 | 22 | ok = !profile.nil? && !person.nil? && profile.environment.present? |
23 | 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 | 25 | admission_task_pending = person.tasks.pending.select {|task| task.kind_of?(CustomFormsPlugin::AdmissionSurvey) && task.form_id == form.id }.present? |
26 | 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 | 39 | person = ra.accessor |
40 | 40 | ok = !profile.nil? && !person.nil? && profile.environment.present? |
41 | 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 | 43 | task = person.tasks.pending.select {|task| task.kind_of?(CustomFormsPlugin::MembershipSurvey) && task.form_id == form.id}.first |
44 | 44 | task.cancel if task |
45 | 45 | end |
46 | - CustomFormsPlugin::Form.from(profile).for_admissions.each do |form| | |
46 | + CustomFormsPlugin::Form.from_profile(profile).for_admissions.each do |form| | |
47 | 47 | task = person.tasks.pending.select {|task| task.kind_of?(CustomFormsPlugin::MembershipSurvey) && task.form_id == form.id}.first |
48 | 48 | task.cancel if task |
49 | 49 | end | ... | ... |
plugins/custom_forms/test/unit/custom_forms_plugin/form_test.rb
... | ... | @@ -179,7 +179,7 @@ class CustomFormsPlugin::FormTest < ActiveSupport::TestCase |
179 | 179 | f1 = CustomFormsPlugin::Form.create!(:name => 'Free Software', :profile => profile) |
180 | 180 | f2 = CustomFormsPlugin::Form.create!(:name => 'Open Source', :profile => profile) |
181 | 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 | 184 | assert_equal ActiveRecord::Relation, scope.class |
185 | 185 | assert_includes scope, f1 |
... | ... | @@ -192,7 +192,7 @@ class CustomFormsPlugin::FormTest < ActiveSupport::TestCase |
192 | 192 | f1 = CustomFormsPlugin::Form.create!(:name => 'On membership 1', :profile => profile, :on_membership => true) |
193 | 193 | f2 = CustomFormsPlugin::Form.create!(:name => 'On membership 2', :profile => profile, :on_membership => true) |
194 | 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 | 197 | assert_equal ActiveRecord::Relation, scope.class |
198 | 198 | assert_includes scope, f1 |
... | ... | @@ -223,7 +223,7 @@ class CustomFormsPlugin::FormTest < ActiveSupport::TestCase |
223 | 223 | f1 = CustomFormsPlugin::Form.create!(:name => 'For admission 1', :profile => profile, :for_admission => true) |
224 | 224 | f2 = CustomFormsPlugin::Form.create!(:name => 'For admission 2', :profile => profile, :for_admission => true) |
225 | 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 | 228 | assert_equal ActiveRecord::Relation, scope.class |
229 | 229 | assert_includes scope, f1 |
... | ... | @@ -235,7 +235,7 @@ class CustomFormsPlugin::FormTest < ActiveSupport::TestCase |
235 | 235 | profile = fast_create(Profile) |
236 | 236 | f1 = CustomFormsPlugin::Form.create!(:name => 'On membership', :profile => profile, :on_membership => true) |
237 | 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 | 240 | assert_equal ActiveRecord::Relation, scope.class |
241 | 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 | 35 | form = CustomFormsPlugin::Form.create!(:name => 'Simple Form', :profile => profile) |
36 | 36 | task1 = CustomFormsPlugin::MembershipSurvey.create!(:form_id => form.id, :target => person, :requestor => profile) |
37 | 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 | 40 | assert_equal ActiveRecord::Relation, scope.class |
41 | 41 | assert_includes scope, task1 | ... | ... |
plugins/spaminator/controllers/spaminator_plugin_admin_controller.rb
... | ... | @@ -3,8 +3,8 @@ class SpaminatorPluginAdminController < AdminController |
3 | 3 | |
4 | 4 | def index |
5 | 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 | 8 | @next_run = settings.period.to_i + ((settings.last_run || Date.today).to_date - Date.today) |
9 | 9 | if request.post? |
10 | 10 | settings.period = nil if settings.period.blank? |
... | ... | @@ -40,7 +40,7 @@ class SpaminatorPluginAdminController < AdminController |
40 | 40 | end |
41 | 41 | |
42 | 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 | 44 | end |
45 | 45 | |
46 | 46 | private | ... | ... |
plugins/spaminator/lib/spaminator_plugin/report.rb
... | ... | @@ -7,7 +7,7 @@ class SpaminatorPlugin::Report < Noosfero::Plugin::ActiveRecord |
7 | 7 | |
8 | 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 | 12 | after_initialize do |report| |
13 | 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 | 19 | r3 = SpaminatorPlugin::Report.create(:environment => environment) |
20 | 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 | 24 | assert_equal ActiveRecord::Relation, reports.class |
25 | 25 | assert_includes reports, r1 | ... | ... |