diff --git a/app/controllers/wiki_controller.rb b/app/controllers/wiki_controller.rb
index 9c98273393..579db50905 100644
--- a/app/controllers/wiki_controller.rb
+++ b/app/controllers/wiki_controller.rb
@@ -102,6 +102,10 @@ def edit
if @node.has_tag('locked') && !current_user.can_moderate?
flash[:warning] = "This page is locked, and only moderators can edit it."
redirect_to @node.path
+ elsif current_user &.first_time_poster
+ flash[:notice] = "Please post a question or other content before editing the wiki. Click here to learn why."
+ redirect_to Node.find_wiki(params[:id]).path
+ return
end
if ((Time.now.to_i - @node.latest.timestamp) < 5.minutes.to_i) && @node.latest.author.uid != current_user.uid
flash.now[:warning] = I18n.t('wiki_controller.someone_clicked_edit_5_minutes_ago')
diff --git a/test/functional/wiki_controller_test.rb b/test/functional/wiki_controller_test.rb
index d7d4f53b00..d624a755cf 100644
--- a/test/functional/wiki_controller_test.rb
+++ b/test/functional/wiki_controller_test.rb
@@ -127,17 +127,33 @@ def teardown
end
test 'viewing edit wiki page' do
+ UserSession.find.destroy if UserSession.find
+ UserSession.create(users(:jeff)) # jeff user fixture is not a first-time-poster
+
get :edit,
params: {
id: 'organizers'
}
+ assert_not users(:jeff).first_time_poster
+ assert_response :success
assert_template 'wiki/edit'
assert_not_nil assigns(:title)
assert_not_nil assigns(:node)
- assert_response :success
end
+ test 'disallow viewing edit wiki page for first-timers' do
+ # default bob user fixure is a first-time-poster
+ assert users(:bob).first_time_poster
+ get :edit,
+ params: {
+ id: 'chicago'
+ }
+
+ assert_equal flash[:notice], "Please post a question or other content before editing the wiki. Click here to learn why."
+ assert_redirected_to nodes(:place).path
+ end
+
test 'updating wiki' do
wiki = nodes(:organizers)
newtitle = 'New Title'