bde7d33949
#309 #309 #309 #309 #309 Merge remote-tracking branch 'origin/main' into feature/309 #309 Co-authored-by: miteruzo <miteruzo@naver.com> Reviewed-on: #319
75 lines
1.7 KiB
Ruby
75 lines
1.7 KiB
Ruby
require 'rails_helper'
|
|
|
|
RSpec.describe VersionRecord, type: :model do
|
|
let!(:tag) { create(:tag, name: 'version_record_tag') }
|
|
let!(:nico_tag) { create(:tag, :nico, name: 'nico:version_record_tag') }
|
|
|
|
it 'makes TagVersion read only after create' do
|
|
version = TagVersion.create!(
|
|
tag: tag,
|
|
version_no: 1,
|
|
event_type: 'create',
|
|
name: tag.name,
|
|
category: tag.category,
|
|
aliases: '',
|
|
parent_tag_ids: '',
|
|
created_at: Time.current,
|
|
created_by_user: nil
|
|
)
|
|
|
|
expect {
|
|
version.update!(name: 'changed')
|
|
}.to raise_error(ActiveRecord::ReadOnlyRecord)
|
|
end
|
|
|
|
it 'prevents TagVersion destroy' do
|
|
version = TagVersion.create!(
|
|
tag: tag,
|
|
version_no: 1,
|
|
event_type: 'create',
|
|
name: tag.name,
|
|
category: tag.category,
|
|
aliases: '',
|
|
parent_tag_ids: '',
|
|
created_at: Time.current,
|
|
created_by_user: nil
|
|
)
|
|
|
|
expect {
|
|
version.destroy!
|
|
}.to raise_error(ActiveRecord::ReadOnlyRecord)
|
|
end
|
|
|
|
it 'makes NicoTagVersion read only after create' do
|
|
version = NicoTagVersion.create!(
|
|
tag: nico_tag,
|
|
version_no: 1,
|
|
event_type: 'create',
|
|
name: nico_tag.name,
|
|
linked_tags: '',
|
|
created_at: Time.current,
|
|
created_by_user: nil
|
|
)
|
|
|
|
expect {
|
|
version.update!(name: 'nico:changed')
|
|
}.to raise_error(ActiveRecord::ReadOnlyRecord)
|
|
end
|
|
|
|
it 'prevents NicoTagVersion destroy' do
|
|
version = NicoTagVersion.create!(
|
|
tag: nico_tag,
|
|
version_no: 1,
|
|
event_type: 'create',
|
|
name: nico_tag.name,
|
|
linked_tags: '',
|
|
created_at: Time.current,
|
|
created_by_user: nil
|
|
)
|
|
|
|
expect {
|
|
version.destroy!
|
|
}.to raise_error(ActiveRecord::ReadOnlyRecord)
|
|
end
|
|
end
|