acts_as_footprintable 0.2.2 → 0.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.travis.yml +5 -1
- data/acts_as_footprintable.gemspec +1 -1
- data/lib/acts_as_footprintable/footprinter.rb +1 -1
- data/lib/acts_as_footprintable/version.rb +1 -1
- data/lib/generators/acts_as_footprintable/migration/templates/active_record/migration.rb +1 -1
- data/spec/footprintable_spec.rb +9 -7
- data/spec/footprinter_spec.rb +10 -9
- data/spec/internal/db/schema.rb +1 -1
- data/spec/spec_helper.rb +0 -1
- metadata +5 -6
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 8e8915ee9a150cadf7601e9f54d18ee0d373f6c9
|
|
4
|
+
data.tar.gz: bbbf50a358d50691ac80a361b0139e6b56405efd
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 250b5cc290a53082fd2af8b2f692d9ec43025d420807ce16983f2a0f6288f0cf68309e7fcea4cec920b2d6eddbb01d445adf5637e94f280a0f834cc8396f03e8
|
|
7
|
+
data.tar.gz: e49ee10b5b6ba5fed9fff2e525f0f424b75e263094badf48ee8841af9cf1b05d7ebab2b78f732b9aba7d99bcd442b7d055fc29423ada85b9cf138fc37a503597
|
data/.travis.yml
CHANGED
|
@@ -20,7 +20,7 @@ Gem::Specification.new do |spec|
|
|
|
20
20
|
|
|
21
21
|
spec.add_development_dependency "bundler", "~> 1.3"
|
|
22
22
|
spec.add_development_dependency 'rake'
|
|
23
|
-
spec.add_development_dependency 'rspec'
|
|
23
|
+
spec.add_development_dependency 'rspec', ">= 3.0.0"
|
|
24
24
|
spec.add_development_dependency 'pg'
|
|
25
25
|
spec.add_development_dependency 'timecop'
|
|
26
26
|
spec.add_development_dependency 'database_cleaner', "~> 1.0.1"
|
|
@@ -30,7 +30,7 @@ module ActsAsFootprintable
|
|
|
30
30
|
|
|
31
31
|
private
|
|
32
32
|
def get_access_history_records(target, limit=nil)
|
|
33
|
-
footprints.where(:id => recent_footprint_ids(target, limit))
|
|
33
|
+
footprints.where(:id => recent_footprint_ids(target, limit)).order("created_at DESC")
|
|
34
34
|
end
|
|
35
35
|
|
|
36
36
|
def table_name
|
|
@@ -4,7 +4,7 @@ class ActsAsFootprintableMigration < ActiveRecord::Migration
|
|
|
4
4
|
create_table :footprints do |t|
|
|
5
5
|
t.references :footprintable, :polymorphic => true
|
|
6
6
|
t.references :footprinter, :polymorphic => true
|
|
7
|
-
t.timestamps
|
|
7
|
+
t.timestamps :null => false
|
|
8
8
|
end
|
|
9
9
|
|
|
10
10
|
if ActiveRecord::VERSION::MAJOR < 4
|
data/spec/footprintable_spec.rb
CHANGED
|
@@ -4,11 +4,11 @@ require 'spec_helper'
|
|
|
4
4
|
describe ActsAsFootprintable::Footprintable do
|
|
5
5
|
|
|
6
6
|
it "should not be a footprintable" do
|
|
7
|
-
NotFootprintable.
|
|
7
|
+
expect(NotFootprintable).not_to be_footprintable
|
|
8
8
|
end
|
|
9
9
|
|
|
10
10
|
it "should be a footprintable" do
|
|
11
|
-
Footprintable.
|
|
11
|
+
expect(Footprintable).to be_footprintable
|
|
12
12
|
end
|
|
13
13
|
|
|
14
14
|
describe 'leave footprints by footprinter' do
|
|
@@ -22,7 +22,7 @@ describe ActsAsFootprintable::Footprintable do
|
|
|
22
22
|
end
|
|
23
23
|
|
|
24
24
|
it "should be leave footprints" do
|
|
25
|
-
@footprintable.leave_footprints(@user).
|
|
25
|
+
expect(@footprintable.leave_footprints(@user)).to be_truthy
|
|
26
26
|
end
|
|
27
27
|
|
|
28
28
|
it "足跡の数が増えていること" do
|
|
@@ -56,7 +56,7 @@ describe ActsAsFootprintable::Footprintable do
|
|
|
56
56
|
context "1週間の場合" do
|
|
57
57
|
it "35の足跡があること" do
|
|
58
58
|
Timecop.travel(Time.parse("2013/9/30 10:00:00")) do
|
|
59
|
-
@footprintable.footprint_count_between(1.week.ago..Time.now).
|
|
59
|
+
expect(@footprintable.footprint_count_between(1.week.ago..Time.now)).to eq 35
|
|
60
60
|
end
|
|
61
61
|
end
|
|
62
62
|
end
|
|
@@ -64,7 +64,7 @@ describe ActsAsFootprintable::Footprintable do
|
|
|
64
64
|
context "1ヶ月の場合" do
|
|
65
65
|
it "150の足跡があること" do
|
|
66
66
|
Timecop.travel(Time.parse("2013/9/30 10:00:00")) do
|
|
67
|
-
@footprintable.footprint_count_between(1.month.ago..Time.now).
|
|
67
|
+
expect(@footprintable.footprint_count_between(1.month.ago..Time.now)).to eq 150
|
|
68
68
|
end
|
|
69
69
|
end
|
|
70
70
|
end
|
|
@@ -89,8 +89,10 @@ describe ActsAsFootprintable::Footprintable do
|
|
|
89
89
|
month = Time.new(2013,9,1)
|
|
90
90
|
Footprintable.access_ranking(month.beginning_of_month...1.week.since(month), 5)
|
|
91
91
|
end
|
|
92
|
-
it {
|
|
93
|
-
it
|
|
92
|
+
it { is_expected.to eq ({7 => 7, 6 => 6, 5 => 5, 4 => 4, 3 => 3 }) }
|
|
93
|
+
it '5件取得できること' do
|
|
94
|
+
expect(subject.count).to eq 5
|
|
95
|
+
end
|
|
94
96
|
end
|
|
95
97
|
end
|
|
96
98
|
end
|
data/spec/footprinter_spec.rb
CHANGED
|
@@ -5,11 +5,11 @@ require 'acts_as_footprintable/footprinter'
|
|
|
5
5
|
describe ActsAsFootprintable::Footprinter do
|
|
6
6
|
|
|
7
7
|
it "should not be a footprinter" do
|
|
8
|
-
NotUser.
|
|
8
|
+
expect(NotUser).not_to be_footprinter
|
|
9
9
|
end
|
|
10
10
|
|
|
11
11
|
it "should be a footprinter" do
|
|
12
|
-
User.
|
|
12
|
+
expect(User).to be_footprinter
|
|
13
13
|
end
|
|
14
14
|
|
|
15
15
|
describe "ユーザーのアクセス履歴を" do
|
|
@@ -27,28 +27,29 @@ describe ActsAsFootprintable::Footprinter do
|
|
|
27
27
|
|
|
28
28
|
context "対象のモデル毎に" do
|
|
29
29
|
it "取得できること" do
|
|
30
|
-
@user.access_histories_for(Footprintable).
|
|
31
|
-
@user.access_histories_for(Footprintable).map{|footprint| footprint.footprintable.name}.
|
|
30
|
+
expect(@user.access_histories_for(Footprintable).count).to eq 5
|
|
31
|
+
expect(@user.access_histories_for(Footprintable).map{|footprint| footprint.footprintable.name}).to eq (1..5).to_a.reverse.map{|index| "footprintable#{index}"}
|
|
32
32
|
end
|
|
33
33
|
|
|
34
34
|
it "件数を絞り込めること" do
|
|
35
|
-
@user.access_histories_for(Footprintable, 3).
|
|
36
|
-
@user.access_histories_for(Footprintable, 3).map{|footprint| footprint.footprintable.name}.
|
|
35
|
+
expect(@user.access_histories_for(Footprintable, 3).count).to eq 3
|
|
36
|
+
expect(@user.access_histories_for(Footprintable, 3).map{|footprint| footprint.footprintable.name}).to eq (3..5).to_a.reverse.map{|index| "footprintable#{index}"}
|
|
37
37
|
end
|
|
38
38
|
end
|
|
39
39
|
|
|
40
40
|
context "全てのモデルを通じて" do
|
|
41
41
|
it "取得できること" do
|
|
42
|
-
@user.access_histories.
|
|
43
|
-
|
|
42
|
+
expect(@user.access_histories.count).to eq 10
|
|
43
|
+
footprintable_names = (1..5).to_a.reverse.inject([]) do |results, index|
|
|
44
44
|
results.push "second_footprintable#{index}"
|
|
45
45
|
results.push "footprintable#{index}"
|
|
46
46
|
results
|
|
47
47
|
end
|
|
48
|
+
expect(@user.access_histories.map{|footprint| footprint.footprintable.name}).to eq footprintable_names
|
|
48
49
|
end
|
|
49
50
|
|
|
50
51
|
it "件数を絞り込める事" do
|
|
51
|
-
@user.access_histories(3).
|
|
52
|
+
expect(@user.access_histories(3).count).to eq 3
|
|
52
53
|
end
|
|
53
54
|
end
|
|
54
55
|
end
|
data/spec/internal/db/schema.rb
CHANGED
|
@@ -3,7 +3,7 @@ ActiveRecord::Schema.define do
|
|
|
3
3
|
create_table :footprints, :force => true do |t|
|
|
4
4
|
t.references :footprintable, :polymorphic => true
|
|
5
5
|
t.references :footprinter, :polymorphic => true
|
|
6
|
-
t.timestamps
|
|
6
|
+
t.timestamps :null => false
|
|
7
7
|
end
|
|
8
8
|
|
|
9
9
|
add_index :footprints, [:footprintable_id, :footprintable_type]
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: acts_as_footprintable
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.2.
|
|
4
|
+
version: 0.2.3
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Toyoaki Oko
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2016-06-10 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|
|
@@ -44,14 +44,14 @@ dependencies:
|
|
|
44
44
|
requirements:
|
|
45
45
|
- - ">="
|
|
46
46
|
- !ruby/object:Gem::Version
|
|
47
|
-
version:
|
|
47
|
+
version: 3.0.0
|
|
48
48
|
type: :development
|
|
49
49
|
prerelease: false
|
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
|
51
51
|
requirements:
|
|
52
52
|
- - ">="
|
|
53
53
|
- !ruby/object:Gem::Version
|
|
54
|
-
version:
|
|
54
|
+
version: 3.0.0
|
|
55
55
|
- !ruby/object:Gem::Dependency
|
|
56
56
|
name: pg
|
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -148,7 +148,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
148
148
|
version: '0'
|
|
149
149
|
requirements: []
|
|
150
150
|
rubyforge_project:
|
|
151
|
-
rubygems_version: 2.
|
|
151
|
+
rubygems_version: 2.5.1
|
|
152
152
|
signing_key:
|
|
153
153
|
specification_version: 4
|
|
154
154
|
summary: Rails gem to allowing records to leave footprints
|
|
@@ -164,4 +164,3 @@ test_files:
|
|
|
164
164
|
- spec/internal/db/schema.rb
|
|
165
165
|
- spec/internal/log/.gitignore
|
|
166
166
|
- spec/spec_helper.rb
|
|
167
|
-
has_rdoc:
|