Commit 87f2fc55d9cb2645d362c8980f09bf0ad2dc97d2

Authored by Braulio Bhavamitra
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
1 1 require_dependency 'mailing_job'
2 2  
3   -class Mailing < ActiveRecord::Base
  3 +class Mailing < ApplicationRecord
4 4  
5 5 acts_as_having_settings :field => :data
6 6  
... ...
app/models/abuse_report.rb
1   -class AbuseReport < ActiveRecord::Base
  1 +class AbuseReport < ApplicationRecord
2 2  
3 3 belongs_to :reporter, :class_name => 'Person'
4 4 belongs_to :abuse_complaint
... ...
app/models/action_tracker_notification.rb
1   -class ActionTrackerNotification < ActiveRecord::Base
  1 +class ActionTrackerNotification < ApplicationRecord
2 2  
3 3 belongs_to :profile
4 4 belongs_to :action_tracker, :class_name => 'ActionTracker::Record', :foreign_key => 'action_tracker_id'
... ...
app/models/application_record.rb 0 → 100644
... ... @@ -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
1 1  
2   -class Article < ActiveRecord::Base
  2 +class Article < ApplicationRecord
3 3  
4 4 acts_as_having_image
5 5 include Noosfero::Plugin::HotSpot
... ...
app/models/article_categorization.rb
1   -class ArticleCategorization < ActiveRecord::Base
  1 +class ArticleCategorization < ApplicationRecord
2 2 self.table_name = :articles_categories
3 3  
4 4 belongs_to :article
... ...
app/models/block.rb
1   -class Block < ActiveRecord::Base
  1 +class Block < ApplicationRecord
2 2  
3 3 include ActionView::Helpers::TagHelper
4 4  
... ...
app/models/box.rb
1   -class Box < ActiveRecord::Base
  1 +class Box < ApplicationRecord
2 2  
3 3 acts_as_list scope: -> box { where owner_id: box.owner_id, owner_type: box.owner_type }
4 4  
... ...
app/models/category.rb
1   -class Category < ActiveRecord::Base
  1 +class Category < ApplicationRecord
