best_boy 0.0.3 → 0.1.0
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.
- data/.gitignore +1 -0
- data/CHANGELOG.md +6 -0
- data/README.md +35 -1
- data/app/controllers/best_boy/best_boy_events_controller.rb +65 -0
- data/app/views/best_boy/best_boy_events/_navigation.html.erb +9 -0
- data/app/views/best_boy/best_boy_events/index.html.erb +6 -0
- data/app/views/best_boy/best_boy_events/lists.html.erb +43 -0
- data/app/views/best_boy/best_boy_events/stats.html.erb +60 -0
- data/app/views/layouts/best_boy_backend.html.erb +62 -0
- data/best_boy.gemspec +9 -6
- data/config/routes.rb +5 -0
- data/db/bestboy.db +0 -0
- data/lib/best_boy.rb +5 -1
- data/{app → lib/best_boy}/controllers/best_boy_controller.rb +1 -1
- data/lib/best_boy/engine.rb +3 -1
- data/lib/best_boy/models/active_record/best_boy/eventable.rb +4 -0
- data/lib/best_boy/models/active_record/best_boy_event.rb +11 -1
- data/lib/best_boy/version.rb +1 -1
- data/lib/generators/best_boy_generator.rb +6 -0
- data/lib/generators/templates/best_boy.rb +15 -3
- data/lib/generators/templates/bootstrap/bootstrap.css +4983 -0
- data/lib/generators/templates/bootstrap/bootstrap_datepicker.css +156 -0
- data/lib/generators/templates/bootstrap/bootstrap_datepicker.js +401 -0
- data/lib/generators/templates/bootstrap/glyphicons-halflings-white.png +0 -0
- data/lib/generators/templates/bootstrap/glyphicons-halflings.png +0 -0
- data/log/test.log +1 -0
- data/spec/best_boy/best_boy_controller_spec.rb +4 -4
- data/spec/best_boy/best_boy_event_spec.rb +49 -3
- data/spec/best_boy/eventable_spec.rb +4 -4
- data/spec/spec_helper.rb +8 -8
- metadata +54 -20
- data/app/models/best_boy/eventable.rb +0 -10
Binary file
|
Binary file
|
data/log/test.log
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
Connecting to database specified by database.yml
|
@@ -2,16 +2,16 @@ require "spec_helper"
|
|
2
2
|
|
3
3
|
describe BestBoyController do
|
4
4
|
before(:each) do
|
5
|
-
@
|
5
|
+
@example = Example.create
|
6
6
|
end
|
7
7
|
|
8
8
|
it "should send valid custom event" do
|
9
|
-
best_boy_event @
|
10
|
-
BestBoyEvent.where(:owner_id => @
|
9
|
+
best_boy_event @example, "testing"
|
10
|
+
BestBoyEvent.where(:owner_id => @example.id, :owner_type => @example.class.name.to_s, :event => "testing").first.should_not be_nil
|
11
11
|
end
|
12
12
|
|
13
13
|
it "should raise error on empty event_phrase" do
|
14
|
-
expect {best_boy_event(@
|
14
|
+
expect {best_boy_event(@example, "")}.should raise_error
|
15
15
|
end
|
16
16
|
|
17
17
|
it "should raise error on class not beeing a eventable" do
|
@@ -1,13 +1,59 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
|
-
describe BestBoyEvent do
|
3
|
+
describe BestBoyEvent, 'with creating' do
|
4
4
|
it "should have valid model" do
|
5
|
-
|
6
|
-
BestBoyEvent.create(:owner_id =>
|
5
|
+
example = Example.create
|
6
|
+
BestBoyEvent.create(:owner_id => example.id, :owner_type => example.class.name.to_s, :event => "create").should be_valid
|
7
7
|
end
|
8
|
+
end
|
8
9
|
|
10
|
+
describe BestBoyEvent, 'with associations' do
|
11
|
+
it { should belong_to(:owner) }
|
12
|
+
end
|
13
|
+
|
14
|
+
describe BestBoyEvent, 'with validations' do
|
9
15
|
it "should require a event" do
|
10
16
|
BestBoyEvent.create(:event => "").should_not be_valid
|
11
17
|
end
|
18
|
+
end
|
19
|
+
|
20
|
+
describe BestBoyEvent, 'with scopes' do
|
21
|
+
def setup_data_aggreagations times, created_at
|
22
|
+
ActiveRecord::Base.connection.execute("DELETE FROM 'best_boy_events'")
|
23
|
+
example = Example.create
|
24
|
+
(1..times).each do
|
25
|
+
BestBoyEvent.create(:owner_id => example.id, :owner_type => example.class.name.to_s, :event => "year_test", :created_at => created_at)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
it "should return correct per_year scope" do
|
30
|
+
setup_data_aggreagations 3, Time.now - 2.years
|
31
|
+
BestBoyEvent.per_year(Time.now - 2.years).count.should eql(3)
|
32
|
+
BestBoyEvent.per_year(Time.now - 2.years).last.created_at.to_date.year.should eql((Time.now - 2.years).year)
|
33
|
+
end
|
34
|
+
|
35
|
+
it "should return correct per_month scope" do
|
36
|
+
setup_data_aggreagations 4, Time.now - 2.month
|
37
|
+
BestBoyEvent.per_month(Time.now - 2.month).count.should eql(4)
|
38
|
+
BestBoyEvent.per_month(Time.now - 2.month).last.created_at.to_date.month.should eql((Time.now - 2.month).month)
|
39
|
+
end
|
40
|
+
|
41
|
+
it "should return correct per_week scope" do
|
42
|
+
setup_data_aggreagations 5, Time.now - 2.weeks
|
43
|
+
BestBoyEvent.per_week(Time.now - 2.weeks).count.should eql(5)
|
44
|
+
end
|
12
45
|
|
46
|
+
it "should return correct per_month scope" do
|
47
|
+
setup_data_aggreagations 7, Time.now - 2.days
|
48
|
+
BestBoyEvent.per_day(Time.now - 2.days).count.should eql(7)
|
49
|
+
BestBoyEvent.per_day(Time.now - 2.days).last.created_at.to_date.day.should eql((Time.now - 2.days).day)
|
50
|
+
end
|
51
|
+
|
52
|
+
it "should return 0 for wrong dates" do
|
53
|
+
setup_data_aggreagations 5, Time.now - 2.weeks
|
54
|
+
BestBoyEvent.per_year(Time.now - 2.years).count.should eql(0)
|
55
|
+
BestBoyEvent.per_month(Time.now - 2.month).count.should eql(0)
|
56
|
+
BestBoyEvent.per_week(Time.now - 3.weeks).count.should eql(0)
|
57
|
+
BestBoyEvent.per_day(Time.now - 2.days).count.should eql(0)
|
58
|
+
end
|
13
59
|
end
|
@@ -2,19 +2,19 @@ require "spec_helper"
|
|
2
2
|
|
3
3
|
describe BestBoy::Eventable do
|
4
4
|
before(:each) do
|
5
|
-
@
|
5
|
+
@example = Example.create
|
6
6
|
end
|
7
7
|
|
8
8
|
it "should send valid create event" do
|
9
|
-
best_boy_event = @
|
9
|
+
best_boy_event = @example.best_boy_events.first.should_not be_nil
|
10
10
|
end
|
11
11
|
|
12
12
|
it "should send valid destroy event" do
|
13
|
-
@
|
13
|
+
@example.destroy
|
14
14
|
BestBoyEvent.where(:owner_type => "User", :event => "destroy").should_not be_nil
|
15
15
|
end
|
16
16
|
|
17
17
|
it "should be an eventable" do
|
18
|
-
@
|
18
|
+
@example.respond_to?("eventable?").should eql(true)
|
19
19
|
end
|
20
20
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -4,17 +4,17 @@ require 'active_record'
|
|
4
4
|
require 'active_support'
|
5
5
|
require "best_boy/models/active_record/best_boy_event.rb"
|
6
6
|
require "best_boy/models/active_record/best_boy/eventable.rb"
|
7
|
-
require "
|
8
|
-
require "./app/controllers/best_boy_controller.rb"
|
7
|
+
require "best_boy/controllers/best_boy_controller.rb"
|
9
8
|
require 'rspec'
|
10
9
|
require 'rspec/autorun'
|
10
|
+
require 'shoulda'
|
11
11
|
|
12
12
|
root = File.expand_path(File.join(File.dirname(__FILE__), '..'))
|
13
13
|
ActiveRecord::Base.establish_connection(
|
14
14
|
:adapter => "sqlite3",
|
15
15
|
:database => "#{root}/db/bestboy.db"
|
16
16
|
)
|
17
|
-
ActiveRecord::Base.connection.execute("DROP TABLE IF EXISTS '
|
17
|
+
ActiveRecord::Base.connection.execute("DROP TABLE IF EXISTS 'examples'")
|
18
18
|
ActiveRecord::Base.connection.execute("DROP TABLE IF EXISTS 'best_boy_events'")
|
19
19
|
ActiveRecord::Schema.define do
|
20
20
|
self.verbose = false
|
@@ -30,21 +30,21 @@ ActiveRecord::Schema.define do
|
|
30
30
|
add_index :best_boy_events, [:owner_id, :owner_type]
|
31
31
|
add_index :best_boy_events, :event
|
32
32
|
|
33
|
-
create_table :
|
33
|
+
create_table :examples, :force => true do |t|
|
34
34
|
t.timestamps
|
35
35
|
end
|
36
|
-
|
37
36
|
end
|
38
37
|
|
39
38
|
ActiveRecord::Base.send(:include, BestBoy::Eventable)
|
40
39
|
|
41
40
|
RSpec.configure do |config|
|
41
|
+
config.mock_with :rspec
|
42
42
|
config.include BestBoyController::InstanceMethods
|
43
43
|
end
|
44
44
|
|
45
|
-
class
|
46
|
-
has_a_best_boy
|
45
|
+
class Dummy
|
47
46
|
end
|
48
47
|
|
49
|
-
class
|
48
|
+
class Example < ActiveRecord::Base
|
49
|
+
has_a_best_boy
|
50
50
|
end
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: best_boy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.0
|
5
|
+
version: 0.1.0
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Christoph Seydel
|
@@ -10,75 +10,97 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2012-06-
|
13
|
+
date: 2012-06-19 00:00:00 +02:00
|
14
14
|
default_executable:
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
|
-
name:
|
17
|
+
name: kaminari
|
18
18
|
prerelease: false
|
19
19
|
requirement: &id001 !ruby/object:Gem::Requirement
|
20
20
|
none: false
|
21
21
|
requirements:
|
22
22
|
- - ">="
|
23
23
|
- !ruby/object:Gem::Version
|
24
|
-
version:
|
25
|
-
type: :
|
24
|
+
version: "0"
|
25
|
+
type: :runtime
|
26
26
|
version_requirements: *id001
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
28
|
+
name: bundler
|
29
29
|
prerelease: false
|
30
30
|
requirement: &id002 !ruby/object:Gem::Requirement
|
31
31
|
none: false
|
32
32
|
requirements:
|
33
|
-
- -
|
33
|
+
- - ~>
|
34
34
|
- !ruby/object:Gem::Version
|
35
|
-
version:
|
35
|
+
version: 1.1.0
|
36
36
|
type: :development
|
37
37
|
version_requirements: *id002
|
38
38
|
- !ruby/object:Gem::Dependency
|
39
|
-
name:
|
39
|
+
name: activerecord
|
40
40
|
prerelease: false
|
41
41
|
requirement: &id003 !ruby/object:Gem::Requirement
|
42
42
|
none: false
|
43
43
|
requirements:
|
44
44
|
- - ">="
|
45
45
|
- !ruby/object:Gem::Version
|
46
|
-
version:
|
46
|
+
version: "0"
|
47
47
|
type: :development
|
48
48
|
version_requirements: *id003
|
49
49
|
- !ruby/object:Gem::Dependency
|
50
|
-
name:
|
50
|
+
name: activesupport
|
51
51
|
prerelease: false
|
52
52
|
requirement: &id004 !ruby/object:Gem::Requirement
|
53
53
|
none: false
|
54
54
|
requirements:
|
55
55
|
- - ">="
|
56
56
|
- !ruby/object:Gem::Version
|
57
|
-
version:
|
57
|
+
version: "0"
|
58
58
|
type: :development
|
59
59
|
version_requirements: *id004
|
60
60
|
- !ruby/object:Gem::Dependency
|
61
|
-
name:
|
61
|
+
name: sqlite3
|
62
62
|
prerelease: false
|
63
63
|
requirement: &id005 !ruby/object:Gem::Requirement
|
64
64
|
none: false
|
65
65
|
requirements:
|
66
|
-
- -
|
66
|
+
- - ~>
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version:
|
68
|
+
version: 1.3.6
|
69
69
|
type: :development
|
70
70
|
version_requirements: *id005
|
71
71
|
- !ruby/object:Gem::Dependency
|
72
|
-
name:
|
72
|
+
name: rake
|
73
73
|
prerelease: false
|
74
74
|
requirement: &id006 !ruby/object:Gem::Requirement
|
75
75
|
none: false
|
76
76
|
requirements:
|
77
|
-
- -
|
77
|
+
- - ~>
|
78
78
|
- !ruby/object:Gem::Version
|
79
|
-
version:
|
79
|
+
version: 0.9.2.2
|
80
80
|
type: :development
|
81
81
|
version_requirements: *id006
|
82
|
+
- !ruby/object:Gem::Dependency
|
83
|
+
name: rspec
|
84
|
+
prerelease: false
|
85
|
+
requirement: &id007 !ruby/object:Gem::Requirement
|
86
|
+
none: false
|
87
|
+
requirements:
|
88
|
+
- - ~>
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
version: 2.10.0
|
91
|
+
type: :development
|
92
|
+
version_requirements: *id007
|
93
|
+
- !ruby/object:Gem::Dependency
|
94
|
+
name: shoulda
|
95
|
+
prerelease: false
|
96
|
+
requirement: &id008 !ruby/object:Gem::Requirement
|
97
|
+
none: false
|
98
|
+
requirements:
|
99
|
+
- - ~>
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: 3.0.1
|
102
|
+
type: :development
|
103
|
+
version_requirements: *id008
|
82
104
|
description: Hybrid action logging, consisting of standard and custom logging.
|
83
105
|
email:
|
84
106
|
- christoph.seydel@me.com
|
@@ -97,11 +119,17 @@ files:
|
|
97
119
|
- LICENSE.txt
|
98
120
|
- README.md
|
99
121
|
- Rakefile
|
100
|
-
- app/controllers/
|
101
|
-
- app/
|
122
|
+
- app/controllers/best_boy/best_boy_events_controller.rb
|
123
|
+
- app/views/best_boy/best_boy_events/_navigation.html.erb
|
124
|
+
- app/views/best_boy/best_boy_events/index.html.erb
|
125
|
+
- app/views/best_boy/best_boy_events/lists.html.erb
|
126
|
+
- app/views/best_boy/best_boy_events/stats.html.erb
|
127
|
+
- app/views/layouts/best_boy_backend.html.erb
|
102
128
|
- best_boy.gemspec
|
129
|
+
- config/routes.rb
|
103
130
|
- db/bestboy.db
|
104
131
|
- lib/best_boy.rb
|
132
|
+
- lib/best_boy/controllers/best_boy_controller.rb
|
105
133
|
- lib/best_boy/engine.rb
|
106
134
|
- lib/best_boy/models/active_record/best_boy/eventable.rb
|
107
135
|
- lib/best_boy/models/active_record/best_boy_event.rb
|
@@ -110,6 +138,12 @@ files:
|
|
110
138
|
- lib/generators/active_record/templates/create_best_boy_events_table.rb
|
111
139
|
- lib/generators/best_boy_generator.rb
|
112
140
|
- lib/generators/templates/best_boy.rb
|
141
|
+
- lib/generators/templates/bootstrap/bootstrap.css
|
142
|
+
- lib/generators/templates/bootstrap/bootstrap_datepicker.css
|
143
|
+
- lib/generators/templates/bootstrap/bootstrap_datepicker.js
|
144
|
+
- lib/generators/templates/bootstrap/glyphicons-halflings-white.png
|
145
|
+
- lib/generators/templates/bootstrap/glyphicons-halflings.png
|
146
|
+
- log/test.log
|
113
147
|
- spec/best_boy/best_boy_controller_spec.rb
|
114
148
|
- spec/best_boy/best_boy_event_spec.rb
|
115
149
|
- spec/best_boy/eventable_spec.rb
|