acts_as_footprintable 0.4.0 → 0.6.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (44) hide show
  1. checksums.yaml +5 -5
  2. data/.github/workflows/gem-push.yml +30 -0
  3. data/.github/workflows/test.yml +42 -0
  4. data/.gitignore +18 -20
  5. data/.rubocop.yml +32 -0
  6. data/Gemfile +5 -15
  7. data/README.md +6 -8
  8. data/Rakefile +11 -7
  9. data/acts_as_footprintable.gemspec +23 -19
  10. data/config.ru +9 -0
  11. data/gemfiles/rails_5.0.gemfile +8 -0
  12. data/gemfiles/rails_5.1.gemfile +8 -0
  13. data/gemfiles/rails_5.2.gemfile +8 -0
  14. data/gemfiles/rails_6.0.gemfile +8 -0
  15. data/gemfiles/rails_6.1.gemfile +8 -0
  16. data/gemfiles/rails_7.0.gemfile +8 -0
  17. data/lib/acts_as_footprintable/extenders/footprintable.rb +5 -4
  18. data/lib/acts_as_footprintable/extenders/footprinter.rb +4 -3
  19. data/lib/acts_as_footprintable/footprint.rb +9 -14
  20. data/lib/acts_as_footprintable/footprintable.rb +6 -10
  21. data/lib/acts_as_footprintable/footprinter.rb +32 -19
  22. data/lib/acts_as_footprintable/version.rb +3 -2
  23. data/lib/acts_as_footprintable.rb +2 -1
  24. data/lib/generators/acts_as_footprintable/migration/migration_generator.rb +20 -9
  25. data/lib/generators/acts_as_footprintable/migration/templates/active_record/migration.rb +6 -5
  26. data/test/footprintable_test.rb +97 -0
  27. data/test/footprinter_test.rb +64 -0
  28. data/test/internal/app/models/footprintable.rb +6 -0
  29. data/test/internal/app/models/not_footprintable.rb +5 -0
  30. data/{spec → test}/internal/app/models/not_user.rb +3 -2
  31. data/{spec → test}/internal/app/models/second_footprintable.rb +4 -3
  32. data/{spec → test}/internal/app/models/user.rb +3 -2
  33. data/test/test_helper.rb +57 -0
  34. metadata +82 -60
  35. data/.rspec +0 -1
  36. data/.travis.yml +0 -16
  37. data/spec/footprintable_spec.rb +0 -98
  38. data/spec/footprinter_spec.rb +0 -63
  39. data/spec/internal/app/models/footprintable.rb +0 -5
  40. data/spec/internal/app/models/not_footprintable.rb +0 -4
  41. data/spec/internal/config/database.yml +0 -5
  42. data/spec/internal/db/schema.rb +0 -31
  43. data/spec/internal/log/.gitignore +0 -1
  44. data/spec/spec_helper.rb +0 -24
