feat: Add support to uncategorized articles (#6912)

This commit is contained in:
Tejaswini Chile
2023-05-02 15:35:26 +05:30
committed by GitHub
parent c8041392dc
commit 847d7ea082
18 changed files with 103 additions and 46 deletions

View File

@@ -9,6 +9,7 @@ RSpec.describe 'Public Articles API', type: :request do
let!(:article) { create(:article, category: category, portal: portal, account_id: account.id, author_id: agent.id) }
before do
ENV['HELPCENTER_URL'] = ENV.fetch('FRONTEND_URL', nil)
create(:article, category: category, portal: portal, account_id: account.id, author_id: agent.id)
create(:article, category: category, portal: portal, account_id: account.id, author_id: agent.id, associated_article_id: article.id)
create(:article, category: category_2, portal: portal, account_id: account.id, author_id: agent.id, associated_article_id: article.id)
@@ -17,7 +18,7 @@ RSpec.describe 'Public Articles API', type: :request do
describe 'GET /public/api/v1/portals/:slug/articles' do
it 'Fetch all articles in the portal' do
get "/hc/#{portal.slug}/#{category.locale}/#{category.slug}/articles"
get "/hc/#{portal.slug}/#{category.locale}/categories/#{category.slug}/articles"
expect(response).to have_http_status(:success)
end
@@ -31,7 +32,7 @@ RSpec.describe 'Public Articles API', type: :request do
content: 'this is some test and funny content')
expect(article2.id).not_to be_nil
get "/hc/#{portal.slug}/#{category.locale}/#{category.slug}/articles",
get "/hc/#{portal.slug}/#{category.locale}/categories/#{category.slug}/articles",
headers: agent.create_new_auth_token,
params: { query: 'funny' }
expect(response).to have_http_status(:success)
@@ -40,14 +41,14 @@ RSpec.describe 'Public Articles API', type: :request do
describe 'GET /public/api/v1/portals/:slug/articles/:id' do
it 'Fetch article with the id' do
get "/hc/#{portal.slug}/#{category.locale}/#{category.slug}/#{article.id}"
get "/hc/#{portal.slug}/articles/#{article.slug}"
expect(response).to have_http_status(:success)
expect(article.reload.views).to eq 1
end
it 'returns the article with the id with a different locale' do
article_in_locale = create(:article, category: category_2, portal: portal, account_id: account.id, author_id: agent.id)
get "/hc/#{portal.slug}/#{category_2.locale}/#{category_2.slug}/#{article_in_locale.id}"
get "/hc/#{portal.slug}/articles/#{article_in_locale.slug}"
expect(response).to have_http_status(:success)
end
end

View File

@@ -12,7 +12,9 @@ RSpec.describe 'Public Categories API', type: :request do
describe 'GET /public/api/v1/portals/:portal_slug/categories' do
it 'Fetch all categories in the portal' do
get "/hc/#{portal.slug}/categories"
category = portal.categories.first
get "/hc/#{portal.slug}/#{category.locale}/categories"
expect(response).to have_http_status(:success)
end
@@ -20,9 +22,9 @@ RSpec.describe 'Public Categories API', type: :request do
describe 'GET /public/api/v1/portals/:portal_slug/categories/:slug' do
it 'Fetch category with the slug' do
category_locale = 'en'
category = portal.categories.first
get "/hc/#{portal.slug}/#{category_locale}/categories"
get "/hc/#{portal.slug}/#{category.locale}/categories/#{category.slug}"
expect(response).to have_http_status(:success)
end