queue and crm view updated

This commit is contained in:
Aung Myo
2017-06-09 09:29:25 +06:30
parent ea4f50e779
commit 35277ac000
41 changed files with 685 additions and 318 deletions

View File

@@ -1,5 +0,0 @@
require 'rails_helper'
RSpec.describe Crm::BookingsController, type: :controller do
end

View File

@@ -1,159 +0,0 @@
require 'rails_helper'
# This spec was generated by rspec-rails when you ran the scaffold generator.
# It demonstrates how one might use RSpec to specify the controller code that
# was generated by Rails when you ran the scaffold generator.
#
# It assumes that the implementation code is generated by the rails scaffold
# generator. If you are using any extension libraries to generate different
# controller code, this generated spec may or may not pass.
#
# It only uses APIs available in rails and/or rspec-rails. There are a number
# of tools you can use to make these specs even more expressive, but we're
# sticking to rails and rspec-rails APIs to keep things simple and stable.
#
# Compared to earlier versions of this generator, there is very limited use of
# stubs and message expectations in this spec. Stubs are only used when there
# is no simpler way to get a handle on the object needed for the example.
# Message expectations are only used when there is no simpler way to specify
# that an instance is receiving a specific message.
RSpec.describe Crm::CustomersController, type: :controller do
# This should return the minimal set of attributes required to create a valid
# Crm::Customer. As you add validations to Crm::Customer, be sure to
# adjust the attributes here as well.
let(:valid_attributes) {
skip("Add a hash of attributes valid for your model")
}
let(:invalid_attributes) {
skip("Add a hash of attributes invalid for your model")
}
# This should return the minimal set of values that should be in the session
# in order to pass any filters (e.g. authentication) defined in
# Crm::CustomersController. Be sure to keep this updated too.
let(:valid_session) { {} }
describe "GET #index" do
it "assigns all crm_customers as @crm_customers" do
customer = Crm::Customer.create! valid_attributes
get :index, params: {}, session: valid_session
expect(assigns(:crm_customers)).to eq([customer])
end
end
describe "GET #show" do
it "assigns the requested crm_customer as @crm_customer" do
customer = Crm::Customer.create! valid_attributes
get :show, params: {id: customer.to_param}, session: valid_session
expect(assigns(:crm_customer)).to eq(customer)
end
end
describe "GET #new" do
it "assigns a new crm_customer as @crm_customer" do
get :new, params: {}, session: valid_session
expect(assigns(:crm_customer)).to be_a_new(Crm::Customer)
end
end
describe "GET #edit" do
it "assigns the requested crm_customer as @crm_customer" do
customer = Crm::Customer.create! valid_attributes
get :edit, params: {id: customer.to_param}, session: valid_session
expect(assigns(:crm_customer)).to eq(customer)
end
end
describe "POST #create" do
context "with valid params" do
it "creates a new Crm::Customer" do
expect {
post :create, params: {crm_customer: valid_attributes}, session: valid_session
}.to change(Crm::Customer, :count).by(1)
end
it "assigns a newly created crm_customer as @crm_customer" do
post :create, params: {crm_customer: valid_attributes}, session: valid_session
expect(assigns(:crm_customer)).to be_a(Crm::Customer)
expect(assigns(:crm_customer)).to be_persisted
end
it "redirects to the created crm_customer" do
post :create, params: {crm_customer: valid_attributes}, session: valid_session
expect(response).to redirect_to(Crm::Customer.last)
end
end
context "with invalid params" do
it "assigns a newly created but unsaved crm_customer as @crm_customer" do
post :create, params: {crm_customer: invalid_attributes}, session: valid_session
expect(assigns(:crm_customer)).to be_a_new(Crm::Customer)
end
it "re-renders the 'new' template" do
post :create, params: {crm_customer: invalid_attributes}, session: valid_session
expect(response).to render_template("new")
end
end
end
describe "PUT #update" do
context "with valid params" do
let(:new_attributes) {
skip("Add a hash of attributes valid for your model")
}
it "updates the requested crm_customer" do
customer = Crm::Customer.create! valid_attributes
put :update, params: {id: customer.to_param, crm_customer: new_attributes}, session: valid_session
customer.reload
skip("Add assertions for updated state")
end
it "assigns the requested crm_customer as @crm_customer" do
customer = Crm::Customer.create! valid_attributes
put :update, params: {id: customer.to_param, crm_customer: valid_attributes}, session: valid_session
expect(assigns(:crm_customer)).to eq(customer)
end
it "redirects to the crm_customer" do
customer = Crm::Customer.create! valid_attributes
put :update, params: {id: customer.to_param, crm_customer: valid_attributes}, session: valid_session
expect(response).to redirect_to(customer)
end
end
context "with invalid params" do
it "assigns the crm_customer as @crm_customer" do
customer = Crm::Customer.create! valid_attributes
put :update, params: {id: customer.to_param, crm_customer: invalid_attributes}, session: valid_session
expect(assigns(:crm_customer)).to eq(customer)
end
it "re-renders the 'edit' template" do
customer = Crm::Customer.create! valid_attributes
put :update, params: {id: customer.to_param, crm_customer: invalid_attributes}, session: valid_session
expect(response).to render_template("edit")
end
end
end
describe "DELETE #destroy" do
it "destroys the requested crm_customer" do
customer = Crm::Customer.create! valid_attributes
expect {
delete :destroy, params: {id: customer.to_param}, session: valid_session
}.to change(Crm::Customer, :count).by(-1)
end
it "redirects to the crm_customers list" do
customer = Crm::Customer.create! valid_attributes
delete :destroy, params: {id: customer.to_param}, session: valid_session
expect(response).to redirect_to(crm_customers_url)
end
end
end