2 2  
3 3 SEARCHABLE_FIELDS = {
4 4 :name => {:label => _('Name'), :weight => 10},
... ...
app/models/certifier.rb
1   -class Certifier < ActiveRecord::Base
  1 +class Certifier < ApplicationRecord
2 2  
3 3 SEARCHABLE_FIELDS = {
4 4 :name => {:label => _('Name'), :weight => 10},
... ...
app/models/chat_message.rb
1   -class ChatMessage < ActiveRecord::Base
  1 +class ChatMessage < ApplicationRecord
2 2  
3 3 belongs_to :to, :class_name => 'Profile'
4 4 belongs_to :from, :class_name => 'Profile'
... ...
app/models/comment.rb
1   -class Comment < ActiveRecord::Base
  1 +class Comment < ApplicationRecord
2 2  
3 3 SEARCHABLE_FIELDS = {
4 4 :title => {:label => _('Title'), :weight => 10},
... ...
app/models/contact_list.rb
1   -class ContactList < ActiveRecord::Base
  1 +class ContactList < ApplicationRecord
2 2  
3 3 serialize :list, Array
4 4  
... ...
app/models/custom_field.rb
1   -class CustomField < ActiveRecord::Base
  1 +class CustomField < ApplicationRecord
2 2  
3 3 serialize :customized_type
4 4 serialize :extras
... ...
app/models/custom_field_value.rb
1   -class CustomFieldValue < ActiveRecord::Base
  1 +class CustomFieldValue < ApplicationRecord
2 2  
3 3 belongs_to :custom_field
4 4 belongs_to :customized, :polymorphic => true
... ...
app/models/domain.rb
1 1 require 'noosfero/multi_tenancy'
2 2  
3   -class Domain < ActiveRecord::Base
  3 +class Domain < ApplicationRecord
4 4  
5 5 # relationships
6 6 ###############
... ...
app/models/environment.rb
1 1 # A Environment is like a website to be hosted in the platform. It may
2 2 # contain multiple Profile's and can be identified by several different
3 3 # domains.
4   -class Environment < ActiveRecord::Base
  4 +class Environment < ApplicationRecord
5 5  
6 6 has_many :users
7 7  
... ...
app/models/external_feed.rb
1   -class ExternalFeed < ActiveRecord::Base
  1 +class ExternalFeed < ApplicationRecord
2 2  
3 3 belongs_to :blog
4 4 validates_presence_of :blog_id
... ...
app/models/favorite_enterprise_person.rb
1   -class FavoriteEnterprisePerson < ActiveRecord::Base
  1 +class FavoriteEnterprisePerson < ApplicationRecord
2 2  
3 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 2 track_actions :new_friendship, :after_create, :keep_params => ["friend.name", "friend.url", "friend.profile_custom_icon"], :custom_user => :person
3 3  
4 4 extend CacheCounterHelper
... ...
app/models/image.rb
1   -class Image < ActiveRecord::Base
  1 +class Image < ApplicationRecord
2 2  
3 3 attr_accessor :remove_image
4 4  
... ...
app/models/input.rb
1   -class Input < ActiveRecord::Base
  1 +class Input < ApplicationRecord
2 2  
3 3 belongs_to :product
4 4 belongs_to :product_category
... ...
app/models/license.rb
1   -class License < ActiveRecord::Base
  1 +class License < ApplicationRecord
2 2  
3 3 SEARCHABLE_FIELDS = {
4 4 :name => {:label => _('Name'), :weight => 10},
... ...
app/models/mailing_sent.rb
1   -class MailingSent < ActiveRecord::Base
  1 +class MailingSent < ApplicationRecord
2 2  
3 3 belongs_to :mailing
4 4 belongs_to :person
... ...
app/models/national_region.rb
1   -class NationalRegion < ActiveRecord::Base
  1 +class NationalRegion < ApplicationRecord
2 2  
3 3 SEARCHABLE_FIELDS = {
4 4 :name => {:label => _('Name'), :weight => 1},
... ...
app/models/national_region_type.rb
1   -class NationalRegionType < ActiveRecord::Base
  1 +class NationalRegionType < ApplicationRecord
2 2 COUNTRY = 1
3 3 STATE = 2
4 4 CITY = 3
... ...
app/models/price_detail.rb
1   -class PriceDetail < ActiveRecord::Base
  1 +class PriceDetail < ApplicationRecord
2 2  
3 3 belongs_to :product
4 4 validates_presence_of :product_id
... ...
app/models/product.rb
1   -class Product < ActiveRecord::Base
  1 +class Product < ApplicationRecord
2 2  
3 3 SEARCHABLE_FIELDS = {
4 4 :name => {:label => _('Name'), :weight => 10},
... ...
app/models/product_qualifier.rb
1   -class ProductQualifier < ActiveRecord::Base
  1 +class ProductQualifier < ApplicationRecord
2 2  
3 3 belongs_to :qualifier
4 4 belongs_to :product
... ...
app/models/production_cost.rb
1   -class ProductionCost < ActiveRecord::Base
  1 +class ProductionCost < ApplicationRecord
2 2  
3 3 belongs_to :owner, :polymorphic => true
4 4  
... ...
app/models/profile.rb
1 1 # A Profile is the representation and web-presence of an individual or an
2 2 # organization. Every Profile is attached to its Environment of origin,
3 3 # which by default is the one returned by Environment:default.
4   -class Profile < ActiveRecord::Base
  4 +class Profile < ApplicationRecord
5 5  
6 6 # use for internationalizable human type names in search facets
7 7 # reimplement on subclasses
... ...
app/models/profile_activity.rb
1   -class ProfileActivity < ActiveRecord::Base
  1 +class ProfileActivity < ApplicationRecord
2 2  
3 3 self.record_timestamps = false
4 4  
... ...
app/models/profile_categorization.rb
1   -class ProfileCategorization < ActiveRecord::Base
  1 +class ProfileCategorization < ApplicationRecord
2 2 self.table_name = :categories_profiles
3 3 belongs_to :profile
4 4 belongs_to :category
... ...
app/models/profile_suggestion.rb
1   -class ProfileSuggestion < ActiveRecord::Base
  1 +class ProfileSuggestion < ApplicationRecord
2 2  
3 3 belongs_to :person
4 4 belongs_to :suggestion, :class_name => 'Profile', :foreign_key => :suggestion_id
... ...
app/models/qualifier.rb
1   -class Qualifier < ActiveRecord::Base
  1 +class Qualifier < ApplicationRecord
2 2  
3 3 SEARCHABLE_FIELDS = {
4 4 :name => {:label => _('Name'), :weight => 1},
... ...
app/models/qualifier_certifier.rb
1   -class QualifierCertifier < ActiveRecord::Base
  1 +class QualifierCertifier < ApplicationRecord
2 2 belongs_to :qualifier
3 3 belongs_to :certifier
4 4  
... ...
app/models/reported_image.rb
1   -class ReportedImage < ActiveRecord::Base
  1 +class ReportedImage < ApplicationRecord
2 2 belongs_to :abuse_report
3 3  
4 4 validates_presence_of :abuse_report
... ...
app/models/scrap.rb
1   -class Scrap < ActiveRecord::Base
  1 +class Scrap < ApplicationRecord
2 2  
3 3 SEARCHABLE_FIELDS = {
4 4 :content => {:label => _('Content'), :weight => 1},
... ...
app/models/search_term.rb
1   -class SearchTerm < ActiveRecord::Base
  1 +class SearchTerm < ApplicationRecord
2 2 validates_presence_of :term, :context
3 3 validates_uniqueness_of :term, :scope => [:context_id, :context_type, :asset]
4 4  
... ...
app/models/search_term_occurrence.rb
1   -class SearchTermOccurrence < ActiveRecord::Base
  1 +class SearchTermOccurrence < ApplicationRecord
2 2  
3 3 belongs_to :search_term
4 4 validates_presence_of :search_term
... ...
app/models/suggestion_connection.rb
1   -class SuggestionConnection < ActiveRecord::Base
  1 +class SuggestionConnection < ApplicationRecord
2 2  
3 3 belongs_to :suggestion, :class_name => 'ProfileSuggestion', :foreign_key => 'suggestion_id'
4 4 belongs_to :connection, :polymorphic => true
... ...
app/models/task.rb
... ... @@ -9,7 +9,7 @@
9 9 # This class has a +data+ field of type <tt>text</tt>, where you can store any
10 10 # type of data (as serialized Ruby objects) you need for your subclass (which
11 11 # will need to declare <ttserialize</tt> itself).
12   -class Task < ActiveRecord::Base
  12 +class Task < ApplicationRecord
13 13  
14 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 3 has_attachment :storage => :file_system,
4 4 :content_type => :image, :max_size => UploadedFile.max_size, processor: 'Rmagick'
... ...
app/models/unit.rb
1   -class Unit < ActiveRecord::Base
  1 +class Unit < ApplicationRecord
2 2  
3 3 acts_as_list scope: -> unit { where environment_id: unit.environment_id }
4 4  
... ...
app/models/user.rb
... ... @@ -4,7 +4,7 @@ require &#39;securerandom&#39;
4 4  
5 5 # User models the system users, and is generated by the acts_as_authenticated
6 6 # Rails generator.
7   -class User < ActiveRecord::Base
  7 +class User < ApplicationRecord
8 8  
9 9 N_('Password')
10 10 N_('Password confirmation')
... ...
app/models/validation_info.rb
1   -class ValidationInfo < ActiveRecord::Base
  1 +class ValidationInfo < ApplicationRecord
2 2  
3 3 belongs_to :organization
4 4  
... ...
db/migrate/059_add_birth_date_to_person.rb
... ... @@ -29,7 +29,7 @@ class AddBirthDateToPerson &lt; ActiveRecord::Migration
29 29 end
30 30 end
31 31  
32   - class Person < ActiveRecord::Base
  32 + class Person < ApplicationRecord
33 33 self.table_name = 'profiles'
34 34 serialize :data, Hash
35 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 3 self.table_name = 'roles'
4 4 belongs_to :environment
5 5 end
6   -class RoleAssignment < ActiveRecord::Base
  6 +class RoleAssignment < ApplicationRecord
7 7 belongs_to :accessor, :polymorphic => true
8 8 belongs_to :resource, :polymorphic => true
9 9 end
... ...
db/migrate/20110706171330_fix_misunderstood_script_filename.rb
... ... @@ -2,7 +2,7 @@
2 2 # from the migration fall on a loop and breaks the migration. Both them are
3 3 # related to alias_method_chain, probably there is a problem with this kind of
4 4 # alias on the migration level.
5   -class Article < ActiveRecord::Base
  5 +class Article < ApplicationRecord
6 6 def sanitize_tag_list
7 7 end
8 8 end
... ...
lib/noosfero/core_ext.rb
1 1 require 'noosfero/core_ext/string'
2 2 require 'noosfero/core_ext/integer'
3   -require 'noosfero/core_ext/active_record'
  3 +require 'noosfero/core_ext/active_record/calculations'
4 4 require 'noosfero/core_ext/active_record/reflection'
5 5  
... ...
lib/noosfero/core_ext/active_record.rb
... ... @@ -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
lib/noosfero/core_ext/active_record/calculations.rb 0 → 100644
... ... @@ -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
1   -class AnalyticsPlugin::PageView < ActiveRecord::Base
  1 +class AnalyticsPlugin::PageView < ApplicationRecord
2 2  
3 3 serialize :data
4 4  
... ...
plugins/analytics/models/analytics_plugin/visit.rb
1   -class AnalyticsPlugin::Visit < ActiveRecord::Base
  1 +class AnalyticsPlugin::Visit < ApplicationRecord
2 2  
3 3 belongs_to :profile
4 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 2 self.table_name = :comment_classification_plugin_comment_label_user
3 3  
4 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 2 self.table_name = :comment_classification_plugin_comment_status_user
3 3  
4 4 belongs_to :profile
... ...
plugins/comment_classification/lib/comment_classification_plugin/label.rb
1   -class CommentClassificationPlugin::Label < ActiveRecord::Base
  1 +class CommentClassificationPlugin::Label < ApplicationRecord
2 2  
3 3 belongs_to :owner, :polymorphic => true
4 4  
... ...
plugins/comment_classification/lib/comment_classification_plugin/status.rb
1   -class CommentClassificationPlugin::Status < ActiveRecord::Base
  1 +class CommentClassificationPlugin::Status < ApplicationRecord
2 2  
3 3 belongs_to :owner, :polymorphic => true
4 4  
... ...
plugins/custom_forms/db/migrate/20130823151900_associate_fields_to_alternatives.rb
1 1 class AssociateFieldsToAlternatives < ActiveRecord::Migration
2   - class CustomFormsPlugin::Field < ActiveRecord::Base
  2 + class CustomFormsPlugin::Field < ApplicationRecord
3 3 self.table_name = :custom_forms_plugin_fields
4 4 has_many :alternatives, :class_name => 'CustomFormsPlugin::Alternative'
5 5 serialize :choices, Hash
... ...
plugins/custom_forms/lib/custom_forms_plugin/alternative.rb
1   -class CustomFormsPlugin::Alternative < ActiveRecord::Base
  1 +class CustomFormsPlugin::Alternative < ApplicationRecord
2 2 self.table_name = :custom_forms_plugin_alternatives
3 3  
4 4 validates_presence_of :label
... ...
plugins/custom_forms/lib/custom_forms_plugin/answer.rb
1   -class CustomFormsPlugin::Answer < ActiveRecord::Base
  1 +class CustomFormsPlugin::Answer < ApplicationRecord
2 2 self.table_name = :custom_forms_plugin_answers
3 3 belongs_to :field, :class_name => 'CustomFormsPlugin::Field'
4 4 belongs_to :submission, :class_name => 'CustomFormsPlugin::Submission'
... ...
plugins/custom_forms/lib/custom_forms_plugin/field.rb
1   -class CustomFormsPlugin::Field < ActiveRecord::Base
  1 +class CustomFormsPlugin::Field < ApplicationRecord
2 2 self.table_name = :custom_forms_plugin_fields
3 3  
4 4 validates_presence_of :name
... ...
plugins/custom_forms/lib/custom_forms_plugin/form.rb
1   -class CustomFormsPlugin::Form < ActiveRecord::Base
  1 +class CustomFormsPlugin::Form < ApplicationRecord
2 2  
3 3 belongs_to :profile
4 4  
... ...
plugins/custom_forms/lib/custom_forms_plugin/submission.rb
1   -class CustomFormsPlugin::Submission < ActiveRecord::Base
  1 +class CustomFormsPlugin::Submission < ApplicationRecord
2 2  
3 3 belongs_to :form, :class_name => 'CustomFormsPlugin::Form'
4 4 belongs_to :profile
... ...
plugins/delivery/models/delivery_plugin/method.rb
1   -class DeliveryPlugin::Method < ActiveRecord::Base
  1 +class DeliveryPlugin::Method < ApplicationRecord
2 2  
3 3 Types = ['pickup', 'deliver']
4 4  
... ...
plugins/delivery/models/delivery_plugin/option.rb
1   -class DeliveryPlugin::Option < ActiveRecord::Base
  1 +class DeliveryPlugin::Option < ApplicationRecord
2 2  
3 3 belongs_to :delivery_method, :class_name => 'DeliveryPlugin::Method'
4 4 belongs_to :owner, :polymorphic => true
... ...
plugins/driven_signup/models/driven_signup_plugin/auth.rb
1   -class DrivenSignupPlugin::Auth < ActiveRecord::Base
  1 +class DrivenSignupPlugin::Auth < ApplicationRecord
2 2  
3 3 belongs_to :environment
4 4  
... ...
plugins/environment_notification/lib/environment_notifications_user.rb
1   -class EnvironmentNotificationsUser < ActiveRecord::Base
  1 +class EnvironmentNotificationsUser < ApplicationRecord
2 2 self.table_name = "environment_notifications_users"
3 3  
4 4 belongs_to :user
... ...
plugins/environment_notification/models/environment_notification_plugin/environment_notification.rb
1   -class EnvironmentNotificationPlugin::EnvironmentNotification < ActiveRecord::Base
  1 +class EnvironmentNotificationPlugin::EnvironmentNotification < ApplicationRecord
2 2  
3 3 self.table_name = "environment_notifications"
4 4  
... ...
plugins/fb_app/models/fb_app_plugin/page_tab.rb
1   -class FbAppPlugin::PageTab < ActiveRecord::Base
  1 +class FbAppPlugin::PageTab < ApplicationRecord
2 2  
3 3 # FIXME: rename table to match model
4 4 self.table_name = :fb_app_plugin_page_tab_configs
... ...
plugins/foo/lib/foo_plugin/bar.rb
1   -class FooPlugin::Bar < ActiveRecord::Base
  1 +class FooPlugin::Bar < ApplicationRecord
2 2  
3 3 end
... ...
plugins/lattes_curriculum/lib/academic_info.rb
1   -class AcademicInfo < ActiveRecord::Base
  1 +class AcademicInfo < ApplicationRecord
2 2  
3 3 belongs_to :person
4 4  
... ...
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 2 self.table_name = 'mark_comment_as_read_plugin'
3 3 belongs_to :comment
4 4 belongs_to :person
... ...
plugins/newsletter/lib/newsletter_plugin/newsletter.rb
1 1 require 'csv'
2 2  
3   -class NewsletterPlugin::Newsletter < ActiveRecord::Base
  3 +class NewsletterPlugin::Newsletter < ApplicationRecord
4 4  
5 5 belongs_to :environment
6 6 belongs_to :person
... ...
plugins/oauth_client/models/oauth_client_plugin/auth.rb
1   -class OauthClientPlugin::Auth < ActiveRecord::Base
  1 +class OauthClientPlugin::Auth < ApplicationRecord
2 2  
3 3 belongs_to :profile, class_name: 'Profile'
4 4 belongs_to :provider, class_name: 'OauthClientPlugin::Provider'
... ...
plugins/oauth_client/models/oauth_client_plugin/provider.rb
1   -class OauthClientPlugin::Provider < ActiveRecord::Base
  1 +class OauthClientPlugin::Provider < ApplicationRecord
2 2  
3 3 belongs_to :environment
4 4  
... ...
plugins/open_graph/models/open_graph_plugin/track.rb
1   -class OpenGraphPlugin::Track < ActiveRecord::Base
  1 +class OpenGraphPlugin::Track < ApplicationRecord
2 2  
3 3 class_attribute :context
4 4 self.context = :open_graph
... ...
plugins/orders/models/orders_plugin/item.rb
1   -class OrdersPlugin::Item < ActiveRecord::Base
  1 +class OrdersPlugin::Item < ApplicationRecord
2 2  
3 3 # flag used by items to compare them with products
4 4 attr_accessor :product_diff
... ...
plugins/orders/models/orders_plugin/order.rb
1   -class OrdersPlugin::Order < ActiveRecord::Base
  1 +class OrdersPlugin::Order < ApplicationRecord
2 2  
3 3 # if abstract_class is true then it will trigger https://github.com/rails/rails/issues/20871
4 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 3 Statuses = %w[edition orders purchases receipts separation delivery closing]
4 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 3 belongs_to :cycle, class_name: 'OrdersCyclePlugin::Cycle'
4 4 belongs_to :sale, class_name: 'OrdersCyclePlugin::Sale', foreign_key: :sale_id, dependent: :destroy
... ...
plugins/orders_cycle/models/orders_cycle_plugin/cycle_product.rb
1   -class OrdersCyclePlugin::CycleProduct < ActiveRecord::Base
  1 +class OrdersCyclePlugin::CycleProduct < ApplicationRecord
2 2  
3 3 self.table_name = :orders_cycle_plugin_cycle_products
4 4  
... ...
plugins/organization_ratings/lib/organization_rating.rb
1   -class OrganizationRating < ActiveRecord::Base
  1 +class OrganizationRating < ApplicationRecord
2 2 belongs_to :person
3 3 belongs_to :organization
4 4 belongs_to :comment
... ...
plugins/organization_ratings/lib/organization_ratings_config.rb
1   -class OrganizationRatingsConfig < ActiveRecord::Base
  1 +class OrganizationRatingsConfig < ApplicationRecord
2 2  
3 3 belongs_to :environment
4 4  
... ...
plugins/shopping_cart/db/migrate/20131226125124_move_shopping_cart_purchase_order_to_orders_plugin_order.rb
1 1 OrdersPlugin.send :remove_const, :Item if defined? OrdersPlugin::Item
2 2 OrdersPlugin.send :remove_const, :Order if defined? OrdersPlugin::Order
3 3  
4   -class ShoppingCartPlugin::PurchaseOrder < ActiveRecord::Base
  4 +class ShoppingCartPlugin::PurchaseOrder < ApplicationRecord
5 5 acts_as_having_settings field: :data
6 6  
7 7 module Status
... ... @@ -16,10 +16,10 @@ class Profile
16 16 has_many :orders, class_name: 'OrdersPlugin::Order'
17 17 end
18 18  
19   -class OrdersPlugin::Item < ActiveRecord::Base
  19 +class OrdersPlugin::Item < ApplicationRecord
20 20 belongs_to :order, class_name: 'OrdersPlugin::Order'
21 21 end
22   -class OrdersPlugin::Order < ActiveRecord::Base
  22 +class OrdersPlugin::Order < ApplicationRecord
23 23 has_many :items, class_name: 'OrdersPlugin::Item', foreign_key: :order_id
24 24  
25 25 extend CodeNumbering::ClassMethods
... ...
plugins/solr/test/unit/acts_as_faceted_test.rb
... ... @@ -2,11 +2,11 @@ require_relative &#39;../test_helper&#39;
2 2 require "#{File.dirname(__FILE__)}/../../lib/acts_as_faceted"
3 3  
4 4  
5   -class TestModel < ActiveRecord::Base
  5 +class TestModel < ApplicationRecord
6 6 def self.f_type_proc(klass)
7   - klass.constantize
  7 + klass.constantize
8 8 h = {
9   - 'UploadedFile' => "Uploaded File",
  9 + 'UploadedFile' => "Uploaded File",
10 10 'TextArticle' => "Text",
11 11 'Folder' => "Folder",
12 12 'Event' => "Event",
... ... @@ -92,7 +92,7 @@ class ActsAsFacetedTest &lt; ActiveSupport::TestCase
92 92 assert_equivalent [["[* TO NOW-1YEARS/DAY]", "Older than one year", 10], ["[NOW-1YEARS TO NOW/DAY]", "Last year", 19]], r
93 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 96 r = TestModel.map_facets_for(Environment.default)
97 97 assert r.count, 2
98 98  
... ... @@ -147,7 +147,7 @@ class ActsAsFacetedTest &lt; ActiveSupport::TestCase
147 147 facets = TestModel.map_facets_for(Environment.default)
148 148 facet = facets.select{ |f| f[:id] == 'f_type' }.first
149 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 151 assert_equal sorted,
152 152 [["Folder", "Folder", 3], ["Gallery", "Gallery", 1], ["TextArticle", 'Text', 15], ["UploadedFile", "Uploaded File", 6]]
153 153 end
... ... @@ -156,7 +156,7 @@ class ActsAsFacetedTest &lt; ActiveSupport::TestCase
156 156 facets = TestModel.map_facets_for(Environment.default)
157 157 facet = facets.select{ |f| f[:id] == 'f_type' }.first
158 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 160 assert_equal sorted,
161 161 [["TextArticle", "Text", 15], ["UploadedFile", "Uploaded File", 6], ["Folder", "Folder", 3], ["Gallery", "Gallery", 1]]
162 162 end
... ...
plugins/solr/vendor/plugins/acts_as_solr_reloaded/lib/acts_as_solr/dynamic_attribute.rb
1   -class DynamicAttribute < ActiveRecord::Base
  1 +class DynamicAttribute < ApplicationRecord
2 2 belongs_to :dynamicable, :polymorphic => true
3 3 end
... ...
plugins/spaminator/lib/spaminator_plugin/report.rb
1   -class SpaminatorPlugin::Report < ActiveRecord::Base
  1 +class SpaminatorPlugin::Report < ApplicationRecord
2 2  
3 3 serialize :failed, Hash
4 4  
... ...
plugins/stoa/lib/stoa_plugin/usp_aluno_turma_grad.rb
1   -class StoaPlugin::UspAlunoTurmaGrad < ActiveRecord::Base
  1 +class StoaPlugin::UspAlunoTurmaGrad < ApplicationRecord
2 2  
3 3 establish_connection(:stoa)
4 4  
... ...
plugins/stoa/lib/stoa_plugin/usp_user.rb
1   -class StoaPlugin::UspUser < ActiveRecord::Base
  1 +class StoaPlugin::UspUser < ApplicationRecord
2 2  
3 3 establish_connection(:stoa)
4 4 self.table_name = 'pessoa'
... ...
plugins/sub_organizations/lib/sub_organizations_plugin/approve_paternity_relation.rb
1   -class SubOrganizationsPlugin::ApprovePaternityRelation < ActiveRecord::Base
  1 +class SubOrganizationsPlugin::ApprovePaternityRelation < ApplicationRecord
2 2  
3 3 belongs_to :task
4 4 belongs_to :parent, :polymorphic => true
... ...
plugins/sub_organizations/lib/sub_organizations_plugin/relation.rb
1   -class SubOrganizationsPlugin::Relation < ActiveRecord::Base
  1 +class SubOrganizationsPlugin::Relation < ApplicationRecord
2 2  
3 3 belongs_to :parent, :polymorphic => true
4 4 belongs_to :child, :polymorphic => true
... ...
plugins/suppliers/db/migrate/20130902115916_add_active_to_suppliers_plugin_supplier.rb
1   -class SuppliersPlugin::Supplier < ActiveRecord::Base
  1 +class SuppliersPlugin::Supplier < ApplicationRecord
2 2 end
3 3  
4 4 class AddActiveToSuppliersPluginSupplier < ActiveRecord::Migration
... ...
plugins/suppliers/models/suppliers_plugin/source_product.rb
1   -class SuppliersPlugin::SourceProduct < ActiveRecord::Base
  1 +class SuppliersPlugin::SourceProduct < ApplicationRecord
2 2  
3 3 default_scope -> { includes :from_product, :to_product }
4 4  
... ...
plugins/suppliers/models/suppliers_plugin/supplier.rb
1   -class SuppliersPlugin::Supplier < ActiveRecord::Base
  1 +class SuppliersPlugin::Supplier < ApplicationRecord
2 2  
3 3 attr_accessor :distribute_products_on_create, :dont_destroy_dummy, :identifier_from_name
4 4  
... ...
plugins/tolerance_time/lib/tolerance_time_plugin/publication.rb
1   -class ToleranceTimePlugin::Publication < ActiveRecord::Base
  1 +class ToleranceTimePlugin::Publication < ApplicationRecord
2 2  
3 3 belongs_to :target, :polymorphic => true
4 4  
... ...
plugins/tolerance_time/lib/tolerance_time_plugin/tolerance.rb
1   -class ToleranceTimePlugin::Tolerance < ActiveRecord::Base
  1 +class ToleranceTimePlugin::Tolerance < ApplicationRecord
2 2  
3 3 belongs_to :profile
4 4  
... ...
plugins/volunteers/models/volunteers_plugin/assignment.rb
1   -class VolunteersPlugin::Assignment < ActiveRecord::Base
  1 +class VolunteersPlugin::Assignment < ApplicationRecord
2 2  
3 3 belongs_to :profile
4 4 belongs_to :period, class_name: 'VolunteersPlugin::Period'
... ...
plugins/volunteers/models/volunteers_plugin/period.rb
1   -class VolunteersPlugin::Period < ActiveRecord::Base
  1 +class VolunteersPlugin::Period < ApplicationRecord
2 2  
3 3 belongs_to :owner, polymorphic: true
4 4  
... ...
test/mocks/test/environment.rb
1 1 require File.expand_path(File.dirname(__FILE__) + "/../../../app/models/environment")
2 2  
3   -class Environment < ActiveRecord::Base
  3 +class Environment < ApplicationRecord
4 4 def self.available_features
5 5 {
6 6 'feature1' => 'Enable Feature 1',
... ...