ar-orderable 1.0.1 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.1
1
+ 1.0.2
data/ar-orderable.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{ar-orderable}
8
- s.version = "1.0.1"
8
+ s.version = "1.0.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Gatis Tomsons", "IT House"]
@@ -27,7 +27,6 @@ Gem::Specification.new do |s|
27
27
  "ar-orderable.gemspec",
28
28
  "lib/ar-orderable.rb",
29
29
  "spec/ar-orderable_spec.rb",
30
- "spec/ar_orderable_spec.rb",
31
30
  "spec/spec.opts",
32
31
  "spec/spec_helper.rb"
33
32
  ]
data/spec/spec_helper.rb CHANGED
@@ -1,13 +1,19 @@
1
- require "rubygems"
2
- require "bundler/setup"
1
+ require 'rubygems'
2
+ require 'bundler'
3
+ begin
4
+ Bundler.setup(:default, :development)
5
+ rescue Bundler::BundlerError => e
6
+ $stderr.puts e.message
7
+ $stderr.puts "Run `bundle install` to install missing gems"
8
+ exit e.status_code
9
+ end
3
10
 
4
11
  require 'rails'
5
12
  require 'active_record'
6
13
  require 'rspec'
7
14
  require 'logger'
8
15
  require 'ruby-debug'
9
-
10
- require File.dirname(__FILE__)+'/../init.rb'
16
+ require 'ar-orderable'
11
17
  ActiveRecord::Base.logger = Logger.new(File.open("#{File.dirname(__FILE__)}/database.log", 'w+'))
12
18
  ActiveRecord::Base.establish_connection({ :database => ":memory:", :adapter => 'sqlite3', :timeout => 500 })
13
19
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ar-orderable
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -15,7 +15,7 @@ default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: rails
18
- requirement: &82064910 !ruby/object:Gem::Requirement
18
+ requirement: &84282840 !ruby/object:Gem::Requirement
19
19
  none: false
20
20
  requirements:
21
21
  - - ! '>='
@@ -23,10 +23,10 @@ dependencies:
23
23
  version: 3.0.0
24
24
  type: :runtime
25
25
  prerelease: false
26
- version_requirements: *82064910
26
+ version_requirements: *84282840
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: sqlite3
29
- requirement: &82064670 !ruby/object:Gem::Requirement
29
+ requirement: &84282600 !ruby/object:Gem::Requirement
30
30
  none: false
31
31
  requirements:
32
32
  - - ~>
@@ -34,10 +34,10 @@ dependencies:
34
34
  version: 1.3.4
35
35
  type: :development
36
36
  prerelease: false
37
- version_requirements: *82064670
37
+ version_requirements: *84282600
38
38
  - !ruby/object:Gem::Dependency
39
39
  name: rspec
40
- requirement: &82064430 !ruby/object:Gem::Requirement
40
+ requirement: &84282360 !ruby/object:Gem::Requirement
41
41
  none: false
42
42
  requirements:
43
43
  - - ~>
@@ -45,10 +45,10 @@ dependencies:
45
45
  version: 2.6.0
46
46
  type: :development
47
47
  prerelease: false
48
- version_requirements: *82064430
48
+ version_requirements: *84282360
49
49
  - !ruby/object:Gem::Dependency
50
50
  name: ruby-debug19
51
- requirement: &82064190 !ruby/object:Gem::Requirement
51
+ requirement: &84282120 !ruby/object:Gem::Requirement
52
52
  none: false
53
53
  requirements:
54
54
  - - ~>
@@ -56,10 +56,10 @@ dependencies:
56
56
  version: 0.11.6
57
57
  type: :development
58
58
  prerelease: false
59
- version_requirements: *82064190
59
+ version_requirements: *84282120
60
60
  - !ruby/object:Gem::Dependency
61
61
  name: bundler
62
- requirement: &82063950 !ruby/object:Gem::Requirement
62
+ requirement: &84281880 !ruby/object:Gem::Requirement
63
63
  none: false
64
64
  requirements:
65
65
  - - ~>
@@ -67,10 +67,10 @@ dependencies:
67
67
  version: 1.0.0
68
68
  type: :development
69
69
  prerelease: false
70
- version_requirements: *82063950
70
+ version_requirements: *84281880
71
71
  - !ruby/object:Gem::Dependency
72
72
  name: jeweler
73
- requirement: &82063710 !ruby/object:Gem::Requirement
73
+ requirement: &84281640 !ruby/object:Gem::Requirement
74
74
  none: false
75
75
  requirements:
76
76
  - - ~>
@@ -78,10 +78,10 @@ dependencies:
78
78
  version: 1.6.4
79
79
  type: :development
80
80
  prerelease: false
81
- version_requirements: *82063710
81
+ version_requirements: *84281640
82
82
  - !ruby/object:Gem::Dependency
83
83
  name: rcov
84
- requirement: &82063470 !ruby/object:Gem::Requirement
84
+ requirement: &84281400 !ruby/object:Gem::Requirement
85
85
  none: false
86
86
  requirements:
87
87
  - - ! '>='
@@ -89,7 +89,7 @@ dependencies:
89
89
  version: '0'
90
90
  type: :development
91
91
  prerelease: false
92
- version_requirements: *82063470
92
+ version_requirements: *84281400
93
93
  description: You can order AR records and skip callbacks
94
94
  email: gatis@ithouse.cc
95
95
  executables: []
@@ -108,7 +108,6 @@ files:
108
108
  - ar-orderable.gemspec
109
109
  - lib/ar-orderable.rb
110
110
  - spec/ar-orderable_spec.rb
111
- - spec/ar_orderable_spec.rb
112
111
  - spec/spec.opts
113
112
  - spec/spec_helper.rb
114
113
  has_rdoc: true
@@ -127,7 +126,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
127
126
  version: '0'
128
127
  segments:
129
128
  - 0
130
- hash: -183352115
129
+ hash: -365549233
131
130
  required_rubygems_version: !ruby/object:Gem::Requirement
132
131
  none: false
133
132
  requirements:
