Commit 87f2fc55d9cb2645d362c8980f09bf0ad2dc97d2
1 parent
ad13aecb
Exists in
rails5
rails5: use ApplicationRecord pattern
Showing
101 changed files
with
183 additions
and
183 deletions
Show diff stats
Too many changes.
To preserve performance only 100 of 101 files displayed.
app/mailers/mailing.rb
app/models/abuse_report.rb
app/models/action_tracker_notification.rb
1 | -class ActionTrackerNotification < ActiveRecord::Base | 1 | +class ActionTrackerNotification < ApplicationRecord |
2 | 2 | ||
3 | belongs_to :profile | 3 | belongs_to :profile |
4 | belongs_to :action_tracker, :class_name => 'ActionTracker::Record', :foreign_key => 'action_tracker_id' | 4 | belongs_to :action_tracker, :class_name => 'ActionTracker::Record', :foreign_key => 'action_tracker_id' |
@@ -0,0 +1,64 @@ | @@ -0,0 +1,64 @@ | ||
1 | +class ApplicationRecord < ActiveRecord::Base | ||
2 | + | ||
3 | + self.abstract_class = true | ||
4 | + | ||
5 | + def self.postgresql? | ||
6 | + ActiveRecord::Base.connection.adapter_name == 'PostgreSQL' | ||
7 | + end | ||
8 | + | ||
9 | + # an ActionView instance for rendering views on models | ||
10 | + def self.action_view | ||
11 | + @action_view ||= begin | ||
12 | + view_paths = ::ActionController::Base.view_paths | ||
13 | + action_view = ::ActionView::Base.new view_paths | ||
14 | + # for using Noosfero helpers inside render calls | ||
15 | + action_view.extend ::ApplicationHelper | ||
16 | + action_view | ||
17 | + end | ||
18 | + end | ||
19 | + | ||
20 | + # default value needed for the above ActionView | ||
21 | + def to_partial_path | ||
22 | + self.class.name.underscore | ||
23 | + end | ||
24 | + | ||
25 | + alias :meta_cache_key :cache_key | ||
26 | + def cache_key | ||
27 | + key = [Noosfero::VERSION, meta_cache_key] | ||
28 | + key.unshift(ActiveRecord::Base.connection.schema_search_path) if ActiveRecord::Base.postgresql? | ||
29 | + key.join('/') | ||
30 | + end | ||
31 | + | ||
32 | + def self.like_search(query, options={}) | ||
33 | + if defined?(self::SEARCHABLE_FIELDS) || options[:fields].present? | ||
34 | + fields_per_table = {} | ||
35 | + fields_per_table[table_name] = (options[:fields].present? ? options[:fields] : self::SEARCHABLE_FIELDS.keys.map(&:to_s)) & column_names | ||
36 | + | ||
37 | + if options[:joins].present? | ||
38 | + join_asset = options[:joins].to_s.classify.constantize | ||
39 | + if defined?(join_asset::SEARCHABLE_FIELDS) || options[:fields].present? | ||
40 | + fields_per_table[join_asset.table_name] = (options[:fields].present? ? options[:fields] : join_asset::SEARCHABLE_FIELDS.keys.map(&:to_s)) & join_asset.column_names | ||
41 | + end | ||
42 | + end | ||
43 | + | ||
44 | + query = query.downcase.strip | ||
45 | + fields_per_table.delete_if { |table,fields| fields.blank? } | ||
46 | + conditions = fields_per_table.map do |table,fields| | ||
47 | + fields.map do |field| | ||
48 | + "lower(#{table}.#{field}) LIKE '%#{query}%'" | ||
49 | + end.join(' OR ') | ||
50 | + end.join(' OR ') | ||
51 | + | ||
52 | + if options[:joins].present? | ||
53 | + joins(options[:joins]).where(conditions) | ||
54 | + else | ||
55 | + where(conditions) | ||
56 | + end | ||
57 | + | ||
58 | + else | ||
59 | + raise "No searchable fields defined for #{self.name}" | ||
60 | + end | ||
61 | + end | ||
62 | + | ||
63 | +end | ||
64 | + |
app/models/article.rb
app/models/article_categorization.rb
app/models/block.rb
app/models/box.rb
app/models/category.rb
app/models/certifier.rb
app/models/chat_message.rb
app/models/comment.rb
app/models/contact_list.rb
app/models/custom_field.rb
app/models/custom_field_value.rb
app/models/domain.rb
app/models/environment.rb
1 | # A Environment is like a website to be hosted in the platform. It may | 1 | # A Environment is like a website to be hosted in the platform. It may |
2 | # contain multiple Profile's and can be identified by several different | 2 | # contain multiple Profile's and can be identified by several different |
3 | # domains. | 3 | # domains. |
4 | -class Environment < ActiveRecord::Base | 4 | +class Environment < ApplicationRecord |
5 | 5 | ||
6 | has_many :users | 6 | has_many :users |
7 | 7 |
app/models/external_feed.rb
app/models/favorite_enterprise_person.rb
1 | -class FavoriteEnterprisePerson < ActiveRecord::Base | 1 | +class FavoriteEnterprisePerson < ApplicationRecord |
2 | 2 | ||
3 | track_actions :favorite_enterprise, :after_create, keep_params: [:enterprise_name, :enterprise_url], if: proc{ |f| f.is_trackable? } | 3 | track_actions :favorite_enterprise, :after_create, keep_params: [:enterprise_name, :enterprise_url], if: proc{ |f| f.is_trackable? } |
4 | 4 |
app/models/friendship.rb
1 | -class Friendship < ActiveRecord::Base | 1 | +class Friendship < ApplicationRecord |
2 | track_actions :new_friendship, :after_create, :keep_params => ["friend.name", "friend.url", "friend.profile_custom_icon"], :custom_user => :person | 2 | track_actions :new_friendship, :after_create, :keep_params => ["friend.name", "friend.url", "friend.profile_custom_icon"], :custom_user => :person |
3 | 3 | ||
4 | extend CacheCounterHelper | 4 | extend CacheCounterHelper |
app/models/image.rb
app/models/input.rb
app/models/license.rb
app/models/mailing_sent.rb
app/models/national_region.rb
app/models/national_region_type.rb
app/models/price_detail.rb
app/models/product.rb
app/models/product_qualifier.rb
app/models/production_cost.rb
app/models/profile.rb
1 | # A Profile is the representation and web-presence of an individual or an | 1 | # A Profile is the representation and web-presence of an individual or an |
2 | # organization. Every Profile is attached to its Environment of origin, | 2 | # organization. Every Profile is attached to its Environment of origin, |
3 | # which by default is the one returned by Environment:default. | 3 | # which by default is the one returned by Environment:default. |
4 | -class Profile < ActiveRecord::Base | 4 | +class Profile < ApplicationRecord |
5 | 5 | ||
6 | # use for internationalizable human type names in search facets | 6 | # use for internationalizable human type names in search facets |
7 | # reimplement on subclasses | 7 | # reimplement on subclasses |
app/models/profile_activity.rb
app/models/profile_categorization.rb
app/models/profile_suggestion.rb
1 | -class ProfileSuggestion < ActiveRecord::Base | 1 | +class ProfileSuggestion < ApplicationRecord |
2 | 2 | ||
3 | belongs_to :person | 3 | belongs_to :person |
4 | belongs_to :suggestion, :class_name => 'Profile', :foreign_key => :suggestion_id | 4 | belongs_to :suggestion, :class_name => 'Profile', :foreign_key => :suggestion_id |
app/models/qualifier.rb
app/models/qualifier_certifier.rb
app/models/reported_image.rb
app/models/scrap.rb
app/models/search_term.rb
1 | -class SearchTerm < ActiveRecord::Base | 1 | +class SearchTerm < ApplicationRecord |
2 | validates_presence_of :term, :context | 2 | validates_presence_of :term, :context |
3 | validates_uniqueness_of :term, :scope => [:context_id, :context_type, :asset] | 3 | validates_uniqueness_of :term, :scope => [:context_id, :context_type, :asset] |
4 | 4 |
app/models/search_term_occurrence.rb
app/models/suggestion_connection.rb
1 | -class SuggestionConnection < ActiveRecord::Base | 1 | +class SuggestionConnection < ApplicationRecord |
2 | 2 | ||
3 | belongs_to :suggestion, :class_name => 'ProfileSuggestion', :foreign_key => 'suggestion_id' | 3 | belongs_to :suggestion, :class_name => 'ProfileSuggestion', :foreign_key => 'suggestion_id' |
4 | belongs_to :connection, :polymorphic => true | 4 | belongs_to :connection, :polymorphic => true |
app/models/task.rb
@@ -9,7 +9,7 @@ | @@ -9,7 +9,7 @@ | ||
9 | # This class has a +data+ field of type <tt>text</tt>, where you can store any | 9 | # This class has a +data+ field of type <tt>text</tt>, where you can store any |
10 | # type of data (as serialized Ruby objects) you need for your subclass (which | 10 | # type of data (as serialized Ruby objects) you need for your subclass (which |
11 | # will need to declare <ttserialize</tt> itself). | 11 | # will need to declare <ttserialize</tt> itself). |
12 | -class Task < ActiveRecord::Base | 12 | +class Task < ApplicationRecord |
13 | 13 | ||
14 | acts_as_having_settings :field => :data | 14 | acts_as_having_settings :field => :data |
15 | 15 |
app/models/thumbnail.rb
1 | -class Thumbnail < ActiveRecord::Base | 1 | +class Thumbnail < ApplicationRecord |
2 | 2 | ||
3 | has_attachment :storage => :file_system, | 3 | has_attachment :storage => :file_system, |
4 | :content_type => :image, :max_size => UploadedFile.max_size, processor: 'Rmagick' | 4 | :content_type => :image, :max_size => UploadedFile.max_size, processor: 'Rmagick' |
app/models/unit.rb
app/models/user.rb
@@ -4,7 +4,7 @@ require 'securerandom' | @@ -4,7 +4,7 @@ require 'securerandom' | ||
4 | 4 | ||
5 | # User models the system users, and is generated by the acts_as_authenticated | 5 | # User models the system users, and is generated by the acts_as_authenticated |
6 | # Rails generator. | 6 | # Rails generator. |
7 | -class User < ActiveRecord::Base | 7 | +class User < ApplicationRecord |
8 | 8 | ||
9 | N_('Password') | 9 | N_('Password') |
10 | N_('Password confirmation') | 10 | N_('Password confirmation') |
app/models/validation_info.rb
db/migrate/059_add_birth_date_to_person.rb
@@ -29,7 +29,7 @@ class AddBirthDateToPerson < ActiveRecord::Migration | @@ -29,7 +29,7 @@ class AddBirthDateToPerson < ActiveRecord::Migration | ||
29 | end | 29 | end |
30 | end | 30 | end |
31 | 31 | ||
32 | - class Person < ActiveRecord::Base | 32 | + class Person < ApplicationRecord |
33 | self.table_name = 'profiles' | 33 | self.table_name = 'profiles' |
34 | serialize :data, Hash | 34 | serialize :data, Hash |
35 | end | 35 | end |
db/migrate/069_add_enviroment_id_to_role.rb
1 | -class Role < ActiveRecord::Base; end | ||
2 | -class RoleWithEnvironment < ActiveRecord::Base | 1 | +class Role < ApplicationRecord |
2 | +class RoleWithEnvironment < ApplicationRecord | ||
3 | self.table_name = 'roles' | 3 | self.table_name = 'roles' |
4 | belongs_to :environment | 4 | belongs_to :environment |
5 | end | 5 | end |
6 | -class RoleAssignment < ActiveRecord::Base | 6 | +class RoleAssignment < ApplicationRecord |
7 | belongs_to :accessor, :polymorphic => true | 7 | belongs_to :accessor, :polymorphic => true |
8 | belongs_to :resource, :polymorphic => true | 8 | belongs_to :resource, :polymorphic => true |
9 | end | 9 | end |
db/migrate/20110706171330_fix_misunderstood_script_filename.rb
@@ -2,7 +2,7 @@ | @@ -2,7 +2,7 @@ | ||
2 | # from the migration fall on a loop and breaks the migration. Both them are | 2 | # from the migration fall on a loop and breaks the migration. Both them are |
3 | # related to alias_method_chain, probably there is a problem with this kind of | 3 | # related to alias_method_chain, probably there is a problem with this kind of |
4 | # alias on the migration level. | 4 | # alias on the migration level. |
5 | -class Article < ActiveRecord::Base | 5 | +class Article < ApplicationRecord |
6 | def sanitize_tag_list | 6 | def sanitize_tag_list |
7 | end | 7 | end |
8 | end | 8 | end |
lib/noosfero/core_ext.rb
1 | require 'noosfero/core_ext/string' | 1 | require 'noosfero/core_ext/string' |
2 | require 'noosfero/core_ext/integer' | 2 | require 'noosfero/core_ext/integer' |
3 | -require 'noosfero/core_ext/active_record' | 3 | +require 'noosfero/core_ext/active_record/calculations' |
4 | require 'noosfero/core_ext/active_record/reflection' | 4 | require 'noosfero/core_ext/active_record/reflection' |
5 | 5 |
lib/noosfero/core_ext/active_record.rb
@@ -1,74 +0,0 @@ | @@ -1,74 +0,0 @@ | ||
1 | -require 'active_record' | ||
2 | - | ||
3 | -class ActiveRecord::Base | ||
4 | - | ||
5 | - def self.postgresql? | ||
6 | - ActiveRecord::Base.connection.adapter_name == 'PostgreSQL' | ||
7 | - end | ||
8 | - | ||
9 | - # an ActionView instance for rendering views on models | ||
10 | - def self.action_view | ||
11 | - @action_view ||= begin | ||
12 | - view_paths = ::ActionController::Base.view_paths | ||
13 | - action_view = ::ActionView::Base.new view_paths | ||
14 | - # for using Noosfero helpers inside render calls | ||
15 | - action_view.extend ::ApplicationHelper | ||
16 | - action_view | ||
17 | - end | ||
18 | - end | ||
19 | - | ||
20 | - # default value needed for the above ActionView | ||
21 | - def to_partial_path | ||
22 | - self.class.name.underscore | ||
23 | - end | ||
24 | - | ||
25 | - alias :meta_cache_key :cache_key | ||
26 | - def cache_key | ||
27 | - key = [Noosfero::VERSION, meta_cache_key] | ||
28 | - key.unshift(ActiveRecord::Base.connection.schema_search_path) if ActiveRecord::Base.postgresql? | ||
29 | - key.join('/') | ||
30 | - end | ||
31 | - | ||
32 | - def self.like_search(query, options={}) | ||
33 | - if defined?(self::SEARCHABLE_FIELDS) || options[:fields].present? | ||
34 | - fields_per_table = {} | ||
35 | - fields_per_table[table_name] = (options[:fields].present? ? options[:fields] : self::SEARCHABLE_FIELDS.keys.map(&:to_s)) & column_names | ||
36 | - | ||
37 | - if options[:joins].present? | ||
38 | - join_asset = options[:joins].to_s.classify.constantize | ||
39 | - if defined?(join_asset::SEARCHABLE_FIELDS) || options[:fields].present? | ||
40 | - fields_per_table[join_asset.table_name] = (options[:fields].present? ? options[:fields] : join_asset::SEARCHABLE_FIELDS.keys.map(&:to_s)) & join_asset.column_names | ||
41 | - end | ||
42 | - end | ||
43 | - | ||
44 | - query = query.downcase.strip | ||
45 | - fields_per_table.delete_if { |table,fields| fields.blank? } | ||
46 | - conditions = fields_per_table.map do |table,fields| | ||
47 | - fields.map do |field| | ||
48 | - "lower(#{table}.#{field}) LIKE '%#{query}%'" | ||
49 | - end.join(' OR ') | ||
50 | - end.join(' OR ') | ||
51 | - | ||
52 | - if options[:joins].present? | ||
53 | - joins(options[:joins]).where(conditions) | ||
54 | - else | ||
55 | - where(conditions) | ||
56 | - end | ||
57 | - | ||
58 | - else | ||
59 | - raise "No searchable fields defined for #{self.name}" | ||
60 | - end | ||
61 | - end | ||
62 | - | ||
63 | -end | ||
64 | - | ||
65 | -ActiveRecord::Calculations.class_eval do | ||
66 | - def count_with_distinct column_name=self.primary_key | ||
67 | - if column_name | ||
68 | - distinct.count_without_distinct column_name | ||
69 | - else | ||
70 | - count_without_distinct | ||
71 | - end | ||
72 | - end | ||
73 | - alias_method_chain :count, :distinct | ||
74 | -end |
@@ -0,0 +1,10 @@ | @@ -0,0 +1,10 @@ | ||
1 | +ActiveRecord::Calculations.class_eval do | ||
2 | + def count_with_distinct column_name=self.primary_key | ||
3 | + if column_name | ||
4 | + distinct.count_without_distinct column_name | ||
5 | + else | ||
6 | + count_without_distinct | ||
7 | + end | ||
8 | + end | ||
9 | + alias_method_chain :count, :distinct | ||
10 | +end |
plugins/analytics/models/analytics_plugin/page_view.rb
plugins/analytics/models/analytics_plugin/visit.rb
1 | -class AnalyticsPlugin::Visit < ActiveRecord::Base | 1 | +class AnalyticsPlugin::Visit < ApplicationRecord |
2 | 2 | ||
3 | belongs_to :profile | 3 | belongs_to :profile |
4 | has_many :page_views, class_name: 'AnalyticsPlugin::PageView', dependent: :destroy | 4 | has_many :page_views, class_name: 'AnalyticsPlugin::PageView', dependent: :destroy |
plugins/comment_classification/lib/comment_classification_plugin/comment_label_user.rb
1 | -class CommentClassificationPlugin::CommentLabelUser < ActiveRecord::Base | 1 | +class CommentClassificationPlugin::CommentLabelUser < ApplicationRecord |
2 | self.table_name = :comment_classification_plugin_comment_label_user | 2 | self.table_name = :comment_classification_plugin_comment_label_user |
3 | 3 | ||
4 | belongs_to :profile | 4 | belongs_to :profile |
plugins/comment_classification/lib/comment_classification_plugin/comment_status_user.rb
1 | -class CommentClassificationPlugin::CommentStatusUser < ActiveRecord::Base | 1 | +class CommentClassificationPlugin::CommentStatusUser < ApplicationRecord |
2 | self.table_name = :comment_classification_plugin_comment_status_user | 2 | self.table_name = :comment_classification_plugin_comment_status_user |
3 | 3 | ||
4 | belongs_to :profile | 4 | belongs_to :profile |
plugins/comment_classification/lib/comment_classification_plugin/label.rb
plugins/comment_classification/lib/comment_classification_plugin/status.rb
plugins/custom_forms/db/migrate/20130823151900_associate_fields_to_alternatives.rb
1 | class AssociateFieldsToAlternatives < ActiveRecord::Migration | 1 | class AssociateFieldsToAlternatives < ActiveRecord::Migration |
2 | - class CustomFormsPlugin::Field < ActiveRecord::Base | 2 | + class CustomFormsPlugin::Field < ApplicationRecord |
3 | self.table_name = :custom_forms_plugin_fields | 3 | self.table_name = :custom_forms_plugin_fields |
4 | has_many :alternatives, :class_name => 'CustomFormsPlugin::Alternative' | 4 | has_many :alternatives, :class_name => 'CustomFormsPlugin::Alternative' |
5 | serialize :choices, Hash | 5 | serialize :choices, Hash |
plugins/custom_forms/lib/custom_forms_plugin/alternative.rb
plugins/custom_forms/lib/custom_forms_plugin/answer.rb
1 | -class CustomFormsPlugin::Answer < ActiveRecord::Base | 1 | +class CustomFormsPlugin::Answer < ApplicationRecord |
2 | self.table_name = :custom_forms_plugin_answers | 2 | self.table_name = :custom_forms_plugin_answers |
3 | belongs_to :field, :class_name => 'CustomFormsPlugin::Field' | 3 | belongs_to :field, :class_name => 'CustomFormsPlugin::Field' |
4 | belongs_to :submission, :class_name => 'CustomFormsPlugin::Submission' | 4 | belongs_to :submission, :class_name => 'CustomFormsPlugin::Submission' |
plugins/custom_forms/lib/custom_forms_plugin/field.rb
plugins/custom_forms/lib/custom_forms_plugin/form.rb
plugins/custom_forms/lib/custom_forms_plugin/submission.rb
plugins/delivery/models/delivery_plugin/method.rb
plugins/delivery/models/delivery_plugin/option.rb
1 | -class DeliveryPlugin::Option < ActiveRecord::Base | 1 | +class DeliveryPlugin::Option < ApplicationRecord |
2 | 2 | ||
3 | belongs_to :delivery_method, :class_name => 'DeliveryPlugin::Method' | 3 | belongs_to :delivery_method, :class_name => 'DeliveryPlugin::Method' |
4 | belongs_to :owner, :polymorphic => true | 4 | belongs_to :owner, :polymorphic => true |
plugins/driven_signup/models/driven_signup_plugin/auth.rb
plugins/environment_notification/lib/environment_notifications_user.rb
plugins/environment_notification/models/environment_notification_plugin/environment_notification.rb
plugins/fb_app/models/fb_app_plugin/page_tab.rb
plugins/foo/lib/foo_plugin/bar.rb
plugins/lattes_curriculum/lib/academic_info.rb
plugins/mark_comment_as_read/lib/mark_comment_as_read_plugin/read_comments.rb
1 | -class MarkCommentAsReadPlugin::ReadComments < ActiveRecord::Base | 1 | +class MarkCommentAsReadPlugin::ReadComments < ApplicationRecord |
2 | self.table_name = 'mark_comment_as_read_plugin' | 2 | self.table_name = 'mark_comment_as_read_plugin' |
3 | belongs_to :comment | 3 | belongs_to :comment |
4 | belongs_to :person | 4 | belongs_to :person |
plugins/newsletter/lib/newsletter_plugin/newsletter.rb
plugins/oauth_client/models/oauth_client_plugin/auth.rb
1 | -class OauthClientPlugin::Auth < ActiveRecord::Base | 1 | +class OauthClientPlugin::Auth < ApplicationRecord |
2 | 2 | ||
3 | belongs_to :profile, class_name: 'Profile' | 3 | belongs_to :profile, class_name: 'Profile' |
4 | belongs_to :provider, class_name: 'OauthClientPlugin::Provider' | 4 | belongs_to :provider, class_name: 'OauthClientPlugin::Provider' |
plugins/oauth_client/models/oauth_client_plugin/provider.rb
plugins/open_graph/models/open_graph_plugin/track.rb
plugins/orders/models/orders_plugin/item.rb
plugins/orders/models/orders_plugin/order.rb
1 | -class OrdersPlugin::Order < ActiveRecord::Base | 1 | +class OrdersPlugin::Order < ApplicationRecord |
2 | 2 | ||
3 | # if abstract_class is true then it will trigger https://github.com/rails/rails/issues/20871 | 3 | # if abstract_class is true then it will trigger https://github.com/rails/rails/issues/20871 |
4 | #self.abstract_class = true | 4 | #self.abstract_class = true |
plugins/orders_cycle/models/orders_cycle_plugin/cycle.rb
1 | -class OrdersCyclePlugin::Cycle < ActiveRecord::Base | 1 | +class OrdersCyclePlugin::Cycle < ApplicationRecord |
2 | 2 | ||
3 | Statuses = %w[edition orders purchases receipts separation delivery closing] | 3 | Statuses = %w[edition orders purchases receipts separation delivery closing] |
4 | DbStatuses = %w[new] + Statuses | 4 | DbStatuses = %w[new] + Statuses |
plugins/orders_cycle/models/orders_cycle_plugin/cycle_order.rb
1 | -class OrdersCyclePlugin::CycleOrder < ActiveRecord::Base | 1 | +class OrdersCyclePlugin::CycleOrder < ApplicationRecord |
2 | 2 | ||
3 | belongs_to :cycle, class_name: 'OrdersCyclePlugin::Cycle' | 3 | belongs_to :cycle, class_name: 'OrdersCyclePlugin::Cycle' |
4 | belongs_to :sale, class_name: 'OrdersCyclePlugin::Sale', foreign_key: :sale_id, dependent: :destroy | 4 | belongs_to :sale, class_name: 'OrdersCyclePlugin::Sale', foreign_key: :sale_id, dependent: :destroy |
plugins/orders_cycle/models/orders_cycle_plugin/cycle_product.rb
plugins/organization_ratings/lib/organization_rating.rb
plugins/organization_ratings/lib/organization_ratings_config.rb
plugins/shopping_cart/db/migrate/20131226125124_move_shopping_cart_purchase_order_to_orders_plugin_order.rb
1 | OrdersPlugin.send :remove_const, :Item if defined? OrdersPlugin::Item | 1 | OrdersPlugin.send :remove_const, :Item if defined? OrdersPlugin::Item |
2 | OrdersPlugin.send :remove_const, :Order if defined? OrdersPlugin::Order | 2 | OrdersPlugin.send :remove_const, :Order if defined? OrdersPlugin::Order |
3 | 3 | ||
4 | -class ShoppingCartPlugin::PurchaseOrder < ActiveRecord::Base | 4 | +class ShoppingCartPlugin::PurchaseOrder < ApplicationRecord |
5 | acts_as_having_settings field: :data | 5 | acts_as_having_settings field: :data |
6 | 6 | ||
7 | module Status | 7 | module Status |
@@ -16,10 +16,10 @@ class Profile | @@ -16,10 +16,10 @@ class Profile | ||
16 | has_many :orders, class_name: 'OrdersPlugin::Order' | 16 | has_many :orders, class_name: 'OrdersPlugin::Order' |
17 | end | 17 | end |
18 | 18 | ||
19 | -class OrdersPlugin::Item < ActiveRecord::Base | 19 | +class OrdersPlugin::Item < ApplicationRecord |
20 | belongs_to :order, class_name: 'OrdersPlugin::Order' | 20 | belongs_to :order, class_name: 'OrdersPlugin::Order' |
21 | end | 21 | end |
22 | -class OrdersPlugin::Order < ActiveRecord::Base | 22 | +class OrdersPlugin::Order < ApplicationRecord |
23 | has_many :items, class_name: 'OrdersPlugin::Item', foreign_key: :order_id | 23 | has_many :items, class_name: 'OrdersPlugin::Item', foreign_key: :order_id |
24 | 24 | ||
25 | extend CodeNumbering::ClassMethods | 25 | extend CodeNumbering::ClassMethods |
plugins/solr/test/unit/acts_as_faceted_test.rb
@@ -2,11 +2,11 @@ require_relative '../test_helper' | @@ -2,11 +2,11 @@ require_relative '../test_helper' | ||
2 | require "#{File.dirname(__FILE__)}/../../lib/acts_as_faceted" | 2 | require "#{File.dirname(__FILE__)}/../../lib/acts_as_faceted" |
3 | 3 | ||
4 | 4 | ||
5 | -class TestModel < ActiveRecord::Base | 5 | +class TestModel < ApplicationRecord |
6 | def self.f_type_proc(klass) | 6 | def self.f_type_proc(klass) |
7 | - klass.constantize | 7 | + klass.constantize |
8 | h = { | 8 | h = { |
9 | - 'UploadedFile' => "Uploaded File", | 9 | + 'UploadedFile' => "Uploaded File", |
10 | 'TextArticle' => "Text", | 10 | 'TextArticle' => "Text", |
11 | 'Folder' => "Folder", | 11 | 'Folder' => "Folder", |
12 | 'Event' => "Event", | 12 | 'Event' => "Event", |
@@ -92,7 +92,7 @@ class ActsAsFacetedTest < ActiveSupport::TestCase | @@ -92,7 +92,7 @@ class ActsAsFacetedTest < ActiveSupport::TestCase | ||
92 | assert_equivalent [["[* TO NOW-1YEARS/DAY]", "Older than one year", 10], ["[NOW-1YEARS TO NOW/DAY]", "Last year", 19]], r | 92 | assert_equivalent [["[* TO NOW-1YEARS/DAY]", "Older than one year", 10], ["[NOW-1YEARS TO NOW/DAY]", "Last year", 19]], r |
93 | end | 93 | end |
94 | 94 | ||
95 | - should 'return facet hash in map_facets_for' do | 95 | + should 'return facet hash in map_facets_for' do |
96 | r = TestModel.map_facets_for(Environment.default) | 96 | r = TestModel.map_facets_for(Environment.default) |
97 | assert r.count, 2 | 97 | assert r.count, 2 |
98 | 98 | ||
@@ -147,7 +147,7 @@ class ActsAsFacetedTest < ActiveSupport::TestCase | @@ -147,7 +147,7 @@ class ActsAsFacetedTest < ActiveSupport::TestCase | ||
147 | facets = TestModel.map_facets_for(Environment.default) | 147 | facets = TestModel.map_facets_for(Environment.default) |
148 | facet = facets.select{ |f| f[:id] == 'f_type' }.first | 148 | facet = facets.select{ |f| f[:id] == 'f_type' }.first |
149 | facet_data = TestModel.map_facet_results facet, @facet_params, @facets, @all_facets, {} | 149 | facet_data = TestModel.map_facet_results facet, @facet_params, @facets, @all_facets, {} |
150 | - sorted = TestModel.facet_result_sort(facet, facet_data, :alphabetically) | 150 | + sorted = TestModel.facet_result_sort(facet, facet_data, :alphabetically) |
151 | assert_equal sorted, | 151 | assert_equal sorted, |
152 | [["Folder", "Folder", 3], ["Gallery", "Gallery", 1], ["TextArticle", 'Text', 15], ["UploadedFile", "Uploaded File", 6]] | 152 | [["Folder", "Folder", 3], ["Gallery", "Gallery", 1], ["TextArticle", 'Text', 15], ["UploadedFile", "Uploaded File", 6]] |
153 | end | 153 | end |
@@ -156,7 +156,7 @@ class ActsAsFacetedTest < ActiveSupport::TestCase | @@ -156,7 +156,7 @@ class ActsAsFacetedTest < ActiveSupport::TestCase | ||
156 | facets = TestModel.map_facets_for(Environment.default) | 156 | facets = TestModel.map_facets_for(Environment.default) |
157 | facet = facets.select{ |f| f[:id] == 'f_type' }.first | 157 | facet = facets.select{ |f| f[:id] == 'f_type' }.first |
158 | facet_data = TestModel.map_facet_results facet, @facet_params, @facets, @all_facets, {} | 158 | facet_data = TestModel.map_facet_results facet, @facet_params, @facets, @all_facets, {} |
159 | - sorted = TestModel.facet_result_sort(facet, facet_data, :count) | 159 | + sorted = TestModel.facet_result_sort(facet, facet_data, :count) |
160 | assert_equal sorted, | 160 | assert_equal sorted, |
161 | [["TextArticle", "Text", 15], ["UploadedFile", "Uploaded File", 6], ["Folder", "Folder", 3], ["Gallery", "Gallery", 1]] | 161 | [["TextArticle", "Text", 15], ["UploadedFile", "Uploaded File", 6], ["Folder", "Folder", 3], ["Gallery", "Gallery", 1]] |
162 | end | 162 | end |
plugins/solr/vendor/plugins/acts_as_solr_reloaded/lib/acts_as_solr/dynamic_attribute.rb
plugins/spaminator/lib/spaminator_plugin/report.rb
plugins/stoa/lib/stoa_plugin/usp_aluno_turma_grad.rb
plugins/stoa/lib/stoa_plugin/usp_user.rb
plugins/sub_organizations/lib/sub_organizations_plugin/approve_paternity_relation.rb
plugins/sub_organizations/lib/sub_organizations_plugin/relation.rb
plugins/suppliers/db/migrate/20130902115916_add_active_to_suppliers_plugin_supplier.rb
plugins/suppliers/models/suppliers_plugin/source_product.rb
plugins/suppliers/models/suppliers_plugin/supplier.rb
1 | -class SuppliersPlugin::Supplier < ActiveRecord::Base | 1 | +class SuppliersPlugin::Supplier < ApplicationRecord |
2 | 2 | ||
3 | attr_accessor :distribute_products_on_create, :dont_destroy_dummy, :identifier_from_name | 3 | attr_accessor :distribute_products_on_create, :dont_destroy_dummy, :identifier_from_name |
4 | 4 |
plugins/tolerance_time/lib/tolerance_time_plugin/publication.rb
plugins/tolerance_time/lib/tolerance_time_plugin/tolerance.rb
plugins/volunteers/models/volunteers_plugin/assignment.rb
plugins/volunteers/models/volunteers_plugin/period.rb
test/mocks/test/environment.rb
1 | require File.expand_path(File.dirname(__FILE__) + "/../../../app/models/environment") | 1 | require File.expand_path(File.dirname(__FILE__) + "/../../../app/models/environment") |
2 | 2 | ||
3 | -class Environment < ActiveRecord::Base | 3 | +class Environment < ApplicationRecord |
4 | def self.available_features | 4 | def self.available_features |
5 | { | 5 | { |
6 | 'feature1' => 'Enable Feature 1', | 6 | 'feature1' => 'Enable Feature 1', |