DEV: Improve specs to be more specific about what has changed

DEV: Improve specs to be more specific about what has changed.

From d298f000464fdf10894c4e87714ac4766f12c170 Mon Sep 17 00:00:00 2001
From: Guo Xiang Tan <tgx_world@hotmail.com>
Date: Thu, 22 Nov 2018 10:10:07 +0800
Subject: [PATCH] DEV: Improve specs to be more specific about what has
 changed.


diff --git a/spec/services/user_updater_spec.rb b/spec/services/user_updater_spec.rb
index 49e3023..bbec1f0 100644
--- a/spec/services/user_updater_spec.rb
+++ b/spec/services/user_updater_spec.rb
@@ -295,10 +295,15 @@ describe UserUpdater do
     it "logs the action" do
       user_without_name = Fabricate(:user, name: nil)
       user = Fabricate(:user, name: 'Billy Bob')
+
       expect do
         UserUpdater.new(acting_user, user).update(name: 'Jim Tom')
       end.to change { UserHistory.count }.by(1)
 
+      expect(UserHistory.last.action).to eq(
+        UserHistory.actions[:change_name]
+      )
+
       expect do
         UserUpdater.new(acting_user, user).update(name: 'JiM TOm')
       end.to_not change { UserHistory.count }
@@ -311,9 +316,17 @@ describe UserUpdater do
         UserUpdater.new(acting_user, user_without_name).update(name: 'Jim Tom')
       end.to change { UserHistory.count }.by(1)
 
+      expect(UserHistory.last.action).to eq(
+        UserHistory.actions[:change_name]
+      )
+
       expect do
         UserUpdater.new(acting_user, user).update(name: '')
       end.to change { UserHistory.count }.by(1)
+
+      expect(UserHistory.last.action).to eq(
+        UserHistory.actions[:change_name]
+      )
     end
   end
 end
diff --git a/spec/services/username_changer_spec.rb b/spec/services/username_changer_spec.rb
index 87e5da2..0476615 100644
--- a/spec/services/username_changer_spec.rb
+++ b/spec/services/username_changer_spec.rb
@@ -45,6 +45,10 @@ describe UsernameChanger do
           expect(UsernameChanger.change(myself, "HanSolo", myself)).to eq(true)
         end.to change { UserHistory.count }.by(1)
 
+        expect(UserHistory.last.action).to eq(
+          UserHistory.actions[:change_username]
+        )
+
         expect(myself.reload.username).to eq('HanSolo')
 
         expect do

GitHub