DEV: Use AR enums in reviewables related code

This is the first patch of many to replace our custom enums in Ruby by
the ones provided by `ActiveRecord`.
This commit is contained in:
Loïc Guitaut
2021-12-08 18:12:24 +01:00
committed by Loïc Guitaut
parent 0c743a591f
commit 26fe047724
36 changed files with 220 additions and 228 deletions

View File

@@ -14,8 +14,8 @@ RSpec.describe ReviewableHistory, type: :model do
history = reviewable.history
expect(history.size).to eq(3)
expect(history[0].reviewable_history_type).to eq(ReviewableHistory.types[:created])
expect(history[0].status).to eq(Reviewable.statuses[:pending])
expect(history[0]).to be_created
expect(history[0]).to be_pending
expect(history[0].created_by).to eq(admin)
end
@@ -26,12 +26,12 @@ RSpec.describe ReviewableHistory, type: :model do
history = reviewable.history
expect(history.size).to eq(3)
expect(history[1].reviewable_history_type).to eq(ReviewableHistory.types[:transitioned])
expect(history[1].status).to eq(Reviewable.statuses[:approved])
expect(history[1]).to be_transitioned
expect(history[1]).to be_approved
expect(history[1].created_by).to eq(moderator)
expect(history[2].reviewable_history_type).to eq(ReviewableHistory.types[:transitioned])
expect(history[2].status).to eq(Reviewable.statuses[:pending])
expect(history[2]).to be_transitioned
expect(history[2]).to be_pending
expect(history[2].created_by).to eq(admin)
end
@@ -52,7 +52,7 @@ RSpec.describe ReviewableHistory, type: :model do
history = reviewable.history
expect(history.size).to eq(2)
expect(history[1].reviewable_history_type).to eq(ReviewableHistory.types[:edited])
expect(history[1]).to be_edited
expect(history[1].created_by).to eq(moderator)
expect(history[1].edited).to eq("category_id" => [old_category.id, nil])
end