menu and menu_category
This commit is contained in:
11
spec/factories/rooms.rb
Normal file
11
spec/factories/rooms.rb
Normal file
@@ -0,0 +1,11 @@
|
||||
FactoryGirl.define do
|
||||
|
||||
factory :room do
|
||||
name { Faker::StarWars.character }
|
||||
order_by { Faker::Number.number(2)}
|
||||
seater {Faker::Number.number(2)}
|
||||
created_by {Faker::StarWars.character}
|
||||
association :zone, factory: :zone, name: "Writely"
|
||||
|
||||
end
|
||||
end
|
||||
@@ -1,8 +1,11 @@
|
||||
FactoryGirl.define do
|
||||
factory :seat_tables do
|
||||
|
||||
factory :seat_table do
|
||||
name { Faker::StarWars.character }
|
||||
order_by { Faker::Number.number(5)}
|
||||
no_of_seater {Faker::Number.number(5)}
|
||||
zone_id nil
|
||||
order_by { Faker::Number.number(2)}
|
||||
no_of_seater {Faker::Number.number(2)}
|
||||
created_by {Faker::StarWars.character}
|
||||
association :zone, factory: :zone, name: "Writely"
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
7
spec/models/menu_category_spec.rb
Normal file
7
spec/models/menu_category_spec.rb
Normal file
@@ -0,0 +1,7 @@
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe MenuCategory, type: :model do
|
||||
it { should validate_presence_of(:name) }
|
||||
it { should belong_to(:menu) }
|
||||
|
||||
end
|
||||
12
spec/models/menu_spec.rb
Normal file
12
spec/models/menu_spec.rb
Normal file
@@ -0,0 +1,12 @@
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe Menu, type: :model do
|
||||
it { should have_many(:menu_categories).dependent(:destroy) }
|
||||
|
||||
it { should validate_presence_of(:name) }
|
||||
it { should validate_presence_of(:is_active) }
|
||||
it { should validate_presence_of(:valid_days) }
|
||||
it { should validate_presence_of(:valid_time_from) }
|
||||
it { should validate_presence_of(:valid_time_to) }
|
||||
|
||||
end
|
||||
10
spec/models/room_spec.rb
Normal file
10
spec/models/room_spec.rb
Normal file
@@ -0,0 +1,10 @@
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe Room, type: :model do
|
||||
it { should belong_to(:zone) }
|
||||
|
||||
it { should validate_presence_of(:name) }
|
||||
it { should validate_presence_of(:seater) }
|
||||
it { should validate_presence_of(:is_active) }
|
||||
|
||||
end
|
||||
@@ -4,6 +4,8 @@ RSpec.describe Zone, type: :model do
|
||||
# Association test
|
||||
# ensure Todo model has a 1:m relationship with the Item model
|
||||
it { should have_many(:seat_tables).dependent(:destroy) }
|
||||
it { should have_many(:rooms).dependent(:destroy) }
|
||||
|
||||
# Validation tests
|
||||
# ensure columns title and created_by are present before saving
|
||||
it { should validate_presence_of(:name) }
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe 'Seat Table API', type: :request do
|
||||
# initialize test data
|
||||
let!(:seat_table) { create_list(:seat_table, 10) }
|
||||
let(:seat_table_id) { seat_tables.first.id }
|
||||
|
||||
# Test suite for GET /todos
|
||||
describe 'GET /api/restaurant/seat_tables' do
|
||||
# make HTTP get request before each example
|
||||
before { get '/api/restaurant/seat_tables' }
|
||||
|
||||
it 'returns Seat Tables' do
|
||||
# Note `json` is a custom helper to parse JSON responses
|
||||
expect(json).not_to be_empty
|
||||
expect(json.size).to eq(10)
|
||||
end
|
||||
|
||||
it 'returns status code 200' do
|
||||
expect(response).to have_http_status(200)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user