paranoia 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -1,2 +1,8 @@
1
1
  require 'bundler'
2
2
  Bundler::GemHelper.install_tasks
3
+
4
+ task :test do
5
+ Dir['test/*_test.rb'].each do |testfile|
6
+ load testfile
7
+ end
8
+ end
@@ -1,4 +1,12 @@
1
1
  module Paranoia
2
+ def self.included(klazz)
3
+ klazz.extend Query
4
+ end
5
+
6
+ module Query
7
+ def paranoid? ; true ; end
8
+ end
9
+
2
10
  def destroy
3
11
  _run_destroy_callbacks
4
12
  self[:deleted_at] ||= Time.now
@@ -17,4 +25,7 @@ class ActiveRecord::Base
17
25
  self.send(:include, Paranoia)
18
26
  default_scope :conditions => { :deleted_at => nil }
19
27
  end
28
+
29
+ def self.paranoid? ; false ; end
30
+ def paranoid? ; self.class.paranoid? ; end
20
31
  end
@@ -1,3 +1,3 @@
1
1
  module Paranoia
2
- VERSION = "1.0.0"
2
+ VERSION = "1.0.1"
3
3
  end
@@ -0,0 +1,40 @@
1
+ require 'test/unit'
2
+ require 'active_record'
3
+ require 'lib/paranoia'
4
+
5
+ DB_FILE = 'tmp/test_db'
6
+
7
+ FileUtils.mkdir_p File.dirname(DB_FILE)
8
+ FileUtils.rm_f DB_FILE
9
+
10
+ ActiveRecord::Base.establish_connection :adapter => 'sqlite3', :database => DB_FILE
11
+ ActiveRecord::Base.connection.execute 'CREATE TABLE paranoid_models (id INTEGER NOT NULL PRIMARY KEY)'
12
+ ActiveRecord::Base.connection.execute 'CREATE TABLE plain_models (id INTEGER NOT NULL PRIMARY KEY)'
13
+
14
+ class ParanoiaTest < Test::Unit::TestCase
15
+ def test_plain_model_class_is_not_paranoid
16
+ assert_equal false, PlainModel.paranoid?
17
+ end
18
+
19
+ def test_paranoid_model_class_is_paranoid
20
+ assert_equal true, ParanoidModel.paranoid?
21
+ end
22
+
23
+ def test_plain_models_are_not_paranoid
24
+ assert_equal false, PlainModel.new.paranoid?
25
+ end
26
+
27
+ def test_paranoid_models_are_paranoid
28
+ assert_equal true, ParanoidModel.new.paranoid?
29
+ end
30
+
31
+ end
32
+
33
+ # Helper classes
34
+
35
+ class ParanoidModel < ActiveRecord::Base
36
+ acts_as_paranoid
37
+ end
38
+
39
+ class PlainModel < ActiveRecord::Base
40
+ end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: paranoia
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 1.0.0
5
+ version: 1.0.1
6
6
  platform: ruby
7
7
  authors: []
8
8
 
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-04-06 00:00:00 +10:00
13
+ date: 2011-05-12 00:00:00 +10:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
@@ -52,6 +52,7 @@ files:
52
52
  - lib/paranoia.rb
53
53
  - lib/paranoia/version.rb
54
54
  - paranoia.gemspec
55
+ - test/paranoia_test.rb
55
56
  has_rdoc: true
56
57
  homepage: http://rubygems.org/gems/paranoia
57
58
  licenses: []
@@ -76,7 +77,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
76
77
  requirements: []
77
78
 
78
79
  rubyforge_project: paranoia
79
- rubygems_version: 1.5.2
80
+ rubygems_version: 1.6.2
80
81
  signing_key:
81
82
  specification_version: 3
82
83
  summary: acts_as_paranoid, without the clusterfuck