Commit 6d90b426 by Weston Ganger

added without_default_scope option

parent 90471cdb
...@@ -40,7 +40,8 @@ def setup! ...@@ -40,7 +40,8 @@ def setup!
'namespaced_paranoid_belongs_tos' => 'deleted_at DATETIME, paranoid_has_one_id INTEGER', 'namespaced_paranoid_belongs_tos' => 'deleted_at DATETIME, paranoid_has_one_id INTEGER',
'unparanoid_unique_models' => 'name VARCHAR(32), paranoid_with_unparanoids_id INTEGER', 'unparanoid_unique_models' => 'name VARCHAR(32), paranoid_with_unparanoids_id INTEGER',
'active_column_models' => 'deleted_at DATETIME, active BOOLEAN', 'active_column_models' => 'deleted_at DATETIME, active BOOLEAN',
'active_column_model_with_uniqueness_validations' => 'name VARCHAR(32), deleted_at DATETIME, active BOOLEAN' 'active_column_model_with_uniqueness_validations' => 'name VARCHAR(32), deleted_at DATETIME, active BOOLEAN',
'without_default_scope_models' => 'deleted_at DATETIME'
}.each do |table_name, columns_as_sql_string| }.each do |table_name, columns_as_sql_string|
ActiveRecord::Base.connection.execute "CREATE TABLE #{table_name} (id INTEGER NOT NULL PRIMARY KEY, #{columns_as_sql_string})" ActiveRecord::Base.connection.execute "CREATE TABLE #{table_name} (id INTEGER NOT NULL PRIMARY KEY, #{columns_as_sql_string})"
end end
...@@ -205,10 +206,11 @@ class ParanoiaTest < test_framework ...@@ -205,10 +206,11 @@ class ParanoiaTest < test_framework
end end
def test_without_default_scope_option def test_without_default_scope_option
model = WithoutDefaultScopeModel.create!(name: "A", deleted_at: Time.now) model = WithoutDefaultScopeModel.create
model.destroy
assert_equal 1, model.class.count assert_equal 1, model.class.count
assert_equal 1, model.class.only_deleted.count assert_equal 1, model.class.only_deleted.count
assert_equal 0, model.class.without_deleted.count assert_equal 0, model.class.where(deleted_at: nil).count
end end
def test_active_column_model def test_active_column_model
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment