Skip to content

Commit

Permalink
Merge pull request #35 from rubydevi/f/iterations-tests
Browse files Browse the repository at this point in the history
Changes Requested:Readme:correct test command
  • Loading branch information
RileyManda authored Nov 10, 2023
2 parents 671f2f5 + d2d807a commit 8d53755
Show file tree
Hide file tree
Showing 22 changed files with 141 additions and 60 deletions.
4 changes: 2 additions & 2 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ AllCops:
DisplayCopNames: true

Layout/LineLength:
Max: 120
Max: 125
Metrics/MethodLength:
Include:
- 'app/controllers/*'
Expand Down Expand Up @@ -59,4 +59,4 @@ Style/HashEachMethods:
Style/HashTransformKeys:
Enabled: false
Style/HashTransformValues:
Enabled: false
Enabled: false
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ source 'https://rubygems.org'
ruby '3.2.2'

# Bundle edge Rails instead: gem "rails", github: "rails/rails", branch: "main"
gem 'faker', '~> 2.20'
gem 'rails', '~> 7.1.1'
gem 'rspec-rails'
gem 'rswag'
Expand Down
3 changes: 3 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,8 @@ GEM
concurrent-ruby (~> 1.0)
zeitwerk (~> 2.6)
erubi (1.12.0)
faker (2.23.0)
i18n (>= 1.8.11, < 2)
globalid (1.2.1)
activesupport (>= 6.1)
i18n (1.14.1)
Expand Down Expand Up @@ -276,6 +278,7 @@ DEPENDENCIES
devise
devise-jwt
dotenv-rails
faker (~> 2.20)
jsonapi-serializer
pg (~> 1.1)
puma (>= 5.0)
Expand Down
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,12 @@ To run the project, you will need to execute:
```sh
rails credentials:edit

rails db:create

rails db:migrate

rails db:seed

rails s
```

Expand All @@ -168,7 +174,7 @@ To run the project, you will need to execute:
To run tests, run the following command:

```sh
Rspec spec or bundle exec rspec spec
rspec spec/model/
```

<!-- ### Deployment
Expand Down
6 changes: 5 additions & 1 deletion app/controllers/api/v1/reservations_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,11 @@ def update

# DELETE /reservations/1
def destroy
@reservation.destroy!
if @reservation.destroy!
render json: { message: 'Reservation deleted successfully' }, status: :no_content
else
render json: { error: 'Failed to delete Reservation' }, status: :unprocessable_entity
end
end

private
Expand Down
5 changes: 0 additions & 5 deletions app/controllers/reservations_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,6 @@ def update
end
end

# DELETE /reservations/1
def destroy
@reservation.destroy!
end

private

# Use callbacks to share common setup or constraints between actions.
Expand Down
5 changes: 0 additions & 5 deletions db/migrate/20231107114431_add_name_to_reservations.rb

This file was deleted.

1 change: 0 additions & 1 deletion db/schema.rb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"dependencies": {
"react-hot-toast": "^2.4.1"
}
}
76 changes: 76 additions & 0 deletions spec/model/aeroplane_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
require 'rails_helper'

RSpec.describe Aeroplane, type: :model do
describe 'validations' do
it 'name should be present' do
aeroplane = Aeroplane.new(model: '[email protected]',
image: 'image 1',
description: 'Description of the planes',
number_of_seats: 6,
location: 'Middle Earth',
fee: 60.0)
expect(aeroplane).to_not be_valid
end

it 'model should be present' do
aeroplane = Aeroplane.new(name: 'Dragon 1',
image: 'image 1',
description: 'Description of the planes',
number_of_seats: 6,
location: 'Middle Earth',
fee: 60.0)
expect(aeroplane).to_not be_valid
end

it 'image should be present' do
aeroplane = Aeroplane.new(name: 'Dragon 1',
model: 'Jet',
description: 'Description of the planes',
number_of_seats: 6,
location: 'Middle Earth',
fee: 60.0)
expect(aeroplane).to_not be_valid
end

it 'description should be present' do
aeroplane = Aeroplane.new(name: 'Dragon 1',
image: 'image 1',
model: 'Jet',
number_of_seats: 6,
location: 'Middle Earth',
fee: 60.0)
expect(aeroplane).to_not be_valid
end

it 'number_of_seats should be present' do
aeroplane = Aeroplane.new(name: 'Dragon 1',
image: 'image 1',
model: 'Jet',
description: 'Description of the planes',
location: 'Middle Earth',
fee: 60.0)
expect(aeroplane).to_not be_valid
end

it 'location should be present' do
aeroplane = Aeroplane.new(name: 'Dragon 1',
image: 'image 1',
model: 'Jet',
description: 'Description of the planes',
number_of_seats: 6,
fee: 60.0)
expect(aeroplane).to_not be_valid
end

it 'fee should be greater than 0' do
aeroplane = Aeroplane.new(name: 'Dragon 1',
image: 'image 1',
model: 'Jet',
description: 'Description of the planes',
number_of_seats: 6,
location: 'Middle Earth',
fee: -1)
expect(aeroplane).to_not be_valid
end
end
end
40 changes: 40 additions & 0 deletions spec/model/reservations_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
require 'rails_helper'

RSpec.describe Reservation, type: :model do
let(:user) do
User.new(name: 'bob', email: '[email protected]', password: 'password12', password_confirmation: 'password12')
end
before { user.save }

let(:plane) do
Aeroplane.new(name: 'boning 777', model: '[email protected]', image: 'image 1', description: 'Description of the planes',
number_of_seats: 6, location: 'Middle Earth', fee: 60.0)
end
before { plane.save }
let(:reservation) do
Reservation.new(reserved_date: '2023-11-11', start_time: '18:24', end_time: '20:25', start_location: 'addis ababa',
destination: 'india', user_id: user.id, aeroplane_id: plane.id)
end
before { reservation.save }
context 'when testing the Reservation class' do
it 'should have user ' do
reservation.user_id = nil
expect(reservation).to_not be_valid
end
it 'should have areoplane ' do
reservation.aeroplane_id = nil
expect(reservation).to_not be_valid
end
it 'should have resevation date ' do
reservation.destination = nil
expect(reservation).to_not be_valid
end
it 'should have destination ' do
reservation.reserved_date = nil
expect(reservation).to_not be_valid
end
it 'should have pass if all valid ' do
expect(reservation).to be_valid
end
end
end
5 changes: 0 additions & 5 deletions spec/models/aeroplane_spec.rb

This file was deleted.

5 changes: 0 additions & 5 deletions spec/models/reservation_spec.rb

This file was deleted.

5 changes: 0 additions & 5 deletions spec/models/user_spec.rb

This file was deleted.

4 changes: 2 additions & 2 deletions swagger/v1/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ paths:
- user_id
- aeroplane_id
servers:
- url: http://{defaultHost}
- url: https://{defaultHost}
variables:
defaultHost:
default: localhost:4000
default: http://127.0.0.1:4000/
13 changes: 0 additions & 13 deletions test/channels/application_cable/connection_test.rb

This file was deleted.

Empty file removed test/controllers/.keep
Empty file.
Empty file removed test/fixtures/files/.keep
Empty file.
Empty file removed test/integration/.keep
Empty file.
Empty file removed test/mailers/.keep
Empty file.
Empty file removed test/models/.keep
Empty file.
15 changes: 0 additions & 15 deletions test/test_helper.rb

This file was deleted.

0 comments on commit 8d53755

Please sign in to comment.