acts_as_discontinued 0.0.1 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 242f8b4a2f75db5cada02025a0f8f1cac11cde98
4
+ data.tar.gz: 42f9af7ac6eded1f923a4a9e992c311e94c819d6
5
+ SHA512:
6
+ metadata.gz: dc895b792ea135e16f1f14672f26ba20738b787c3a3e574d5a825161ed99ea93a4340a891b32eeb66d62c08cb4cce003b4212ce86b144dd4f9e2355e14fe5b62
7
+ data.tar.gz: 74a4de8bfc8653e0e9d3a4b867b1ed9b6282fd74d16ab25b898b352e1ad089e72ac68b1d4c316bf82456b79fb988a33a79314a132eec6d91228ff7a320e3779a
data/.rbenv-version ADDED
@@ -0,0 +1 @@
1
+ 2.1.0
@@ -16,6 +16,7 @@ Gem::Specification.new do |gem|
16
16
  gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
17
17
  gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
18
  gem.require_paths = ["lib"]
19
- gem.add_dependency "activerecord", '>= 3.0.0'
19
+ gem.add_dependency "activerecord", '~> 4.0'
20
+ gem.add_dependency "rake"
20
21
  gem.add_development_dependency "sqlite3"
21
22
  end
@@ -7,16 +7,16 @@ module ActsAsDiscontinued
7
7
  def acts_as_discontinued(options = {})
8
8
  include InstanceMethods
9
9
  class_eval do
10
- scope :active, :conditions => {:discontinued_at => nil}
11
- scope :status, lambda { |*args|
12
- stat = args.first.to_s
13
- case stat
10
+ scope :active, -> { where discontinued_at: nil }
11
+ scope :inactive, -> { where.not discontinued_at: nil }
12
+ scope :status, -> stat {
13
+ case stat.to_s
14
14
  when 'active', ''
15
- {:conditions => {:discontinued_at => nil}}
15
+ active
16
16
  when 'inactive'
17
- {:conditions => "#{table_name}.discontinued_at is not null"}
17
+ inactive
18
18
  else
19
- {}
19
+ all
20
20
  end
21
21
  }
22
22
  end
@@ -1,3 +1,3 @@
1
1
  module ActsAsDiscontinued
2
- VERSION = "0.0.1"
2
+ VERSION = "0.1.0"
3
3
  end
@@ -1,4 +1,4 @@
1
- require 'test/unit'
1
+ require 'minitest/autorun'
2
2
  require 'active_record'
3
3
  require "#{File.dirname(__FILE__)}/../../lib/acts_as_discontinued"
4
4
 
@@ -32,14 +32,14 @@ class Product < ActiveRecord::Base
32
32
  belongs_to :category
33
33
  end
34
34
 
35
- class ActsAsDiscontinuedTest < Test::Unit::TestCase
35
+ class ActsAsDiscontinuedTest < Minitest::Test
36
36
  def test_should_set_discontinued_at_when_discontinued!
37
- assert_not_nil Product.create!.discontinue!.reload.discontinued_at
37
+ assert Product.create!.discontinue!.reload.discontinued_at != nil
38
38
  end
39
39
 
40
40
  def test_should_unset_discontinued_at_when_activate!
41
41
  p = Product.create! discontinued_at: Time.now
42
- assert_not_nil p.discontinued_at
42
+ assert p.discontinued_at != nil
43
43
  p.activate!
44
44
  assert_nil p.reload.discontinued_at
45
45
  end
@@ -58,7 +58,7 @@ class ActsAsDiscontinuedTest < Test::Unit::TestCase
58
58
  assert_equal 2, Product.status(:active).size
59
59
  assert_equal 2, Product.status(nil).size
60
60
  assert_equal 1, Product.status(:inactive).size
61
- assert_equal 1, Product.status(:inactive).find(:all, joins: :category).size
61
+ assert_equal 1, Product.status(:inactive).joins(:category).size
62
62
  end
63
63
 
64
64
  def test_scope_should_work_on_strings
metadata CHANGED
@@ -1,46 +1,55 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: acts_as_discontinued
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
5
- prerelease:
4
+ version: 0.1.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Emmanuel Nicolau
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2012-11-14 00:00:00.000000000 Z
11
+ date: 2014-07-27 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: activerecord
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ! '>='
17
+ - - "~>"
20
18
  - !ruby/object:Gem::Version
21
- version: 3.0.0
19
+ version: '4.0'
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ! '>='
24
+ - - "~>"
28
25
  - !ruby/object:Gem::Version
29
- version: 3.0.0
26
+ version: '4.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
30
41
  - !ruby/object:Gem::Dependency
31
42
  name: sqlite3
32
43
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
44
  requirements:
35
- - - ! '>='
45
+ - - ">="
36
46
  - !ruby/object:Gem::Version
37
47
  version: '0'
38
48
  type: :development
39
49
  prerelease: false
40
50
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
51
  requirements:
43
- - - ! '>='
52
+ - - ">="
44
53
  - !ruby/object:Gem::Version
45
54
  version: '0'
46
55
  description: Another paranoid gem
@@ -50,8 +59,8 @@ executables: []
50
59
  extensions: []
51
60
  extra_rdoc_files: []
52
61
  files:
53
- - .DS_Store
54
- - .gitignore
62
+ - ".gitignore"
63
+ - ".rbenv-version"
55
64
  - Gemfile
56
65
  - LICENSE.txt
57
66
  - README.md
@@ -60,38 +69,29 @@ files:
60
69
  - lib/acts_as_discontinued.rb
61
70
  - lib/acts_as_discontinued/acts_as_discontinued.rb
62
71
  - lib/acts_as_discontinued/version.rb
63
- - test/.DS_Store
64
72
  - test/acts_as_discontinued/acts_as_discontinued_test.rb
65
73
  homepage: ''
66
74
  licenses: []
75
+ metadata: {}
67
76
  post_install_message:
68
77
  rdoc_options: []
69
78
  require_paths:
70
79
  - lib
71
80
  required_ruby_version: !ruby/object:Gem::Requirement
72
- none: false
73
81
  requirements:
74
- - - ! '>='
82
+ - - ">="
75
83
  - !ruby/object:Gem::Version
76
84
  version: '0'
77
- segments:
78
- - 0
79
- hash: 2844659536037982857
80
85
  required_rubygems_version: !ruby/object:Gem::Requirement
81
- none: false
82
86
  requirements:
83
- - - ! '>='
87
+ - - ">="
84
88
  - !ruby/object:Gem::Version
85
89
  version: '0'
86
- segments:
87
- - 0
88
- hash: 2844659536037982857
89
90
  requirements: []
90
91
  rubyforge_project:
91
- rubygems_version: 1.8.23
92
+ rubygems_version: 2.2.0
92
93
  signing_key:
93
- specification_version: 3
94
+ specification_version: 4
94
95
  summary: Another paranoid gem
95
96
  test_files:
96
- - test/.DS_Store
97
97
  - test/acts_as_discontinued/acts_as_discontinued_test.rb
data/.DS_Store DELETED
Binary file
data/test/.DS_Store DELETED
Binary file