noodnik 0.1.1 → 0.2.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/README.md +8 -1
- data/app/controllers/noodnik/nags_controller.rb +5 -5
- data/app/helpers/noodnik/nags_helper.rb +35 -17
- data/app/models/noodnik/cookie_nag.rb +23 -0
- data/app/models/noodnik/nag.rb +11 -2
- data/lib/generators/noodnik/install/install_generator.rb +11 -0
- data/lib/generators/noodnik/install/templates/initializer.rb +8 -0
- data/test/dummy/db/development.sqlite3 +0 -0
- data/test/dummy/db/test.sqlite3 +0 -0
- data/test/dummy/log/development.log +1512 -0
- data/test/dummy/log/test.log +7031 -0
- data/test/dummy/spec/controllers/noodnik_nags_controller_spec.rb +2 -8
- data/test/dummy/spec/helpers/nags_helper_spec.rb +58 -14
- data/test/dummy/spec/spec_helper.rb +7 -0
- data/test/dummy/tmp/cache/assets/D54/ED0/sprockets%2F71c9fa01091d432b131da3bb73faf3d4 +0 -0
- metadata +5 -2
@@ -32,7 +32,7 @@ describe Noodnik::NagsController do
|
|
32
32
|
end
|
33
33
|
|
34
34
|
it "sets the provided topic as the cookie name" do
|
35
|
-
@cookies.should_receive(:[]=).with(@topic
|
35
|
+
@cookies.should_receive(:[]=).with("noodnik_#{@topic}", anything)
|
36
36
|
get :postpone, @attr
|
37
37
|
end
|
38
38
|
|
@@ -44,7 +44,7 @@ describe Noodnik::NagsController do
|
|
44
44
|
|
45
45
|
describe "GET 'complete'" do
|
46
46
|
it "removes the nag cookie" do
|
47
|
-
@cookies.should_receive(:delete).with(@topic
|
47
|
+
@cookies.should_receive(:delete).with("noodnik_#{@topic}")
|
48
48
|
get :complete, @attr
|
49
49
|
end
|
50
50
|
end
|
@@ -108,12 +108,6 @@ describe Noodnik::NagsController do
|
|
108
108
|
end
|
109
109
|
end
|
110
110
|
|
111
|
-
def set_current_user_id(user_id)
|
112
|
-
Noodnik.setup do |config|
|
113
|
-
config.current_user_id = lambda { user_id }
|
114
|
-
end
|
115
|
-
end
|
116
|
-
|
117
111
|
def stub_time
|
118
112
|
t = Time.parse("01/01/2010 10:00")
|
119
113
|
Time.stub!(:now).and_return(t)
|
@@ -10,9 +10,7 @@ describe Noodnik::NagsHelper do
|
|
10
10
|
describe "when signed in" do
|
11
11
|
before :each do
|
12
12
|
@user_id = 1
|
13
|
-
|
14
|
-
config.current_user_id = lambda { @user_id }
|
15
|
-
end
|
13
|
+
set_current_user_id(@user_id)
|
16
14
|
end
|
17
15
|
|
18
16
|
after :each do
|
@@ -25,13 +23,13 @@ describe Noodnik::NagsHelper do
|
|
25
23
|
end.should match(%r[<div class="noodnik-nag">.*</div>])
|
26
24
|
end
|
27
25
|
|
28
|
-
it "
|
26
|
+
it "yields the block for a new topic" do
|
29
27
|
helper.nag_user_to :register do |nag|
|
30
28
|
"Register!"
|
31
29
|
end.should include("Register!")
|
32
30
|
end
|
33
31
|
|
34
|
-
it "
|
32
|
+
it "does not yield the block if topic has been postponed" do
|
35
33
|
Noodnik::Nag.create! user_id: @user_id, topic: @topic, next_nag: 2.weeks.from_now
|
36
34
|
|
37
35
|
helper.nag_user_to :register do |nag|
|
@@ -39,7 +37,7 @@ describe Noodnik::NagsHelper do
|
|
39
37
|
end.should be_nil
|
40
38
|
end
|
41
39
|
|
42
|
-
it "
|
40
|
+
it "yields the block if postpone expired" do
|
43
41
|
Noodnik::Nag.create! user_id: @user_id, topic: @topic, next_nag: 1.week.ago
|
44
42
|
|
45
43
|
helper.nag_user_to :register do |nag|
|
@@ -47,27 +45,72 @@ describe Noodnik::NagsHelper do
|
|
47
45
|
end.should include("Register!")
|
48
46
|
end
|
49
47
|
|
50
|
-
it "
|
48
|
+
it "does not yield the block if topic was completed" do
|
51
49
|
Noodnik::Nag.create! user_id: @user_id, topic: @topic, next_nag: 10.weeks.ago, completed: true
|
52
50
|
|
53
51
|
helper.nag_user_to :register do |nag|
|
54
52
|
"I should not be returned!"
|
55
53
|
end.should be_nil
|
56
54
|
end
|
55
|
+
end
|
57
56
|
|
57
|
+
describe "when not signed in" do
|
58
|
+
before :each do
|
59
|
+
set_current_user_id(nil)
|
60
|
+
@cookies = mock('cookies')
|
61
|
+
helper.stub!(:cookies).and_return(@cookies)
|
62
|
+
end
|
63
|
+
|
64
|
+
it "yields the block in a div with class 'noodnik-nag'" do
|
65
|
+
@cookies.should_receive(:[]).with(:register).and_return(nil)
|
66
|
+
helper.nag_user_to :register do |nag|
|
67
|
+
"I should be in a <div>!"
|
68
|
+
end.should match(%r[<div class="noodnik-nag">.*</div>])
|
69
|
+
end
|
70
|
+
|
71
|
+
it "yields the block for a new topic" do
|
72
|
+
@cookies.should_receive(:[]).with(:register).and_return(nil)
|
73
|
+
helper.nag_user_to :register do |nag|
|
74
|
+
"Register!"
|
75
|
+
end.should include("Register!")
|
76
|
+
end
|
77
|
+
|
78
|
+
it "does not yield the block if topic has been postponed" do
|
79
|
+
@cookies.should_receive(:[]).with(:register).and_return(2.weeks.from_now.to_s)
|
80
|
+
helper.nag_user_to :register do |nag|
|
81
|
+
"I should not be returned!"
|
82
|
+
end.should be_nil
|
83
|
+
end
|
84
|
+
|
85
|
+
it "yields the block if postpone expired" do
|
86
|
+
@cookies.should_receive(:[]).with(:register).and_return(2.weeks.ago.to_s)
|
87
|
+
|
88
|
+
helper.nag_user_to :register do |nag|
|
89
|
+
"Register!"
|
90
|
+
end.should include("Register!")
|
91
|
+
end
|
92
|
+
|
93
|
+
it "does not yield the block if topic was completed" do
|
94
|
+
@cookies.should_receive(:[]).with(:register).and_return('complete')
|
95
|
+
|
96
|
+
helper.nag_user_to :register do |nag|
|
97
|
+
"I should not be returned!"
|
98
|
+
end.should be_nil
|
99
|
+
end
|
58
100
|
end
|
101
|
+
|
59
102
|
end
|
60
103
|
|
61
104
|
describe "link_to" do
|
62
105
|
describe "with html_options provided" do
|
63
106
|
before :each do
|
64
107
|
@link = nag_user_to :register do
|
65
|
-
|
108
|
+
link_to 'google.com', 'www.google.com', class: 'foo'
|
66
109
|
end
|
67
110
|
end
|
68
111
|
|
69
|
-
it "adds 'data-noodnik-
|
70
|
-
@link.should include('data-noodnik-topic=
|
112
|
+
it "adds 'data-noodnik-complete-path' with the correct topic" do
|
113
|
+
@link.should include('data-noodnik-complete-path="/noodnik/complete?topic=register"')
|
71
114
|
end
|
72
115
|
|
73
116
|
it "adds class 'noodnik-complete'" do
|
@@ -82,8 +125,8 @@ describe Noodnik::NagsHelper do
|
|
82
125
|
end
|
83
126
|
end
|
84
127
|
|
85
|
-
it "adds 'data-noodnik-
|
86
|
-
@link.should include('data-noodnik-topic=
|
128
|
+
it "adds 'data-noodnik-complete-path' with the correct topic" do
|
129
|
+
@link.should include('data-noodnik-complete-path="/noodnik/complete?topic=register"')
|
87
130
|
end
|
88
131
|
|
89
132
|
it "adds class 'noodnik-complete'" do
|
@@ -98,7 +141,7 @@ describe Noodnik::NagsHelper do
|
|
98
141
|
postpone_for 14.days
|
99
142
|
end
|
100
143
|
end
|
101
|
-
|
144
|
+
|
102
145
|
it "prompts a default message of 'Remind me in 14 days'" do
|
103
146
|
@link.should include('Remind me in 14 days')
|
104
147
|
end
|
@@ -115,10 +158,11 @@ describe Noodnik::NagsHelper do
|
|
115
158
|
@link.should include("topic=register")
|
116
159
|
end
|
117
160
|
|
118
|
-
it "
|
161
|
+
it "has class 'noodnik-postpone'" do
|
119
162
|
@link.should include("noodnik-postpone")
|
120
163
|
end
|
121
164
|
|
165
|
+
# postpone_for is the only type of link inside a nag_user_to block that *should'nt* get class 'noodnik-complete'
|
122
166
|
it "does not add class 'noodnik-complete'" do
|
123
167
|
@link.should_not include("noodnik-complete")
|
124
168
|
end
|
@@ -1,6 +1,13 @@
|
|
1
1
|
require 'rubygems'
|
2
2
|
require 'spork'
|
3
3
|
|
4
|
+
|
5
|
+
def set_current_user_id(user_id)
|
6
|
+
Noodnik.setup do |config|
|
7
|
+
config.current_user_id = lambda { user_id }
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
4
11
|
Spork.prefork do
|
5
12
|
# Loading more in this block will cause your tests to run faster. However,
|
6
13
|
# if you change any configuration or code from libraries loaded here, you'll
|
Binary file
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: noodnik
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
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: 2011-09-
|
12
|
+
date: 2011-09-22 00:00:00.000000000Z
|
13
13
|
dependencies: []
|
14
14
|
description: A simple Rails solution for reminding users to do stuff.
|
15
15
|
email: rauchy@gmail.com
|
@@ -25,11 +25,14 @@ files:
|
|
25
25
|
- app/assets/stylesheets/noodnik/nags.css
|
26
26
|
- app/views/layouts/application.html.erb
|
27
27
|
- app/views/layouts/noodnik/application.html.erb
|
28
|
+
- app/models/noodnik/cookie_nag.rb
|
28
29
|
- app/models/noodnik/nag.rb
|
29
30
|
- app/helpers/noodnik/nags_helper.rb
|
30
31
|
- app/helpers/noodnik/application_helper.rb
|
31
32
|
- config/routes.rb
|
32
33
|
- db/migrate/20110813042447_create_noodnik_nags.rb
|
34
|
+
- lib/generators/noodnik/install/install_generator.rb
|
35
|
+
- lib/generators/noodnik/install/templates/initializer.rb
|
33
36
|
- lib/noodnik.rb
|
34
37
|
- lib/noodnik/engine.rb
|
35
38
|
- lib/noodnik/railtie.rb
|