DEV: Improve specs to be more specific about what has changed.
This commit is contained in:
parent
a3f8ef89a6
commit
d298f00046
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue