fix: Add slug to articles (#5500)
This commit is contained in:
@@ -24,6 +24,7 @@ RSpec.describe 'Api::V1::Accounts::Articles', type: :request do
|
||||
category_id: category.id,
|
||||
description: 'test description',
|
||||
title: 'MyTitle',
|
||||
slug: 'my-title',
|
||||
content: 'This is my content.',
|
||||
status: :published,
|
||||
author_id: agent.id
|
||||
@@ -39,8 +40,9 @@ RSpec.describe 'Api::V1::Accounts::Articles', type: :request do
|
||||
end
|
||||
|
||||
it 'associate to the root article' do
|
||||
root_article = create(:article, category: category, portal: portal, account_id: account.id, author_id: agent.id, associated_article_id: nil)
|
||||
parent_article = create(:article, category: category, portal: portal, account_id: account.id, author_id: agent.id,
|
||||
root_article = create(:article, category: category, slug: 'root-article', portal: portal, account_id: account.id, author_id: agent.id,
|
||||
associated_article_id: nil)
|
||||
parent_article = create(:article, category: category, slug: 'parent-article', portal: portal, account_id: account.id, author_id: agent.id,
|
||||
associated_article_id: root_article.id)
|
||||
|
||||
article_params = {
|
||||
@@ -48,6 +50,7 @@ RSpec.describe 'Api::V1::Accounts::Articles', type: :request do
|
||||
category_id: category.id,
|
||||
description: 'test description',
|
||||
title: 'MyTitle',
|
||||
slug: 'MyTitle',
|
||||
content: 'This is my content.',
|
||||
status: :published,
|
||||
author_id: agent.id,
|
||||
@@ -73,6 +76,7 @@ RSpec.describe 'Api::V1::Accounts::Articles', type: :request do
|
||||
category_id: category.id,
|
||||
description: 'test description',
|
||||
title: 'MyTitle',
|
||||
slug: 'MyTitle',
|
||||
content: 'This is my content.',
|
||||
status: :published,
|
||||
author_id: agent.id,
|
||||
@@ -210,9 +214,9 @@ RSpec.describe 'Api::V1::Accounts::Articles', type: :request do
|
||||
|
||||
it 'get associated articles' do
|
||||
root_article = create(:article, category: category, portal: portal, account_id: account.id, author_id: agent.id, associated_article_id: nil)
|
||||
child_article_1 = create(:article, category: category, portal: portal, account_id: account.id, author_id: agent.id,
|
||||
child_article_1 = create(:article, slug: 'child-1', category: category, portal: portal, account_id: account.id, author_id: agent.id,
|
||||
associated_article_id: root_article.id)
|
||||
child_article_2 = create(:article, category: category, portal: portal, account_id: account.id, author_id: agent.id,
|
||||
child_article_2 = create(:article, slug: 'child-2', category: category, portal: portal, account_id: account.id, author_id: agent.id,
|
||||
associated_article_id: root_article.id)
|
||||
|
||||
get "/api/v1/accounts/#{account.id}/portals/#{portal.slug}/articles/#{root_article.id}",
|
||||
|
||||
@@ -4,6 +4,7 @@ FactoryBot.define do
|
||||
category_id { 1 }
|
||||
author_id { 1 }
|
||||
title { 'MyString' }
|
||||
slug { 'MyString' }
|
||||
content { 'MyText' }
|
||||
description { 'MyDescrption' }
|
||||
status { 1 }
|
||||
|
||||
@@ -25,13 +25,15 @@ RSpec.describe Article, type: :model do
|
||||
let!(:category_3) { create(:category, slug: 'category_3', locale: 'es', portal_id: portal_2.id) }
|
||||
|
||||
before do
|
||||
create(:article, category_id: category_1.id, content: 'This is the content', description: 'this is the description', title: 'this is title',
|
||||
create(:article, category_id: category_1.id, content: 'This is the content', description: 'this is the description',
|
||||
slug: 'this-is-title', title: 'this is title',
|
||||
portal_id: portal_1.id, author_id: user.id)
|
||||
create(:article, category_id: category_1.id, title: 'title 1', content: 'This is the content', portal_id: portal_1.id, author_id: user.id)
|
||||
create(:article, category_id: category_2.id, title: 'title 2', portal_id: portal_2.id, author_id: user.id)
|
||||
create(:article, category_id: category_2.id, title: 'title 3', portal_id: portal_1.id, author_id: user.id)
|
||||
create(:article, category_id: category_3.id, title: 'title 6', portal_id: portal_2.id, author_id: user.id, status: :published)
|
||||
create(:article, category_id: category_2.id, title: 'title 7', portal_id: portal_1.id, author_id: user.id, status: :published)
|
||||
create(:article, category_id: category_1.id, slug: 'title-1', title: 'title 1', content: 'This is the content', portal_id: portal_1.id,
|
||||
author_id: user.id)
|
||||
create(:article, category_id: category_2.id, slug: 'title-2', title: 'title 2', portal_id: portal_2.id, author_id: user.id)
|
||||
create(:article, category_id: category_2.id, slug: 'title-3', title: 'title 3', portal_id: portal_1.id, author_id: user.id)
|
||||
create(:article, category_id: category_3.id, slug: 'title-6', title: 'title 6', portal_id: portal_2.id, author_id: user.id, status: :published)
|
||||
create(:article, category_id: category_2.id, slug: 'title-7', title: 'title 7', portal_id: portal_1.id, author_id: user.id, status: :published)
|
||||
end
|
||||
|
||||
context 'when no parameters passed' do
|
||||
@@ -121,7 +123,7 @@ RSpec.describe Article, type: :model do
|
||||
|
||||
context 'with pagination' do
|
||||
it 'returns paginated articles' do
|
||||
create_list(:article, 30, category_id: category_2.id, title: 'title 1', portal_id: portal_2.id, author_id: user.id)
|
||||
create_list(:article, 30, category_id: category_2.id, slug: 'title-1', title: 'title 1', portal_id: portal_2.id, author_id: user.id)
|
||||
params = { category_slug: 'category_2' }
|
||||
records = portal_2.articles.search(params)
|
||||
expect(records.count).to eq(25)
|
||||
|
||||
Reference in New Issue
Block a user