diff --git a/Gemfile b/Gemfile index 2a9cdcb..126e35d 100644 --- a/Gemfile +++ b/Gemfile @@ -42,7 +42,8 @@ gem 'bootsnap', require: false # Use Rack CORS for handling Cross-Origin Resource Sharing (CORS), making cross-origin AJAX possible gem 'rack-cors' -gem 'rswag' +gem 'rswag-api' +gem 'rswag-ui' group :development, :test do # See https://guides.rubyonrails.org/debugging_rails_applications.html#debugging-with-the-debug-gem diff --git a/Gemfile.lock b/Gemfile.lock index 28db2ec..f725981 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -90,7 +90,6 @@ GEM warden (~> 1.2.3) diff-lcs (1.5.0) erubi (1.11.0) - ffi (1.15.5) ffi (1.15.5-x64-mingw-ucrt) globalid (1.0.0) activesupport (>= 5.0) @@ -125,15 +124,12 @@ GEM net-smtp (0.3.2) net-protocol nio4r (2.5.8) - nokogiri (1.13.8-arm64-darwin) - racc (~> 1.4) nokogiri (1.13.8-x64-mingw-ucrt) racc (~> 1.4) orm_adapter (0.5.0) parallel (1.22.1) parser (3.1.2.1) ast (~> 2.4.1) - pg (1.4.3) pg (1.4.3-x64-mingw-ucrt) public_suffix (5.0.0) puma (5.6.5) @@ -196,10 +192,6 @@ GEM rspec-mocks (~> 3.10) rspec-support (~> 3.10) rspec-support (3.11.1) - rswag (2.6.0) - rswag-api (= 2.6.0) - rswag-specs (= 2.6.0) - rswag-ui (= 2.6.0) rswag-api (2.6.0) railties (>= 3.1, < 7.1) rswag-specs (2.6.0) @@ -238,9 +230,7 @@ GEM zeitwerk (2.6.1) PLATFORMS - arm64-darwin-21 x64-mingw-ucrt - x86_64-linux DEPENDENCIES bootsnap @@ -255,8 +245,9 @@ DEPENDENCIES rack-cors rails (~> 7.0.4) rspec-rails - rswag + rswag-api rswag-specs + rswag-ui rubocop (>= 1.0, < 2.0) tzinfo-data diff --git a/README.md b/README.md index a38ed34..77ec9d3 100644 --- a/README.md +++ b/README.md @@ -2,10 +2,17 @@ - A friendly api to book vehicle reservations +![image](https://user-images.githubusercontent.com/94127418/194410472-85325ac9-67d0-4409-97cf-21090ccedc73.png) +![image](https://user-images.githubusercontent.com/94127418/194410576-8f1d6ae6-bcaa-4860-a31d-51b83b37e88c.png) + + ## LINK to front-end - This Project has a React Front-end you can work with > [React front-end](https://github.com/Fatima-hub333/appointment-diary-front-end) << open +## Backend API LIVE +> [API LIVE](https://book-vehicle.herokuapp.com/) + ### Built With - Ruby on Rails @@ -16,6 +23,14 @@ - API Swagger documentation - Bullet N + 1 queries +### Kanban Board +- [kanban](https://github.com/Fatima-hub333/appointment-diary/issues/56#issuecomment-1254172387) +- [Project]https://github.com/Fatima-hub333/appointment-diary-backend/tree/main) +- +🥇 We are a group of 3 people: + - @basem909 + - @kinginthenorthcodez + - @Fatima-hub333 > git clone - Move into project directory @@ -78,7 +93,8 @@ GitHub: @Fatima-hub333 - Feel free to check the issues page. -### [Api documentation]() +### [Api documentation](https://book-vehicle.herokuapp.com/) + > Note: To release latest 24-10-2022 @@ -87,4 +103,4 @@ GitHub: @Fatima-hub333 Give a ⭐️ if you like this project! 📝 License -This project is MIT licensed. +This project is [MIT](https://github.com/Fatima-hub333/appointment-diary-backend/blob/dev/license). diff --git a/app/controllers/api/v1/users_controller.rb b/app/controllers/api/v1/users_controller.rb index 1a471e8..512a5e5 100644 --- a/app/controllers/api/v1/users_controller.rb +++ b/app/controllers/api/v1/users_controller.rb @@ -1,7 +1,4 @@ class Api::V1::UsersController < ApplicationController - before_action :tokenized - before_action :authenticate_user! - def index @users = User.all render json: { status: 'Success', message: 'Loaded users', data: @users }, status: :ok diff --git a/app/controllers/api/v1/vehicles_controller.rb b/app/controllers/api/v1/vehicles_controller.rb index 6628f08..dd1e4f8 100644 --- a/app/controllers/api/v1/vehicles_controller.rb +++ b/app/controllers/api/v1/vehicles_controller.rb @@ -44,6 +44,6 @@ def set_vehicle end def vehicle_params - params.permit(:brand, :model, :price, :image, :description) + params.permit(:brand, :model, :price, :image, :visible, :description) end end diff --git a/app/controllers/home_controller.rb b/app/controllers/home_controller.rb new file mode 100644 index 0000000..ad5c0c6 --- /dev/null +++ b/app/controllers/home_controller.rb @@ -0,0 +1,5 @@ +class HomeController < ApplicationController + def index + redirect_to '/api-docs' + end +end diff --git a/app/controllers/users/omniauth_callbacks_controller.rb b/app/controllers/users/omniauth_callbacks_controller.rb index 49b8d1f..59b8c6b 100644 --- a/app/controllers/users/omniauth_callbacks_controller.rb +++ b/app/controllers/users/omniauth_callbacks_controller.rb @@ -1,4 +1,4 @@ -class User::OmniauthCallbacksController < Devise::OmniauthCallbacksController +class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController # You should configure your model like this: # devise :omniauthable, omniauth_providers: [:twitter] diff --git a/app/controllers/users/passwords_controller.rb b/app/controllers/users/passwords_controller.rb index d19306d..53cc34e 100644 --- a/app/controllers/users/passwords_controller.rb +++ b/app/controllers/users/passwords_controller.rb @@ -1,4 +1,4 @@ -class User::PasswordsController < Devise::PasswordsController +class Users::PasswordsController < Devise::PasswordsController # GET /resource/password/new # def new # super diff --git a/app/controllers/users/sessions_controller.rb b/app/controllers/users/sessions_controller.rb index bb4dc47..97370a8 100644 --- a/app/controllers/users/sessions_controller.rb +++ b/app/controllers/users/sessions_controller.rb @@ -22,7 +22,7 @@ def create def destroy @user = current_user if @user - render json: { status: 'Success', message: 'signed out', data: @user }, status: :ok + render json: { status: 'Success', message: 'signed out', data: @user }, status: 200 sign_out(@user) else render json: { status: 'Failed', message: 'There is no user to sign out' }, status: :unauthorized diff --git a/app/controllers/users/unlocks_controller.rb b/app/controllers/users/unlocks_controller.rb index aa0cef0..8b9ef86 100644 --- a/app/controllers/users/unlocks_controller.rb +++ b/app/controllers/users/unlocks_controller.rb @@ -1,4 +1,4 @@ -class User::UnlocksController < Devise::UnlocksController +class Users::UnlocksController < Devise::UnlocksController # GET /resource/unlock/new # def new # super diff --git a/app/models/user.rb b/app/models/user.rb index 316ba23..4b85ac2 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -2,7 +2,7 @@ class User < ApplicationRecord # Include default devise modules. Others available are: # :confirmable, :lockable, :trackable and :omniauthable devise :database_authenticatable, :registerable, - :recoverable, :rememberable, :validatable, :confirmable + :recoverable, :rememberable, :validatable before_create :generate_authentication_token diff --git a/app/models/vehicle.rb b/app/models/vehicle.rb index 5b872a4..b19b42d 100644 --- a/app/models/vehicle.rb +++ b/app/models/vehicle.rb @@ -1,5 +1,5 @@ class Vehicle < ApplicationRecord - validates :brand, :model, :description, :image, presence: true + validates :brand, :model, :description, :image, :visible, presence: true validates :price, numericality: { greater_than_or_equal_to: 0 } has_many :reservations, dependent: :destroy diff --git a/config/environments/production.rb b/config/environments/production.rb index 2542b8a..79a2fca 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -13,9 +13,6 @@ # and those relying on copy on write to perform better. # Rake tasks automatically ignore this option for performance. config.eager_load = true - config.action_mailer.default_url_options = { 'https://appointment-diary-backend.herokuapp.com/'} - config.action_mailer.delivery_method = :letter_opener - config.action_mailer.perform_deliveries = true # Full error reports are disabled and caching is turned on. config.consider_all_requests_local = false @@ -59,7 +56,6 @@ # Use a real queuing backend for Active Job (and separate queues per environment). # config.active_job.queue_adapter = :resque # config.active_job.queue_name_prefix = "appointment_diary_backend_production" - config.action_mailer.perform_caching = false # Ignore bad email addresses and do not raise email delivery errors. diff --git a/config/routes.rb b/config/routes.rb index 188a796..a308a15 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,6 +1,7 @@ # frozen_string_literal: true Rails.application.routes.draw do + root to: 'home#index' mount Rswag::Ui::Engine => '/api-docs' mount Rswag::Api::Engine => '/api-docs' devise_for :users, controllers: { diff --git a/db/migrate/20221004054904_add_visble_to_vehicle.rb b/db/migrate/20221004054904_add_visble_to_vehicle.rb new file mode 100644 index 0000000..753969a --- /dev/null +++ b/db/migrate/20221004054904_add_visble_to_vehicle.rb @@ -0,0 +1,5 @@ +class AddVisbleToVehicle < ActiveRecord::Migration[7.0] + def change + add_column :vehicles, :visible, :boolean + end +end diff --git a/db/schema.rb b/db/schema.rb index 8eaeddc..5d06cfb 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[7.0].define(version: 2022_09_28_200417) do +ActiveRecord::Schema[7.0].define(version: 2022_10_04_054904) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -52,6 +52,7 @@ t.text "description" t.datetime "created_at", null: false t.datetime "updated_at", null: false + t.boolean "visible" end add_foreign_key "reservations", "users" diff --git a/db/seeds.rb b/db/seeds.rb index 7d148cb..6a9219c 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -9,11 +9,9 @@ user1 = User.create!(name: 'John Doe', email: 'john123@gmail.com', password: 'test123', roles: ['admin']) user2 = User.create!(name: 'Jane Doe', email: 'jane123@gmail.com', password: 'test123', roles: ['admin']) -user1.confirm -user2.confirm -veh1 = Vehicle.create!(brand: 'BWM', model: 'BMW-30', image: 'image-bmw', price: 80, description: 'good and lightspeed with low consumptiom') -veh2 = Vehicle.create!(brand: 'Macendiz', model: 'Benz-30', image: 'image-Benz', price: 90, description: 'good and lightspeed with low consumptiom') -veh3 = Vehicle.create!(brand: 'G-Wagon', model: 'G-wagon-15', image: 'image-wagon', price: 95, description: 'good and lightspeed with low consumptiom') +veh1 = Vehicle.create!(brand: 'BWM', model: 'BMW-30', image: 'image-bmw', price: 80, visible: true, description: 'good and lightspeed with low consumptiom') +veh2 = Vehicle.create!(brand: 'Macendiz', model: 'Benz-30', image: 'image-Benz', price: 90, visible: true,description: 'good and lightspeed with low consumptiom') +veh3 = Vehicle.create!(brand: 'G-Wagon', model: 'G-wagon-15', image: 'image-wagon', price: 95, visible: true, description: 'good and lightspeed with low consumptiom') res1 = Reservation.create!(user: user1, vehicle: veh1, date: '24-09-2022', city: 'bravos') res1 = Reservation.create!(user: user2, vehicle: veh1,date: '24-09-2022', city: 'capetown') res1 = Reservation.create!(user: user2, vehicle: veh3,date: '24-09-2022', city: 'lusaka') diff --git a/license b/license new file mode 100644 index 0000000..8482e9e --- /dev/null +++ b/license @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2022 Isaac, Bassem and Fatima + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/spec/requests/api/v1/vehicles_spec.rb b/spec/requests/api/v1/vehicles_spec.rb index 972b12e..a49884f 100644 --- a/spec/requests/api/v1/vehicles_spec.rb +++ b/spec/requests/api/v1/vehicles_spec.rb @@ -26,6 +26,7 @@ model: 'Benz-30', price: '90.0', image: 'image-Benz', + visible: 'true', description: 'good and lightspeed with low consumptiom', created_at: '2022-10-01T04:51:07.296Z', updated_at: '2022-10-01T04:51:07.296Z' @@ -35,6 +36,7 @@ brand: 'G-Wagon', model: 'G-wagon-15', price: '95.0', + visible: 'true', image: 'image-wagon', description: 'good and lightspeed with low consumptiom', created_at: '2022-10-01T04:51:07.302Z', @@ -45,6 +47,7 @@ brand: 'Farari', model: 'BMW', price: '450.0', + visible: 'true', image: 'farari.png', description: 'Some text here', created_at: '2022-10-01T12:39:00.705Z', @@ -75,6 +78,7 @@ model: { type: :string }, image: { type: :string }, price: { type: :decimal }, + visible: { type: :boolean }, description: { type: :text } }, required: %w[authenticate_token brand model image price description] @@ -83,7 +87,7 @@ let(:params) do { authentication_token: User.last.authentication_token, brand: 'Mecedz', model: 'benz-30', image: 'image-bmw', - price: 80, description: 'good and lightspeed with low consumptiom' } + price: 80, visible: true, description: 'good and lightspeed with low consumptiom' } end example 'application/json', 'success', { status: 'Success', @@ -93,6 +97,7 @@ brand: 'G-Wagon', model: 'G-wagon-15', price: '95.0', + visible: 'true', image: 'image-wagon', description: 'good and lightspeed with low consumptiom', created_at: '2022-10-01T22:01:18.479Z', @@ -121,7 +126,7 @@ let(:params) { { authentication_token: User.first.authentication_token } } example 'application/json', 'success', { status: 'Success', message: 'Loaded vehicle', - data: { id: 4, brand: 'BWM', model: 'BMW-30', price: '80.0', + data: { id: 4, brand: 'BWM', model: 'BMW-30', price: '80.0', visible: 'true', image: 'image-bmw', description: 'good and lightspeed with low consumptiom', created_at: '2022-10-01T04:51:07.286Z', updated_at: '2022-10-01T04:51:07.286Z' } } @@ -144,11 +149,11 @@ let(:params) do { authentication_token: User.first.authentication_token, brand: 'Lambo', model: 'lambo-30', image: 'image-bmw', - price: 80, description: 'good and lightspeed with low consumptiom' } + price: 80, visible: true, description: 'good and lightspeed with low consumptiom' } end example 'application/json', 'success', { status: 'Success', message: 'Loaded vehicle', - data: { id: 4, brand: 'BWM', model: 'BMW-30', price: '80.0', + data: { id: 4, brand: 'BWM', model: 'BMW-30', price: '80.0', visible: 'true', image: 'image-bmw', description: 'good and lightspeed with low consumptiom', created_at: '2022-10-01T04:51:07.286Z', updated_at: '2022-10-01T04:51:07.286Z' } } @@ -171,11 +176,11 @@ let(:params) do { authentication_token: User.first.authentication_token, brand: 'Lambo', model: 'lambo-30', image: 'image-bmw', - price: 80, description: 'good and lightspeed with low consumptiom' } + price: 80, visible: true, description: 'good and lightspeed with low consumptiom' } end example 'application/json', 'success', { status: 'Success', message: 'Loaded vehicle', - data: { id: 4, brand: 'BWM', model: 'BMW-30', price: '80.0', + data: { id: 4, brand: 'BWM', model: 'BMW-30', price: '80.0', visible: 'true', image: 'image-bmw', description: 'good and lightspeed with low consumptiom', created_at: '2022-10-01T04:51:07.286Z', updated_at: '2022-10-01T04:51:07.286Z' } } @@ -199,7 +204,7 @@ example 'application/json', 'success', { status: 'Success', message: 'Loaded vehicle', data: { id: 4, - brand: 'BWM', model: 'BMW-30', price: '80.0', + brand: 'BWM', model: 'BMW-30', price: '80.0', visible: 'true', image: 'image-bmw', description: 'good and lightspeed with low consumptiom', created_at: '2022-10-01T04:51:07.286Z', updated_at: '2022-10-01T04:51:07.286Z' } } diff --git a/spec/requests/login_spec.rb b/spec/requests/login_spec.rb index 88e98a6..ce15e6f 100644 --- a/spec/requests/login_spec.rb +++ b/spec/requests/login_spec.rb @@ -3,9 +3,7 @@ RSpec.describe 'users/sign_in', type: :request do context 'sign_in' do before(:each) do - Rails.application.load_seed - User.find_by(email: 'john@gmail.com').confirm - post user_session_path, params: { email: 'john@gmail.com', password: 'test123' } + post user_session_path, params: { email: 'john123@gmail.com', password: 'test123' } end it 'Responds with ok status' do puts response @@ -18,7 +16,7 @@ end it 'Responds data has the email of the user signed in' do data = JSON.parse(response.body)['data'] - expect(data['email']).to eq('john@gmail.com') + expect(data['email']).to eq('john123@gmail.com') end end end diff --git a/spec/requests/reservation_spec.rb b/spec/requests/reservation_spec.rb index 9c8d786..a0f5351 100644 --- a/spec/requests/reservation_spec.rb +++ b/spec/requests/reservation_spec.rb @@ -3,8 +3,6 @@ RSpec.describe '/api/v1/reservation', type: :request do context 'Create Reservation ' do before(:each) do - Rails.application.load_seed - User.first.confirm get api_v1_reservations_path, params: { authentication_token: User.first.authentication_token } end @@ -29,8 +27,6 @@ end context 'Unauthorized access' do before(:each) do - Rails.application.load_seed - User.first.confirm get api_v1_reservations_path end it 'Respnse unauthrozed' do diff --git a/spec/requests/sign_out_spec.rb b/spec/requests/sign_out_spec.rb index f60b8b2..81fd235 100644 --- a/spec/requests/sign_out_spec.rb +++ b/spec/requests/sign_out_spec.rb @@ -3,9 +3,7 @@ RSpec.describe 'users/sign_out', type: :request do context 'sign-out existing session' do before do - Rails.application.load_seed - User.find_by(email: 'john@gmail.com').confirm - post user_session_path, params: { email: 'john@gmail.com', password: 'test123' } + post user_session_path, params: { email: 'john123@gmail.com', password: 'test123' } delete destroy_user_session_path end it 'Responds with ok status' do @@ -17,7 +15,7 @@ end it 'Responds data has email of the user signed out' do data = JSON.parse(response.body)['data'] - expect(data['email']).to eq('john@gmail.com') + expect(data['email']).to eq('john123@gmail.com') end end diff --git a/spec/requests/users/sessions_spec.rb b/spec/requests/users/sessions_spec.rb index 5a58ce7..d783ce6 100644 --- a/spec/requests/users/sessions_spec.rb +++ b/spec/requests/users/sessions_spec.rb @@ -16,8 +16,6 @@ } response(200, 'successful') do - @user = User.last - @user.confirm let(:params) { { email: 'jane123@gmail.com', password: 'test123' } } example 'application/json', :successfull_login, { status: 'Success', @@ -47,5 +45,21 @@ end end end + + path '/users/sign_out' do + delete('delete session') do + tags 'Sign-out' + description ' Signs out user in session' + produces 'application/json' + + response(401, 'unauthorized') do + example 'application/json', :unauthorized, { + status: 'Failed', + message: 'There is no user to sign out' + } + run_test! + end + end + end end # rubocop:enable Metrics/BlockLength diff --git a/spec/requests/vehicles_spec.rb b/spec/requests/vehicles_spec.rb index 4409b70..8a771a7 100644 --- a/spec/requests/vehicles_spec.rb +++ b/spec/requests/vehicles_spec.rb @@ -4,8 +4,6 @@ RSpec.describe '/api/v1/vehicles', type: :request do context 'Get vehicles ' do before(:each) do - Rails.application.load_seed - User.first.confirm get api_v1_vehicles_path, params: { authentication_token: User.first.authentication_token } end @@ -19,7 +17,6 @@ data = JSON.parse(response.body) expect(data['message']).to eq('Loaded vehicle') end - it 'List brand Vehicle' do get api_v1_vehicle_path(Vehicle.first.id), params: { authentication_token: User.first.authentication_token } data = JSON.parse(response.body)['data']['brand'] @@ -29,7 +26,7 @@ post api_v1_vehicles_path, params: { authentication_token: User.first.authentication_token, brand: 'Mecedz', model: 'benz-30', image: 'image-bmw', - price: 80, description: 'good and lightspeed with low consumptiom' } + price: 80, visible: true, description: 'good and lightspeed with low consumptiom' } data = JSON.parse(response.body) expect(data['message']).to eq('Created Vehicle') end @@ -37,11 +34,10 @@ patch api_v1_vehicle_path(Vehicle.last.id), params: { authentication_token: User.first.authentication_token, brand: 'Lambo', model: 'lambo-30', image: 'image-bmw', - price: 80, description: 'good and lightspeed with low consumptiom' } + price: 80, visible: true, description: 'good and lightspeed with low consumptiom' } data = JSON.parse(response.body) expect(data['message']).to eq('Updeted Vehicle Succesfully') end - it 'Deletes a vehicle' do delete api_v1_vehicle_path(Vehicle.last.id), params: { authentication_token: User.first.authentication_token } data = JSON.parse(response.body) @@ -50,8 +46,6 @@ end context 'Unauthorized access' do before(:each) do - Rails.application.load_seed - User.first.confirm get api_v1_vehicles_path end it 'Respnse unauthrozed' do diff --git a/spec/swagger_helper.rb b/spec/swagger_helper.rb index d5f212a..8f03767 100644 --- a/spec/swagger_helper.rb +++ b/spec/swagger_helper.rb @@ -1,5 +1,5 @@ require 'rails_helper' - +# rubocop:disable Metrics/BlockLength RSpec.configure do |config| # Specify a root folder where Swagger JSON files are generated # NOTE: If you're using the rswag-api to serve API descriptions, you'll need @@ -16,17 +16,25 @@ 'v1/swagger.yaml' => { openapi: '3.0.1', info: { - title: 'API V1', + title: 'book-vehicle API V1', version: 'v1', description: 'A friendly api to book vehicle reservations' }, paths: {}, servers: [ + { + url: 'https://{herokuapp}', + variables: { + herokuapp: { + default: 'book-vehicle.herokuapp.com' + } + } + }, { url: 'http://{defaultHost}', variables: { defaultHost: { - default: 'localhost:3000' + default: 'localhost:3000/' } } } @@ -40,3 +48,4 @@ # Defaults to json. Accepts ':json' and ':yaml'. config.swagger_format = :yaml end +# rubocop:enable Metrics/BlockLength diff --git a/swagger/v1/swagger.yaml b/swagger/v1/swagger.yaml index 6fc365a..98acfec 100644 --- a/swagger/v1/swagger.yaml +++ b/swagger/v1/swagger.yaml @@ -1,7 +1,7 @@ --- openapi: 3.0.1 info: - title: API V1 + title: book-vehicle API V1 version: v1 description: A friendly api to book vehicle reservations paths: @@ -187,6 +187,7 @@ paths: model: Benz-30 price: '90.0' image: image-Benz + visible: 'true' description: good and lightspeed with low consumptiom created_at: '2022-10-01T04:51:07.296Z' updated_at: '2022-10-01T04:51:07.296Z' @@ -194,6 +195,7 @@ paths: brand: G-Wagon model: G-wagon-15 price: '95.0' + visible: 'true' image: image-wagon description: good and lightspeed with low consumptiom created_at: '2022-10-01T04:51:07.302Z' @@ -202,6 +204,7 @@ paths: brand: Farari model: BMW price: '450.0' + visible: 'true' image: farari.png description: Some text here created_at: '2022-10-01T12:39:00.705Z' @@ -236,6 +239,7 @@ paths: brand: G-Wagon model: G-wagon-15 price: '95.0' + visible: 'true' image: image-wagon description: good and lightspeed with low consumptiom created_at: '2022-10-01T22:01:18.479Z' @@ -256,6 +260,8 @@ paths: type: string price: type: decimal + visible: + type: boolean description: type: text required: @@ -304,6 +310,7 @@ paths: brand: BWM model: BMW-30 price: '80.0' + visible: 'true' image: image-bmw description: good and lightspeed with low consumptiom created_at: '2022-10-01T04:51:07.286Z' @@ -339,6 +346,7 @@ paths: brand: BWM model: BMW-30 price: '80.0' + visible: 'true' image: image-bmw description: good and lightspeed with low consumptiom created_at: '2022-10-01T04:51:07.286Z' @@ -374,6 +382,7 @@ paths: brand: BWM model: BMW-30 price: '80.0' + visible: 'true' image: image-bmw description: good and lightspeed with low consumptiom created_at: '2022-10-01T04:51:07.286Z' @@ -409,6 +418,7 @@ paths: brand: BWM model: BMW-30 price: '80.0' + visible: 'true' image: image-bmw description: good and lightspeed with low consumptiom created_at: '2022-10-01T04:51:07.286Z' @@ -518,8 +528,28 @@ paths: required: - email - password + "/users/sign_out": + delete: + summary: delete session + tags: + - Sign-out + description: " Signs out user in session" + responses: + '401': + description: unauthorized + content: + application/json: + examples: + unauthorized: + value: + status: Failed + message: There is no user to sign out servers: +- url: https://{herokuapp} + variables: + herokuapp: + default: book-vehicle.herokuapp.com - url: http://{defaultHost} variables: defaultHost: - default: localhost:3000 + default: localhost:3000/ diff --git a/test/channels/application_cable/connection_test.rb b/test/channels/application_cable/connection_test.rb deleted file mode 100644 index f925925..0000000 --- a/test/channels/application_cable/connection_test.rb +++ /dev/null @@ -1,13 +0,0 @@ -require 'test_helper' - -module ApplicationCable - class ConnectionTest < ActionCable::Connection::TestCase - # test "connects with cookies" do - # cookies.signed[:user_id] = 42 - # - # connect - # - # assert_equal connection.user_id, "42" - # end - end -end diff --git a/test/controllers/.keep b/test/controllers/.keep deleted file mode 100644 index e69de29..0000000 diff --git a/test/controllers/api/v1/vehicles_controller_test.rb b/test/controllers/api/v1/vehicles_controller_test.rb deleted file mode 100644 index 87b070a..0000000 --- a/test/controllers/api/v1/vehicles_controller_test.rb +++ /dev/null @@ -1,7 +0,0 @@ -require 'test_helper' - -class Api::V1::VehiclesControllerTest < ActionDispatch::IntegrationTest - # test "the truth" do - # assert true - # end -end diff --git a/test/controllers/users_controller_test.rb b/test/controllers/users_controller_test.rb deleted file mode 100644 index 6c3da77..0000000 --- a/test/controllers/users_controller_test.rb +++ /dev/null @@ -1,7 +0,0 @@ -require 'test_helper' - -class UsersControllerTest < ActionDispatch::IntegrationTest - # test "the truth" do - # assert true - # end -end diff --git a/test/fixtures/files/.keep b/test/fixtures/files/.keep deleted file mode 100644 index e69de29..0000000 diff --git a/test/fixtures/users.yml b/test/fixtures/users.yml deleted file mode 100644 index d7a3329..0000000 --- a/test/fixtures/users.yml +++ /dev/null @@ -1,11 +0,0 @@ -# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html - -# This model initially had no columns defined. If you add columns to the -# model remove the "{}" from the fixture names and add the columns immediately -# below each fixture, per the syntax in the comments below -# -one: {} -# column: value -# -two: {} -# column: value diff --git a/test/fixtures/vehicles.yml b/test/fixtures/vehicles.yml deleted file mode 100644 index 80544a9..0000000 --- a/test/fixtures/vehicles.yml +++ /dev/null @@ -1,15 +0,0 @@ -# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html - -one: - brand: MyString - model: MyString - price: 9.99 - image: MyString - description: MyText - -two: - brand: MyString - model: MyString - price: 9.99 - image: MyString - description: MyText diff --git a/test/integration/.keep b/test/integration/.keep deleted file mode 100644 index e69de29..0000000 diff --git a/test/mailers/.keep b/test/mailers/.keep deleted file mode 100644 index e69de29..0000000 diff --git a/test/models/.keep b/test/models/.keep deleted file mode 100644 index e69de29..0000000 diff --git a/test/models/user_test.rb b/test/models/user_test.rb deleted file mode 100644 index 82f61e0..0000000 --- a/test/models/user_test.rb +++ /dev/null @@ -1,7 +0,0 @@ -require 'test_helper' - -class UserTest < ActiveSupport::TestCase - # test "the truth" do - # assert true - # end -end diff --git a/test/models/vehicle_test.rb b/test/models/vehicle_test.rb deleted file mode 100644 index bfcbfff..0000000 --- a/test/models/vehicle_test.rb +++ /dev/null @@ -1,7 +0,0 @@ -require 'test_helper' - -class VehicleTest < ActiveSupport::TestCase - # test "the truth" do - # assert true - # end -end diff --git a/test/test_helper.rb b/test/test_helper.rb deleted file mode 100644 index 1b7300e..0000000 --- a/test/test_helper.rb +++ /dev/null @@ -1,15 +0,0 @@ -ENV['RAILS_ENV'] ||= 'test' -require_relative '../config/environment' -require 'rails/test_help' - -module ActiveSupport - class TestCase - # Run tests in parallel with specified workers - parallelize(workers: :number_of_processors) - - # Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order. - fixtures :all - - # Add more helper methods to be used by all tests here... - end -end