@@ -1,63 +0,0 @@
1
- # coding: utf-8
2
- require 'spec_helper'
3
- require 'acts_as_footprintable/footprinter'
4
-
5
- describe ActsAsFootprintable::Footprinter do
6
-
7
- it "should not be a footprinter" do
8
- expect(NotUser).not_to be_footprinter
9
- end
10
-
11
- it "should be a footprinter" do
12
- expect(User).to be_footprinter
13
- end
14
-
15
- describe "ユーザーのアクセス履歴を" do
16
- let!(:user_1) { User.create!(:name => "user_1") }
17
- before do
18
- (1..5).each do |index|
19
- footprintable = Footprintable.create!(:name => "footprintable#{index}")
20
- second_footprintable = SecondFootprintable.create!(:name => "second_footprintable#{index}")
21
- 3.times do
22
- footprintable.leave_footprints user_1
23
- second_footprintable.leave_footprints user_1
24
- end
25
- end
26
- end
27
-
28
- context "対象のモデル毎に" do
29
- it "取得できること" do
30
- expect(user_1.access_histories_for(Footprintable).count).to eq 5
31
- expect(user_1.access_histories_for(Footprintable).map{|footprint| footprint.footprintable.name}).to eq (1..5).to_a.reverse.map{|index| "footprintable#{index}"}
32
- end
33
-
34
- it "件数を絞り込めること" do
35
- expect(user_1.access_histories_for(Footprintable, 3).count).to eq 3
36
- expect(user_1.access_histories_for(Footprintable, 3).map{|footprint| footprint.footprintable.name}).to eq (3..5).to_a.reverse.map{|index| "footprintable#{index}"}
37
- end
38
- end
39
-
40
- context "全てのモデルを通じて" do
41
- it "取得できること" do
42
- expect(user_1.access_histories.count).to eq 10
43
- footprintable_names = (1..5).to_a.reverse.inject([]) do |results, index|
44
- results.push "second_footprintable#{index}"
45
- results.push "footprintable#{index}"
46
- results
47
- end
48
- expect(user_1.access_histories.map{|footprint| footprint.footprintable.name}).to eq footprintable_names
49
- end
50
-
51
- it "件数を絞り込める事" do
52
- expect(user_1.access_histories(3).count).to eq 3
53
- end
54
- end
55
-
56
- context 'アクセス履歴のないユーザーの場合' do
57
- let!(:user_2) { User.create!(:name => "user_2") }
58
- it '件数が0件であること' do
59
- expect(user_2.access_histories_for(Footprintable).count).to eq 0
60
- end
61
- end
62
- end
63
- end
@@ -1,5 +0,0 @@
1
- # coding: utf-8
2
- class Footprintable < ActiveRecord::Base
3
- acts_as_footprintable
4
- validates :name, :presence => true
5
- end
@@ -1,4 +0,0 @@
1
- # coding: utf-8
2
- class NotFootprintable < ActiveRecord::Base
3
- validates :name, :presence => true
4
- end
@@ -1,5 +0,0 @@
1
- test:
2
- adapter: postgresql
3
- encoding: unicode
4
- database: acts_as_footprintable
5
- min_messages: WARNING
@@ -1,31 +0,0 @@
1
- # coding: utf-8
2
- ActiveRecord::Schema.define do
3
- create_table :footprints, :force => true do |t|
4
- t.references :footprintable, :polymorphic => true
5
- t.references :footprinter, :polymorphic => true
6
- t.timestamps :null => false
7
- end
8
-
9
- add_index :footprints, [:footprintable_id, :footprintable_type]
10
- add_index :footprints, [:footprinter_id, :footprinter_type]
11
-
12
- create_table :users, :force => true do |t|
13
- t.string :name
14
- end
15
-
16
- create_table :not_users, :force => true do |t|
17
- t.string :name
18
- end
19
-
20
- create_table :footprintables, :force => true do |t|
21
- t.string :name
22
- end
23
-
24
- create_table :second_footprintables, :force => true do |t|
25
- t.string :name
26
- end
27
-
28
- create_table :not_footprintables, :force => true do |t|
29
- t.string :name
30
- end
31
- end
@@ -1 +0,0 @@
1
- *.log
data/spec/spec_helper.rb DELETED
@@ -1,24 +0,0 @@
1
- ## coding: utf-8
2
- require 'rubygems'
3
- require 'bundler/setup'
4
- require 'combustion'
5
- require 'database_cleaner'
6
- require 'timecop'
7
- require 'pry'
8
-
9
- Combustion.initialize! :active_record
10
-
11
- RSpec.configure do |config|
12
- config.run_all_when_everything_filtered = true
13
- config.filter_run :focus
14
-
15
- config.before :suite do
16
- DatabaseCleaner.strategy = :truncation
17
- end
18
- config.before :each do
19
- DatabaseCleaner.start
20
- end
21
- config.after :each do
22
- DatabaseCleaner.clean
23
- end
24
- end