spec: fix missing metadata attribute
parent
ad747791d9
commit
038a0d20cb
|
@ -7,7 +7,7 @@ RSpec.describe Rating::Rate, ':create' do
|
||||||
let!(:article) { create :article }
|
let!(:article) { create :article }
|
||||||
|
|
||||||
context 'with no scopeable' do
|
context 'with no scopeable' do
|
||||||
before { described_class.create author: author, resource: article, value: 3 }
|
before { described_class.create author: author, metadata: {}, resource: article, value: 3 }
|
||||||
|
|
||||||
context 'when rate does not exist yet' do
|
context 'when rate does not exist yet' do
|
||||||
it 'creates a rate entry' do
|
it 'creates a rate entry' do
|
||||||
|
@ -32,7 +32,7 @@ RSpec.describe Rating::Rate, ':create' do
|
||||||
context 'when rate already exists' do
|
context 'when rate already exists' do
|
||||||
let!(:author_2) { create :author }
|
let!(:author_2) { create :author }
|
||||||
|
|
||||||
before { described_class.create author: author_2, resource: article, value: 4 }
|
before { described_class.create author: author_2, metadata: {}, resource: article, value: 4 }
|
||||||
|
|
||||||
it 'creates one more rate entry' do
|
it 'creates one more rate entry' do
|
||||||
rates = described_class.where(author: [author, author_2]).order('created_at asc')
|
rates = described_class.where(author: [author, author_2]).order('created_at asc')
|
||||||
|
@ -67,7 +67,7 @@ RSpec.describe Rating::Rate, ':create' do
|
||||||
context 'with scopeable' do
|
context 'with scopeable' do
|
||||||
let!(:category) { create :category }
|
let!(:category) { create :category }
|
||||||
|
|
||||||
before { described_class.create author: author, resource: article, scopeable: category, value: 3 }
|
before { described_class.create author: author, metadata: {}, resource: article, scopeable: category, value: 3 }
|
||||||
|
|
||||||
context 'when rate does not exist yet' do
|
context 'when rate does not exist yet' do
|
||||||
it 'creates a rate entry' do
|
it 'creates a rate entry' do
|
||||||
|
@ -94,7 +94,7 @@ RSpec.describe Rating::Rate, ':create' do
|
||||||
context 'when rate already exists' do
|
context 'when rate already exists' do
|
||||||
let!(:author_2) { create :author }
|
let!(:author_2) { create :author }
|
||||||
|
|
||||||
before { described_class.create author: author_2, resource: article, scopeable: category, value: 4 }
|
before { described_class.create author: author_2, metadata: {}, resource: article, scopeable: category, value: 4 }
|
||||||
|
|
||||||
it 'creates one more rate entry' do
|
it 'creates one more rate entry' do
|
||||||
rates = described_class.where(author: [author, author_2]).order('created_at asc')
|
rates = described_class.where(author: [author, author_2]).order('created_at asc')
|
||||||
|
@ -130,8 +130,6 @@ RSpec.describe Rating::Rate, ':create' do
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'with metadata' do
|
context 'with metadata' do
|
||||||
before { AddCommentOnRatingRatesTable.new.change }
|
|
||||||
|
|
||||||
context 'with nil value' do
|
context 'with nil value' do
|
||||||
it 'creates a rate entry ignoring metadata' do
|
it 'creates a rate entry ignoring metadata' do
|
||||||
described_class.create author: author, metadata: nil, resource: article, value: 3
|
described_class.create author: author, metadata: nil, resource: article, value: 3
|
||||||
|
|
|
@ -12,7 +12,7 @@ RSpec.describe Rating::Rate, ':rate_for' do
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when rate does not exist' do
|
context 'when rate does not exist' do
|
||||||
before { described_class.create author: author, resource: article, value: 3 }
|
before { described_class.create author: author, metadata: {}, resource: article, value: 3 }
|
||||||
|
|
||||||
it 'returns the record' do
|
it 'returns the record' do
|
||||||
expect(described_class.rate_for(author: author, resource: article)).to eq described_class.last
|
expect(described_class.rate_for(author: author, resource: article)).to eq described_class.last
|
||||||
|
@ -28,7 +28,7 @@ RSpec.describe Rating::Rate, ':rate_for' do
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when rate does not exist' do
|
context 'when rate does not exist' do
|
||||||
before { described_class.create author: author, resource: article, scopeable: category, value: 3 }
|
before { described_class.create author: author, metadata: {}, resource: article, scopeable: category, value: 3 }
|
||||||
|
|
||||||
it 'returns the record' do
|
it 'returns the record' do
|
||||||
query = described_class.rate_for(author: author, resource: article, scopeable: category)
|
query = described_class.rate_for(author: author, resource: article, scopeable: category)
|
||||||
|
|
|
@ -8,3 +8,4 @@ CreateArticlesTable.new.change
|
||||||
CreateAuthorsTable.new.change
|
CreateAuthorsTable.new.change
|
||||||
CreateCategoriesTable.new.change
|
CreateCategoriesTable.new.change
|
||||||
CreateRatingTables.new.change
|
CreateRatingTables.new.change
|
||||||
|
AddCommentOnRatingRatesTable.new.change
|
||||||
|
|
Loading…
Reference in New Issue