This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
RSpec.describe PostTag, type: :model do
|
||||
describe '#sections' do
|
||||
it 'loads sections by post_id and tag_id' do
|
||||
post_tag = create(:post_tag)
|
||||
section = create(:post_tag_section,
|
||||
post: post_tag.post,
|
||||
tag: post_tag.tag,
|
||||
begin_ms: 1000,
|
||||
end_ms: 2000)
|
||||
|
||||
expect(post_tag.sections).to contain_exactly(section)
|
||||
end
|
||||
|
||||
it 'does not load sections for another tag on the same post' do
|
||||
post = create(:post)
|
||||
tag = create(:tag)
|
||||
other_tag = create(:tag)
|
||||
|
||||
post_tag = create(:post_tag, post:, tag:)
|
||||
create(:post_tag_section,
|
||||
post:,
|
||||
tag: other_tag,
|
||||
begin_ms: 1000,
|
||||
end_ms: 2000)
|
||||
|
||||
expect(post_tag.sections).to be_empty
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user