feat: Portal and Category public APIs (#4946)
This commit is contained in:
@@ -35,6 +35,7 @@ RSpec.describe 'Api::V1::Accounts::Articles', type: :request do
|
||||
expect(response).to have_http_status(:success)
|
||||
json_response = JSON.parse(response.body)
|
||||
expect(json_response['payload']['title']).to eql('MyTitle')
|
||||
expect(json_response['payload']['status']).to eql('draft')
|
||||
end
|
||||
|
||||
it 'associate to the root article' do
|
||||
@@ -100,10 +101,11 @@ RSpec.describe 'Api::V1::Accounts::Articles', type: :request do
|
||||
end
|
||||
|
||||
context 'when it is an authenticated user' do
|
||||
it 'updates category' do
|
||||
it 'updates article' do
|
||||
article_params = {
|
||||
article: {
|
||||
title: 'MyTitle2',
|
||||
status: 'published',
|
||||
description: 'test_description'
|
||||
}
|
||||
}
|
||||
@@ -116,6 +118,7 @@ RSpec.describe 'Api::V1::Accounts::Articles', type: :request do
|
||||
expect(response).to have_http_status(:success)
|
||||
json_response = JSON.parse(response.body)
|
||||
expect(json_response['payload']['title']).to eql(article_params[:article][:title])
|
||||
expect(json_response['payload']['status']).to eql(article_params[:article][:status])
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe 'Public Categories API', type: :request do
|
||||
let!(:account) { create(:account) }
|
||||
let!(:portal) { create(:portal, slug: 'test-portal') }
|
||||
|
||||
before do
|
||||
create(:category, slug: 'test-category-1', portal_id: portal.id, account_id: account.id)
|
||||
create(:category, slug: 'test-category-2', portal_id: portal.id, account_id: account.id)
|
||||
create(:category, slug: 'test-category-3', portal_id: portal.id, account_id: account.id)
|
||||
end
|
||||
|
||||
describe 'GET /public/api/v1/portals/:portal_slug/categories' do
|
||||
it 'Fetch all categories in the portal' do
|
||||
get "/public/api/v1/portals/#{portal.slug}/categories"
|
||||
|
||||
expect(response).to have_http_status(:success)
|
||||
json_response = JSON.parse(response.body)
|
||||
|
||||
expect(json_response['payload'].length).to eql portal.categories.count
|
||||
end
|
||||
end
|
||||
|
||||
describe 'GET /public/api/v1/portals/:portal_slug/categories/:slug' do
|
||||
it 'Fetch category with the slug' do
|
||||
category_slug = 'test-category-3'
|
||||
|
||||
get "/public/api/v1/portals/#{portal.slug}/categories/#{category_slug}"
|
||||
|
||||
expect(response).to have_http_status(:success)
|
||||
json_response = JSON.parse(response.body)
|
||||
|
||||
expect(json_response['slug']).to eql category_slug
|
||||
end
|
||||
end
|
||||
end
|
||||
21
spec/controllers/public/api/v1/portals_controller_spec.rb
Normal file
21
spec/controllers/public/api/v1/portals_controller_spec.rb
Normal file
@@ -0,0 +1,21 @@
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe 'Public Portals API', type: :request do
|
||||
let!(:account) { create(:account) }
|
||||
let!(:portal) { create(:portal, slug: 'test-portal', account_id: account.id) }
|
||||
|
||||
before do
|
||||
create(:portal, slug: 'test-portal-1', account_id: account.id)
|
||||
create(:portal, slug: 'test-portal-2', account_id: account.id)
|
||||
end
|
||||
|
||||
describe 'GET /public/api/v1/portals/{portal_slug}' do
|
||||
it 'Show portal and categories belonging to the portal' do
|
||||
get "/public/api/v1/portals/#{portal.slug}"
|
||||
|
||||
expect(response).to have_http_status(:success)
|
||||
json_response = JSON.parse(response.body)
|
||||
expect(json_response['slug']).to eql 'test-portal'
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user