FIX: Rename ninja edit terminology to grace period (#13598)

FIX: Rename ninja edit terminology to grace period (#13598)

We renamed the site setting for this long ago, but there were a few places left in the code base where “ninja edit” needed to be turned into “grace period”. Doing this here to avoid combatative language.

diff --git a/lib/post_revisor.rb b/lib/post_revisor.rb
index a96e658..1c51d75 100644
--- a/lib/post_revisor.rb
+++ b/lib/post_revisor.rb
@@ -121,7 +121,7 @@ class PostRevisor
 
   # AVAILABLE OPTIONS:
   # - revised_at: changes the date of the revision
-  # - force_new_version: bypass ninja-edit window
+  # - force_new_version: bypass grace period edit window
   # - bypass_rate_limiter:
   # - bypass_bump: do not bump the topic, even if last post
   # - skip_validations: ask ActiveRecord to skip validations
@@ -156,7 +156,7 @@ class PostRevisor
     @revised_at = @opts[:revised_at] || Time.now
     @last_version_at = @post.last_version_at || Time.now
 
-    if guardian.affected_by_slow_mode?(@topic) && !ninja_edit? && SiteSetting.slow_mode_prevents_editing
+    if guardian.affected_by_slow_mode?(@topic) && !grace_period_edit? && SiteSetting.slow_mode_prevents_editing
       @post.errors.add(:base, I18n.t("cannot_edit_on_slow_mode"))
       return false
     end
@@ -283,7 +283,7 @@ class PostRevisor
 
   def should_create_new_version?
     return false if @skip_revision
-    edited_by_another_user? || !ninja_edit? || owner_changed? || force_new_version? || edit_reason_specified?
+    edited_by_another_user? || !grace_period_edit? || owner_changed? || force_new_version? || edit_reason_specified?
   end
 
   def edit_reason_specified?
@@ -332,7 +332,7 @@ class PostRevisor
     end
   end
 
-  def ninja_edit?
+  def grace_period_edit?
     return false if (@revised_at - @last_version_at) > SiteSetting.editing_grace_period.to_i
     return false if @post.reviewable_flag.present?
 
diff --git a/spec/components/post_revisor_spec.rb b/spec/components/post_revisor_spec.rb
index f8a76be..d3b0f22 100644
--- a/spec/components/post_revisor_spec.rb
+++ b/spec/components/post_revisor_spec.rb
@@ -178,7 +178,7 @@ describe PostRevisor do
         expect(post.errors.messages[:base].first).to be I18n.t("cannot_edit_on_slow_mode")
       end
 
-      it 'ninja editing is allowed' do
+      it 'grace period editing is allowed' do
         SiteSetting.editing_grace_period = 1.minute
 
         subject.revise!(post.user, { raw: 'updated body' }, revised_at: post.updated_at + 10.seconds)
@@ -208,7 +208,7 @@ describe PostRevisor do
       end
     end
 
-    describe 'ninja editing' do
+    describe 'grace period editing' do
       it 'correctly applies edits' do
         SiteSetting.editing_grace_period = 1.minute
 
@@ -608,7 +608,7 @@ describe PostRevisor do
 
       context 'second poster posts again quickly' do
 
-        it 'is a ninja edit, because the second poster posted again quickly' do
+        it 'is a grace period edit, because the second poster posted again quickly' do
           SiteSetting.editing_grace_period = 1.minute
           subject.revise!(changed_by, { raw: 'yet another updated body' }, revised_at: post.updated_at + 10.seconds)
           post.reload
@@ -1178,7 +1178,7 @@ describe PostRevisor do
       expect { revisor.revise!(admin, { raw: 'updated body' }) }.to change(ReviewablePost, :count).by(0)
     end
 
-    it 'skips ninja edits' do
+    it 'skips grace period edits' do
       SiteSetting.editing_grace_period = 1.minute
 
       expect {
diff --git a/spec/models/group_spec.rb b/spec/models/group_spec.rb
index a70bae1..5da7ff6 100644
--- a/spec/models/group_spec.rb
+++ b/spec/models/group_spec.rb
@@ -367,7 +367,7 @@ describe Group do
     expect(real_admins).to be_empty
     expect(real_staff).to eq []
 
-    # we need some ninja work to set min username to 6
+    # we need some work to set min username to 6
 
     User.where('length(username) < 6').each do |u|
       u.username = u.username + "ZZZZZZ"
diff --git a/spec/models/post_spec.rb b/spec/models/post_spec.rb
index d9c3369..5c5eb12 100644
--- a/spec/models/post_spec.rb
+++ b/spec/models/post_spec.rb
@@ -692,7 +692,7 @@ describe Post do
 
     end
 
-    describe 'ninja editing & edit windows' do
+    describe 'grace period editing & edit windows' do
 
       before { SiteSetting.editing_grace_period = 1.minute.to_i }
 
@@ -700,7 +700,7 @@ describe Post do
         revised_at = post.updated_at + 2.minutes
         new_revised_at = revised_at + 2.minutes
 
-        # ninja edit
+        # grace period edit
         post.revise(post.user, { raw: 'updated body' }, revised_at: post.updated_at + 10.seconds)
         post.reload
         expect(post.version).to eq(1)
@@ -760,7 +760,7 @@ describe Post do
 
       context 'second poster posts again quickly' do
 
-        it 'is a ninja edit, because the second poster posted again quickly' do
+        it 'is a grace period edit, because the second poster posted again quickly' do
           SiteSetting.editing_grace_period = 1.minute.to_i
           post.revise(changed_by, { raw: 'yet another updated body' }, revised_at: post.updated_at + 10.seconds)
           post.reload

GitHub sha: 59582102d816bee5746c4b93393a65f273a6927a

This commit appears in #13598 which was approved by SamSaffron. It was merged by martin.