- Docker
- Docker Compose
- Clone the project
$ git clone git@github.com:mikkotan/merchant-portal.git
- Change directory
$ cd merchant-portal
- Create .env file from .sample.env
$ cp .sample.env .env
- Open .env file and setup env variables
POSTGRES_USER=root
POSTGRES_PASSWORD=root
DATABASE_HOST=db
RSWAG_USERNAME=admin
RSWAG_PASSWORD=admin
SWAGGER_URL=http://localhost:3000
SWAGGER_DEFAULT_HOST=localhost:3000
- Build with docker
$ docker-compose build
- Setup database
$ docker-compose run --rm web bundle exec rails db:setup
- Run rspec
$ docker-compose run --rm web bundle exec rspec
- Run containers
$ docker-compose up -d
- Open SwaggerUI in
http://localhost:3000/api-docs
and use credentials from step 5
- ruby-3.2.2
- Rails 7.1.3
- PostgreSQL (latest)
- Clone the project
$ git clone git@github.com:mikkotan/merchant-portal.git
- Change directory
$ cd merchant-portal
- Install dependencies
$ bundle install
- Create .env file from .sample.env
$ cp .sample.env .env
- Open .env file and setup env variables (This connects to your local pg instance, make sure to update variables accordingly)
POSTGRES_USER=root
POSTGRES_PASSWORD=root
DATABASE_HOST=localhost
RSWAG_USERNAME=admin
RSWAG_PASSWORD=admin
SWAGGER_URL=http://localhost:3000
SWAGGER_DEFAULT_HOST=localhost:3000
- Setup database
$ rails db:setup
- Run specs
$ bundle exec rspec
- Run rails server
$ rails s
- Open SwaggerUI in
http://localhost:3000/api-docs
and use rswag credentials in step 5
For api documentation, navigate to http://localhost:3000/api-docs
- Staff User ID:
450f9854-ab1f-4c04-94f2-a651fda030dc
- Merchant User A ID:
cd7f33cb-c483-451d-b995-1730b2a580cd
- (Belongs to MerchantA) - Merchant User B ID:
58894254-b0a7-4550-a42a-f774ceb4512d
- (Belongs to MerchantB) - Merchant A ID:
10452350-147e-1234-a15b-503ba451f379
- Merchant B ID:
1bde0977-e3b2-2222-8c7c-fe3a7cbb98bb
- Pipelines IDs
004acfe5-4334-1234-9498-28add7f4674a
- active for MerchantAcd8469d7-3daf-43dd-9ee5-1966ba53db89
- active for MerchantB004acfe5-4334-5678-9498-28add7f4674a
ede3a8f9-4fd5-4a44-8d36-4077b3a82211
829ca84f-9000-43df-a572-7dd13b1a22f8
Curl commands
Using Staff User as current user
GET /api/v1/merchants
200 - Staff User queries for merchants for context of MerchantUserA
curl -X 'GET' \
'http://localhost:3000/api/v1/merchants?user_id=cd7f33cb-c483-451d-b995-1730b2a580cd' \
-H 'accept: application/json' \
-H 'access-token: 450f9854-ab1f-4c04-94f2-a651fda030dc'
401 Unauthorized Request - Invalid access-token
curl -X 'GET' \
'http://localhost:3000/api/v1/merchants?user_id=cd7f33cb-c483-451d-b995-1730b2a580cd' \
-H 'accept: application/json' \
-H 'access-token: 450f9854-ab1f-4c04-94f2-a651fda030d1'
GET /api/v1/pipelines
200 - Staff User queries for pipelines for context of MerchantUserA for MerchantA
curl -X 'GET' \
'http://localhost:3000/api/v1/pipelines?user_id=cd7f33cb-c483-451d-b995-1730b2a580cd&merchant_id=10452350-147e-1234-a15b-503ba451f379' \
-H 'accept: application/json' \
-H 'access-token: 450f9854-ab1f-4c04-94f2-a651fda030dc'
200 - Staff User queries for active pipeline for context of MerchantUserA for MerchantA
curl -X 'GET' \
'http://localhost:3000/api/v1/pipelines?user_id=cd7f33cb-c483-451d-b995-1730b2a580cd&merchant_id=10452350-147e-1234-a15b-503ba451f379&active=false' \
-H 'accept: application/json' \
-H 'access-token: 450f9854-ab1f-4c04-94f2-a651fda030dc'
200 but empty - Staff User queries for active pipelines for context of MerchantUserB for MerchantA (MerchantUserB does not belong to MerchantA, so result will be empty)
curl -X 'GET' \
'http://localhost:3000/api/v1/pipelines?user_id=58894254-b0a7-4550-a42a-f774ceb4512d&merchant_id=10452350-147e-1234-a15b-503ba451f379&active=true' \
-H 'accept: application/json' \
-H 'access-token: 450f9854-ab1f-4c04-94f2-a651fda030dc'
GET /api/v1/pipelines/:id
200 - Pipeline exists
curl -X 'GET' \
'http://localhost:3000/api/v1/pipelines/ede3a8f9-4fd5-4a44-8d36-4077b3a82211' \
-H 'accept: application/json' \
-H 'access-token: 450f9854-ab1f-4c04-94f2-a651fda030dc'
404 - Pipeline does not exists
curl -X 'GET' \
'http://localhost:3000/api/v1/pipelines/ede3a8f9-4fd5-4a44-8d36-4077b3a8221a' \
-H 'accept: application/json' \
-H 'access-token: 450f9854-ab1f-4c04-94f2-a651fda030dc'
Using Merchant User as current user
GET /api/v1/merchants
200 - MerchantUserA queries for merchant list for himself
curl -X 'GET' \
'http://localhost:3000/api/v1/merchants?user_id=cd7f33cb-c483-451d-b995-1730b2a580cd' \
-H 'accept: application/json' \
-H 'access-token: cd7f33cb-c483-451d-b995-1730b2a580cd'
403 - MerchantUserA queries for merchant list for another user
curl -X 'GET' \
'http://localhost:3000/api/v1/merchants?user_id=58894254-b0a7-4550-a42a-f774ceb4512d' \
-H 'accept: application/json' \
-H 'access-token: cd7f33cb-c483-451d-b995-1730b2a580cd'
GET /api/v1/pipelines
200 - MerchantUserA queries for pipelines for MerchantA
curl -X 'GET' \
'http://localhost:3000/api/v1/pipelines?user_id=cd7f33cb-c483-451d-b995-1730b2a580cd&merchant_id=10452350-147e-1234-a15b-503ba451f379' \
-H 'accept: application/json' \
-H 'access-token: cd7f33cb-c483-451d-b995-1730b2a580cd'
200 - MerchantUserA queries for active pipelines for MerchantA
curl -X 'GET' \
'http://localhost:3000/api/v1/pipelines?user_id=cd7f33cb-c483-451d-b995-1730b2a580cd&merchant_id=10452350-147e-1234-a15b-503ba451f379&active=true' \
-H 'accept: application/json' \
-H 'access-token: cd7f33cb-c483-451d-b995-1730b2a580cd'
403 - MerchantUserA queries for pipelines for another user for MerchantA
curl -X 'GET' \
'http://localhost:3000/api/v1/pipelines?user_id=58894254-b0a7-4550-a42a-f774ceb4512d&merchant_id=10452350-147e-1234-a15b-503ba451f379&active=true' \
-H 'accept: application/json' \
-H 'access-token: cd7f33cb-c483-451d-b995-1730b2a580cd'
403 - MerchantUserA queries for pipelines from another Merchant
curl -X 'GET' \
'http://localhost:3000/api/v1/pipelines?user_id=cd7f33cb-c483-451d-b995-1730b2a580cd&merchant_id=1bde0977-e3b2-2222-8c7c-fe3a7cbb98bb&active=true' \
-H 'accept: application/json' \
-H 'access-token: cd7f33cb-c483-451d-b995-1730b2a580cd'
GET /api/v1/pipelines/:id
200 - Pipeline exists
curl -X 'GET' \
'http://localhost:3000/api/v1/pipelines/ede3a8f9-4fd5-4a44-8d36-4077b3a82211' \
-H 'accept: application/json' \
-H 'access-token: cd7f33cb-c483-451d-b995-1730b2a580cd'
404 - Pipeline does not exists
curl -X 'GET' \
'http://localhost:3000/api/v1/pipelines/ede3a8f9-4fd5-4a44-8d36-4077b3a8221a' \
-H 'accept: application/json' \
-H 'access-token: cd7f33cb-c483-451d-b995-1730b2a580cd'