changeling 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +4 -11
- data/lib/changeling/models/logling.rb +1 -7
- data/lib/changeling/probeling.rb +2 -7
- data/lib/changeling/support/search.rb +3 -1
- data/lib/changeling/version.rb +1 -1
- data/spec/controllers/blameling_integration_spec.rb +4 -4
- data/spec/lib/changeling/models/logling_spec.rb +4 -4
- data/spec/lib/changeling/probeling_spec.rb +13 -11
- metadata +2 -2
data/README.md
CHANGED
@@ -79,7 +79,7 @@ When your object is saved, a job is placed in the 'changeling' queue.
|
|
79
79
|
class Post
|
80
80
|
# include Changeling::Trackling
|
81
81
|
include Changeling::Async::Trackling
|
82
|
-
|
82
|
+
|
83
83
|
# Model logic here...
|
84
84
|
end
|
85
85
|
```
|
@@ -111,14 +111,7 @@ You can access a different number of records by passing in a number to the .logl
|
|
111
111
|
@post.loglings(50)
|
112
112
|
```
|
113
113
|
|
114
|
-
Access
|
115
|
-
|
116
|
-
```ruby
|
117
|
-
# Alias for this method: @post.all_history
|
118
|
-
@post.all_loglings
|
119
|
-
```
|
120
|
-
|
121
|
-
Access all of an objects history where a specific field was changed:
|
114
|
+
Access an object's last 10 changes where a specific field was changed:
|
122
115
|
|
123
116
|
```ruby
|
124
117
|
# Alias for this method: @post.history_for_field(field)
|
@@ -126,8 +119,8 @@ Access all of an objects history where a specific field was changed:
|
|
126
119
|
# Or if you prefer stringified fields:
|
127
120
|
@post.loglings_for_field('title')
|
128
121
|
|
129
|
-
# You can also pass in a number to
|
130
|
-
@post.loglings_for_field(:title,
|
122
|
+
# You can also pass in a number to get more results
|
123
|
+
@post.loglings_for_field(:title, 50)
|
131
124
|
```
|
132
125
|
|
133
126
|
### Logling Properties (history objects):
|
@@ -59,13 +59,7 @@ module Changeling
|
|
59
59
|
:direction => :desc
|
60
60
|
}
|
61
61
|
|
62
|
-
results = Changeling::Support::Search.find_by(:filters => filters, :sort => sort)
|
63
|
-
|
64
|
-
if length
|
65
|
-
results.take(length)
|
66
|
-
else
|
67
|
-
results
|
68
|
-
end
|
62
|
+
results = Changeling::Support::Search.find_by(:filters => filters, :sort => sort, :size => length)
|
69
63
|
end
|
70
64
|
end
|
71
65
|
|
data/lib/changeling/probeling.rb
CHANGED
@@ -1,17 +1,12 @@
|
|
1
1
|
module Changeling
|
2
2
|
module Probeling
|
3
|
-
def all_loglings
|
4
|
-
Changeling::Models::Logling.records_for(self)
|
5
|
-
end
|
6
|
-
alias_method :all_history, :all_loglings
|
7
|
-
|
8
3
|
def loglings(records = 10)
|
9
4
|
Changeling::Models::Logling.records_for(self, records.to_i)
|
10
5
|
end
|
11
6
|
alias_method :history, :loglings
|
12
7
|
|
13
|
-
def loglings_for_field(field_name, records =
|
14
|
-
Changeling::Models::Logling.records_for(self, records
|
8
|
+
def loglings_for_field(field_name, records = 10)
|
9
|
+
Changeling::Models::Logling.records_for(self, records.to_i, field_name.to_s)
|
15
10
|
end
|
16
11
|
alias_method :history_for_field, :loglings_for_field
|
17
12
|
end
|
@@ -8,10 +8,12 @@ module Changeling
|
|
8
8
|
sort = args[:sort]
|
9
9
|
return [] unless filters || sort
|
10
10
|
|
11
|
+
size = args[:size] || 10
|
12
|
+
|
11
13
|
@class = Changeling::Models::Logling
|
12
14
|
@class.tire.index.refresh
|
13
15
|
|
14
|
-
results = @class.search do
|
16
|
+
results = @class.search :per_page => size do
|
15
17
|
query do
|
16
18
|
filtered do
|
17
19
|
query { all }
|
data/lib/changeling/version.rb
CHANGED
@@ -15,7 +15,7 @@ describe RailsApp, "Testing Blameling Integration" do
|
|
15
15
|
Thread.new {
|
16
16
|
post :create
|
17
17
|
# Look in application.rb for the User class and it's id method.
|
18
|
-
BlogPost.last.
|
18
|
+
BlogPost.last.loglings.first.modified_by.should == nil
|
19
19
|
}.join
|
20
20
|
end
|
21
21
|
end
|
@@ -34,7 +34,7 @@ describe RailsApp, "Testing Blameling Integration" do
|
|
34
34
|
Thread.new {
|
35
35
|
post :create
|
36
36
|
# Look in application.rb for the User class and it's id method.
|
37
|
-
BlogPost.last.
|
37
|
+
BlogPost.last.loglings.first.modified_by.should == 33
|
38
38
|
}.join
|
39
39
|
end
|
40
40
|
end
|
@@ -53,7 +53,7 @@ describe RailsApp, "Testing Blameling Integration" do
|
|
53
53
|
Thread.new {
|
54
54
|
post :create
|
55
55
|
# Look in application.rb for the User class and it's id method.
|
56
|
-
BlogPost.last.
|
56
|
+
BlogPost.last.loglings.first.modified_by.should == nil
|
57
57
|
}.join
|
58
58
|
end
|
59
59
|
end
|
@@ -72,7 +72,7 @@ describe RailsApp, "Testing Blameling Integration" do
|
|
72
72
|
Thread.new {
|
73
73
|
post :create
|
74
74
|
# Look in application.rb for the User class and it's id method.
|
75
|
-
BlogPost.last.
|
75
|
+
BlogPost.last.loglings.first.modified_by.should == 88
|
76
76
|
}.join
|
77
77
|
end
|
78
78
|
end
|
@@ -176,14 +176,14 @@ describe Changeling::Models::Logling do
|
|
176
176
|
@search.stub(:find_by).and_return(@results)
|
177
177
|
end
|
178
178
|
|
179
|
-
it "should
|
179
|
+
it "should be passed into the Search module" do
|
180
180
|
num = 5
|
181
|
-
@
|
181
|
+
@search.should_receive(:find_by).with(hash_including({ :size => num })).and_return(@results)
|
182
182
|
@klass.records_for(@object, 5)
|
183
183
|
end
|
184
184
|
|
185
|
-
it "should
|
186
|
-
@
|
185
|
+
it "should pass nil for size option into Search module" do
|
186
|
+
@search.should_receive(:find_by).with(hash_including({ :size => nil })).and_return(@results)
|
187
187
|
@klass.records_for(@object)
|
188
188
|
end
|
189
189
|
end
|
@@ -17,18 +17,21 @@ describe Changeling::Probeling do
|
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
20
|
-
@object.
|
20
|
+
@object.loglings.count.should == 4
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|
24
|
-
describe "
|
25
|
-
|
26
|
-
|
27
|
-
|
24
|
+
describe "pagination" do
|
25
|
+
before(:each) do
|
26
|
+
(1..50).each do |num|
|
27
|
+
@object.title = "Title #{num}"
|
28
|
+
@object.save!
|
29
|
+
end
|
28
30
|
end
|
29
31
|
|
30
|
-
it "should return
|
31
|
-
@object.
|
32
|
+
it "should return the specified amount of data when calling .loglings" do
|
33
|
+
@object.loglings.count.should == 10
|
34
|
+
@object.loglings(60).count.should == 54
|
32
35
|
end
|
33
36
|
end
|
34
37
|
|
@@ -49,7 +52,6 @@ describe Changeling::Probeling do
|
|
49
52
|
end
|
50
53
|
|
51
54
|
it "should only return the amount of loglings requested" do
|
52
|
-
@object.all_loglings.count.should == 4
|
53
55
|
@object.loglings(2).count.should == 2
|
54
56
|
end
|
55
57
|
|
@@ -59,8 +61,8 @@ describe Changeling::Probeling do
|
|
59
61
|
end
|
60
62
|
|
61
63
|
describe ".loglings_for_field" do
|
62
|
-
it "should query Logling with it's class name, and it's own ID, and a
|
63
|
-
@klass.should_receive(:records_for).with(@object,
|
64
|
+
it "should query Logling with it's class name, and it's own ID, a field name, and a default number of loglings to return" do
|
65
|
+
@klass.should_receive(:records_for).with(@object, 10, "field")
|
64
66
|
@object.loglings_for_field("field")
|
65
67
|
end
|
66
68
|
|
@@ -75,7 +77,7 @@ describe Changeling::Probeling do
|
|
75
77
|
end
|
76
78
|
|
77
79
|
it "should handle symbol arguments for field" do
|
78
|
-
@klass.should_receive(:records_for).with(@object,
|
80
|
+
@klass.should_receive(:records_for).with(@object, 10, "field")
|
79
81
|
@object.loglings_for_field(:field)
|
80
82
|
end
|
81
83
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: changeling
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-02-
|
12
|
+
date: 2013-02-28 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: tire
|