spec: fix

main
Washington Botelho 2019-10-03 20:06:47 -03:00
parent 63a0f7e83b
commit 4fc253ccc2
No known key found for this signature in database
GPG Key ID: 5DE4F42A8F073617
4 changed files with 45 additions and 8 deletions

View File

@ -4,7 +4,5 @@ class AddExtraScopesOnRatingRatesTable < ActiveRecord::Migration[5.0]
def change def change
add_column :rating_rates, :scope_1, :string add_column :rating_rates, :scope_1, :string
add_column :rating_rates, :scope_2, :string add_column :rating_rates, :scope_2, :string
# remove_index :rating_rates, %i[author_id author_type resource_id resource_type scopeable_id scopeable_type]
end end
end end

View File

@ -0,0 +1,19 @@
# frozen_string_literal: true
class CreateRateTable < ActiveRecord::Migration[5.0]
def change
create_table :rating_rates do |t|
t.decimal :value, default: 0, precision: 25, scale: 16
t.references :author, index: true, null: false, polymorphic: true
t.references :resource, index: true, null: false, polymorphic: true
t.references :scopeable, index: true, null: true, polymorphic: true
t.timestamps null: false
end
change_column :rating_rates, :author_type, :string, limit: 10
change_column :rating_rates, :resource_type, :string, limit: 10
change_column :rating_rates, :scopeable_type, :string, limit: 10
end
end

View File

@ -0,0 +1,20 @@
# frozen_string_literal: true
class CreateRatingTable < ActiveRecord::Migration[5.0]
def change
create_table :rating_ratings do |t|
t.decimal :average, default: 0, mull: false, precision: 25, scale: 16
t.decimal :estimate, default: 0, mull: false, precision: 25, scale: 16
t.integer :sum, default: 0, mull: false
t.integer :total, default: 0, mull: false
t.references :resource, index: true, null: false, polymorphic: true
t.references :scopeable, index: true, null: true, polymorphic: true
t.timestamps null: false
end
change_column :rating_ratings, :resource_type, :string, limit: 10
change_column :rating_ratings, :scopeable_type, :string, limit: 10
end
end

View File

@ -1,10 +1,10 @@
# frozen_string_literal: true # frozen_string_literal: true
require File.expand_path('../../lib/generators/rating/templates/db/migrate/create_rating_table.rb', __dir__)
require File.expand_path('../../lib/generators/rating/templates/db/migrate/create_rate_table.rb', __dir__)
Dir[File.expand_path('db/migrate/*.rb', __dir__)].each { |file| require file } Dir[File.expand_path('db/migrate/*.rb', __dir__)].each { |file| require file }
CreateRateTable.new.change
CreateRatingTable.new.change
CreateArticlesTable.new.change CreateArticlesTable.new.change
CreateAuthorsTable.new.change CreateAuthorsTable.new.change
@ -12,9 +12,9 @@ CreateGlobalsTable.new.change
CreateCategoriesTable.new.change CreateCategoriesTable.new.change
CreateCommentsTable.new.change CreateCommentsTable.new.change
CreateRateTable.new.change
CreateRatingTable.new.change
CreateReviewRatingsTable.new.change CreateReviewRatingsTable.new.change
CreateReviewsTable.new.change CreateReviewsTable.new.change
AddCommentOnRatingRatesTable.new.change AddCommentOnRatingRatesTable.new.change
AddExtraScopesOnRatingRatesTable.new.change AddExtraScopesOnRatingRatesTable.new.change if ENV['CONFIG_ENABLED_WITH_EXTRA_SCOPES'] == 'true'