@@ -1,130 +0,0 @@
1
- require File.dirname(__FILE__) + '/spec_helper'
2
-
3
- describe ActiveRecord::Orderable do
4
- it "should order simple categories correctly" do
5
- 5.times{|i| Category.create(:name => "Cat #{i+1}")}
6
- Category.count.should == 5
7
- Category.first.order_nr.should == 1
8
- Category.last.order_nr.should == 5
9
- c = Category.first
10
- c.update_attribute(:order_nr, 4)
11
- Category.find_by_name("Cat 1").order_nr.should == 4
12
- Category.first.name.should == "Cat 2"
13
- c = Category.first
14
- Category.find_by_name("Cat 4").move_to 1
15
- Category.find_by_name("Cat 4").order_nr.should == 1
16
- Category.find(c.id).order_nr.should == 2
17
- end
18
-
19
- it "should order categories correct by scope" do
20
- cat_types = [
21
- CatType.create(:name => "Type 1"),
22
- CatType.create(:name => "Type 2")
23
- ]
24
-
25
- 5.times{|i| Category.create(:name => "Cat #{i+1}", :cat_type => cat_types.first)}
26
- 5.times{|i| Category.create(:name => "Cat #{i+6}", :cat_type => cat_types.last)}
27
-
28
- Category.find_by_name("Cat 9").move_to 1
29
- Category.find_by_name("Cat 9").order_nr.should == 1
30
- Category.find_by_name("Cat 6").order_nr.should == 2
31
- Category.find_by_name("Cat 7").order_nr.should == 3
32
- Category.find_by_name("Cat 8").order_nr.should == 4
33
- Category.find_by_name("Cat 10").order_nr.should == 5
34
-
35
- Category.find_by_name("Cat 7").move_to 5
36
-
37
- Category.find_by_name("Cat 9").order_nr.should == 1
38
- Category.find_by_name("Cat 6").order_nr.should == 2
39
- Category.find_by_name("Cat 8").order_nr.should == 3
40
- Category.find_by_name("Cat 10").order_nr.should == 4
41
- Category.find_by_name("Cat 7").order_nr.should == 5
42
-
43
- Category.find_by_name("Cat 7").move_to 4
44
-
45
- Category.find_by_name("Cat 9").order_nr.should == 1
46
- Category.find_by_name("Cat 6").order_nr.should == 2
47
- Category.find_by_name("Cat 8").order_nr.should == 3
48
- Category.find_by_name("Cat 7").order_nr.should == 4
49
- Category.find_by_name("Cat 10").order_nr.should == 5
50
-
51
- Category.find_by_name("Cat 9").move_to 5
52
-
53
- Category.find_by_name("Cat 6").order_nr.should == 1
54
- Category.find_by_name("Cat 8").order_nr.should == 2
55
- Category.find_by_name("Cat 7").order_nr.should == 3
56
- Category.find_by_name("Cat 10").order_nr.should == 4
57
- Category.find_by_name("Cat 9").order_nr.should == 5
58
-
59
- Category.find_by_name("Cat 10").move_to 2
60
-
61
- Category.find_by_name("Cat 6").order_nr.should == 1
62
- Category.find_by_name("Cat 10").order_nr.should == 2
63
- Category.find_by_name("Cat 8").order_nr.should == 3
64
- Category.find_by_name("Cat 7").order_nr.should == 4
65
- Category.find_by_name("Cat 9").order_nr.should == 5
66
- end
67
-
68
- it "should create unordered list and order it with order_unordered method" do
69
- 1.upto(4){|i| Category.create(:name => "Cat #{i}")}
70
- cat = Category.create(:name => "Cat 0")
71
- Category.update_all("order_nr = NULL")
72
- Category.order_unordered
73
- cat.order_nr.should_not == 1
74
- cat.move_to 1
75
- cat.reload
76
- cat.order_nr.should == 1
77
- Category.find_by_name("Cat 4").order_nr.should == 5
78
- end
79
-
80
- it "should create scoped unordered list and order it with order_unordered method" do
81
- cat_types = [
82
- CatType.create(:name => "Type 1"),
83
- CatType.create(:name => "Type 2")
84
- ]
85
- 5.times{|i| Category.create(:name => "Cat #{i+1}", :cat_type => cat_types.first)}
86
- 5.times{|i| Category.create(:name => "Cat #{i+6}", :cat_type => cat_types.last)}
87
- Category.update_all("order_nr = NULL")
88
- Category.all.map(&:order_nr).should == [nil, nil, nil, nil, nil, nil, nil, nil, nil, nil]
89
- Category.order_unordered
90
- Category.all.map(&:order_nr).should == [1, 1, 2, 2, 3, 3, 4, 4, 5, 5]
91
- end
92
-
93
- it "should move_up" do
94
- 5.times{|i| Category.create(:name => "Cat #{i+1}")}
95
- c = Category.find_by_name("Cat 2")
96
- c.order_nr.should == 2
97
- c.move_up
98
- c.reload
99
- c.order_nr.should == 1
100
- c.move_up
101
- c.reload
102
- c.order_nr.should == 1
103
- end
104
-
105
- it "should move_down" do
106
- 5.times{|i| Category.create(:name => "Cat #{i+1}")}
107
- c = Category.find_by_name("Cat 2")
108
- c.order_nr.should == 2
109
- c.move_down
110
- c.reload
111
- c.order_nr.should == 3
112
- c.move_to(5)
113
- c.reload
114
- c.order_nr.should == 5
115
- c.move_down
116
- c.reload
117
- c.order_nr.should == 5
118
- end
119
-
120
- it "should skip_callbacks" do
121
- 5.times{|i| Category.create(:name => "Cat #{i+1}")}
122
- c = Category.find_by_name("Cat 2")
123
- c.background_task.should be_nil
124
- c.move_down
125
- c.background_task.should == :done
126
- c.background_task = nil
127
- c.move_up(:skip_callbacks => true)
128
- c.background_task.should be_nil
129
- end
130
- end