View File

@@ -0,0 +1,15 @@
require 'rails_helper'
# Specs in this file have access to a helper object that includes
# the Crm::DiningQueuesHelper. For example:
#
# describe Crm::DiningQueuesHelper do
# describe "string concat" do
# it "concats two strings with spaces" do
# expect(helper.concat_strings("this","that")).to eq("this that")
# end
# end
# end
RSpec.describe Crm::DiningQueuesHelper, type: :helper do
pending "add some examples to (or delete) #{__FILE__}"
end

View File

@@ -0,0 +1,10 @@
require 'rails_helper'
RSpec.describe "Crm::DiningQueues", type: :request do
describe "GET /crm_dining_queues" do
it "works! (now write some real specs)" do
get crm_dining_queues_path
expect(response).to have_http_status(200)
end
end
end

View File

@@ -0,0 +1,39 @@
require "rails_helper"
RSpec.describe Crm::DiningQueuesController, type: :routing do
describe "routing" do
it "routes to #index" do
expect(:get => "/crm/dining_queues").to route_to("crm/dining_queues#index")
end
it "routes to #new" do
expect(:get => "/crm/dining_queues/new").to route_to("crm/dining_queues#new")
end
it "routes to #show" do
expect(:get => "/crm/dining_queues/1").to route_to("crm/dining_queues#show", :id => "1")
end
it "routes to #edit" do
expect(:get => "/crm/dining_queues/1/edit").to route_to("crm/dining_queues#edit", :id => "1")
end
it "routes to #create" do
expect(:post => "/crm/dining_queues").to route_to("crm/dining_queues#create")
end
it "routes to #update via PUT" do
expect(:put => "/crm/dining_queues/1").to route_to("crm/dining_queues#update", :id => "1")
end
it "routes to #update via PATCH" do
expect(:patch => "/crm/dining_queues/1").to route_to("crm/dining_queues#update", :id => "1")
end
it "routes to #destroy" do
expect(:delete => "/crm/dining_queues/1").to route_to("crm/dining_queues#destroy", :id => "1")
end
end
end

View File

@@ -0,0 +1,24 @@
require 'rails_helper'
RSpec.describe "crm/dining_queues/edit", type: :view do
before(:each) do
@crm_dining_queue = assign(:crm_dining_queue, Crm::DiningQueue.create!(
:name => "MyString",
:contact => "MyString",
:queue_no => "MyString"
))
end
it "renders the edit crm_dining_queue form" do
render
assert_select "form[action=?][method=?]", crm_dining_queue_path(@crm_dining_queue), "post" do
assert_select "input[name=?]", "crm_dining_queue[name]"
assert_select "input[name=?]", "crm_dining_queue[contact]"
assert_select "input[name=?]", "crm_dining_queue[queue_no]"
end
end
end

View File

@@ -0,0 +1,25 @@
require 'rails_helper'
RSpec.describe "crm/dining_queues/index", type: :view do
before(:each) do
assign(:crm_dining_queues, [
Crm::DiningQueue.create!(
:name => "Name",
:contact => "Contact",
:queue_no => "Queue No"
),
Crm::DiningQueue.create!(
:name => "Name",
:contact => "Contact",
:queue_no => "Queue No"
)
])
end
it "renders a list of crm/dining_queues" do
render
assert_select "tr>td", :text => "Name".to_s, :count => 2
assert_select "tr>td", :text => "Contact".to_s, :count => 2
assert_select "tr>td", :text => "Queue No".to_s, :count => 2
end
end

View File

@@ -0,0 +1,24 @@
require 'rails_helper'
RSpec.describe "crm/dining_queues/new", type: :view do
before(:each) do
assign(:crm_dining_queue, Crm::DiningQueue.new(
:name => "MyString",
:contact => "MyString",
:queue_no => "MyString"
))
end
it "renders new crm_dining_queue form" do
render
assert_select "form[action=?][method=?]", crm_dining_queues_path, "post" do
assert_select "input[name=?]", "crm_dining_queue[name]"
assert_select "input[name=?]", "crm_dining_queue[contact]"
assert_select "input[name=?]", "crm_dining_queue[queue_no]"
end
end
end

View File

@@ -0,0 +1,18 @@
require 'rails_helper'
RSpec.describe "crm/dining_queues/show", type: :view do
before(:each) do
@crm_dining_queue = assign(:crm_dining_queue, Crm::DiningQueue.create!(
:name => "Name",
:contact => "Contact",
:queue_no => "Queue No"
))
end
it "renders attributes in <p>" do
render
expect(rendered).to match(/Name/)
expect(rendered).to match(/Contact/)
expect(rendered).to match(/Queue No/)
end
end