spec/spec_helper.rb in simple_slug-0.3.5 vs spec/spec_helper.rb in simple_slug-0.4.0
- old
+ new
@@ -1,48 +1,44 @@
+require 'sqlite3'
require 'active_record'
require 'i18n'
require 'active_support/core_ext'
require 'byebug'
require 'simple_slug'
-# just silence warning
I18n.enforce_available_locales = false
I18n.default_locale = :uk
-class RspecActiveModelBase
- include ActiveModel::Model
- include ActiveModel::AttributeMethods
- extend ActiveModel::Callbacks
+ActiveRecord::Base.establish_connection(
+ adapter: 'sqlite3',
+ database: ':memory:'
+)
- include SimpleSlug::ModelAddition
+# ActiveRecord::Base.logger = Logger.new(STDOUT)
- define_model_callbacks :validation, :save, :destroy
+RSpec.configure do |config|
+ config.before(:suite) do
+ ActiveRecord::Migration.verbose = false
- attr_accessor :id, :slug, :name, :created_at
- alias_method :slug_was, :slug
+ ActiveRecord::Schema.define do
+ create_table :rspec_active_record_bases, force: true do |t|
+ t.string :name
+ t.string :slug, limit: 191
+ t.string :slug_en, limit: 191
+ t.timestamps
+ end
- def self.create(attributes, *)
- record = new(attributes)
- record.save
- record
+ create_table :simple_slug_history_slugs, force: true do |t|
+ t.string :slug, null: false, limit: 191
+ t.string :locale, limit: 10
+ t.integer :sluggable_id, null: false
+ t.string :sluggable_type, limit: 50, null: false
+ t.timestamps
+ end
+ end
end
+end
- def save
- run_callbacks(:validation) { run_callbacks(:save) { } }
- end
- def destroy
- run_callbacks(:destroy) { @destroyed = true }
- end
-
- def persisted?
- true
- end
-
- def slug_changed?
- slug.present?
- end
-
- def destroyed?
- !!@destroyed
- end
-end
+class RspecActiveRecordBase < ActiveRecord::Base
+ include SimpleSlug::ModelAddition
+end
\ No newline at end of file