@@ -100,30 +100,38 @@ def teardown
100100 end
101101 end
102102
103- test "encouragement to contribute appears after 10 created notes and disappears after login" do
104- check_encouragement_while_creating_notes ( 10 )
103+ test "encouragement to contribute appears after 5 created notes and disappears after login" do
104+ check_encouragement_while_creating_notes ( 5 )
105105
106106 sign_in_as ( create ( :user ) )
107107
108108 check_no_encouragement_while_logging_out
109109 end
110110
111- test "encouragement to contribute appears after 10 created notes and disappears after email signup" do
112- check_encouragement_while_creating_notes ( 10 )
111+ test "encouragement to contribute appears after 5 created notes and disappears after email signup" do
112+ check_encouragement_while_creating_notes ( 5 )
113113
114114 sign_up_with_email
115115
116116 check_no_encouragement_while_logging_out
117117 end
118118
119- test "encouragement to contribute appears after 10 created notes and disappears after google signup" do
120- check_encouragement_while_creating_notes ( 10 )
119+ test "encouragement to contribute appears after 5 created notes and disappears after google signup" do
120+ check_encouragement_while_creating_notes ( 5 )
121121
122122 sign_up_with_google
123123
124124 check_no_encouragement_while_logging_out
125125 end
126126
127+ test "strict encouragement to contribute appears after 10 created notes and disappears after login" do
128+ check_strict_encouragement_while_creating_notes ( 5 , 10 )
129+
130+ sign_in_as ( create ( :user ) )
131+
132+ check_no_encouragement_while_logging_out
133+ end
134+
127135 private
128136
129137 def check_encouragement_while_creating_notes ( encouragement_threshold )
@@ -147,6 +155,32 @@ def check_encouragement_while_creating_notes(encouragement_threshold)
147155 end
148156 end
149157
158+ def check_strict_encouragement_while_creating_notes ( encouragement_threshold , strict_encouragement_threshold )
159+ strict_encouragement_threshold . times do |n |
160+ visit new_note_path ( :anchor => "map=16/0/#{ 0.001 * n } " )
161+
162+ within_sidebar do
163+ if n < encouragement_threshold
164+ assert_no_content ( /already posted at least \d + anonymous note/ )
165+ else
166+ assert_content ( /already posted at least \d + anonymous note/ )
167+ end
168+
169+ fill_in "text" , :with => "new note ##{ n + 1 } "
170+ click_on "Add Note"
171+
172+ assert_content "new note ##{ n + 1 } "
173+ end
174+ end
175+
176+ visit new_note_path ( :anchor => "map=16/0/#{ 0.001 * strict_encouragement_threshold } " )
177+
178+ within_sidebar do
179+ assert_content ( /already posted at least #{ strict_encouragement_threshold } anonymous note/ )
180+ assert_no_button "Add Note"
181+ end
182+ end
183+
150184 def check_no_encouragement_while_logging_out
151185 visit new_note_path ( :anchor => "map=16/0/0" )
152186
0 commit comments