create productCommission

This commit is contained in:
Zin Lin Phyo
2017-08-22 11:08:49 +06:30
parent 1af178fecb
commit 74c2955ef0
26 changed files with 1187 additions and 795 deletions

View File

@@ -0,0 +1,141 @@
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.
#
# Also compared to earlier versions of this generator, there are no longer any
# expectations of assigns and templates rendered. These features have been
# removed from Rails core in Rails 5, but can be added back in via the
# `rails-controller-testing` gem.
RSpec.describe Origami::ProductCommissionsController, type: :controller do
# This should return the minimal set of attributes required to create a valid
# ProductCommission. As you add validations to ProductCommission, 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
# Origami::ProductCommissionsController. Be sure to keep this updated too.
let(:valid_session) { {} }
describe "GET #index" do
it "returns a success response" do
product_commission = ProductCommission.create! valid_attributes
get :index, params: {}, session: valid_session
expect(response).to be_success
end
end
describe "GET #show" do
it "returns a success response" do
product_commission = ProductCommission.create! valid_attributes
get :show, params: {id: product_commission.to_param}, session: valid_session
expect(response).to be_success
end
end
describe "GET #new" do
it "returns a success response" do
get :new, params: {}, session: valid_session
expect(response).to be_success
end
end
describe "GET #edit" do
it "returns a success response" do
product_commission = ProductCommission.create! valid_attributes
get :edit, params: {id: product_commission.to_param}, session: valid_session
expect(response).to be_success
end
end
describe "POST #create" do
context "with valid params" do
it "creates a new ProductCommission" do
expect {
post :create, params: {origami_product_commission: valid_attributes}, session: valid_session
}.to change(ProductCommission, :count).by(1)
end
it "redirects to the created origami_product_commission" do
post :create, params: {origami_product_commission: valid_attributes}, session: valid_session
expect(response).to redirect_to(ProductCommission.last)
end
end
context "with invalid params" do
it "returns a success response (i.e. to display the 'new' template)" do
post :create, params: {origami_product_commission: invalid_attributes}, session: valid_session
expect(response).to be_success
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 origami_product_commission" do
product_commission = ProductCommission.create! valid_attributes
put :update, params: {id: product_commission.to_param, origami_product_commission: new_attributes}, session: valid_session
product_commission.reload
skip("Add assertions for updated state")
end
it "redirects to the origami_product_commission" do
product_commission = ProductCommission.create! valid_attributes
put :update, params: {id: product_commission.to_param, origami_product_commission: valid_attributes}, session: valid_session
expect(response).to redirect_to(product_commission)
end
end
context "with invalid params" do
it "returns a success response (i.e. to display the 'edit' template)" do
product_commission = ProductCommission.create! valid_attributes
put :update, params: {id: product_commission.to_param, origami_product_commission: invalid_attributes}, session: valid_session
expect(response).to be_success
end
end
end
describe "DELETE #destroy" do
it "destroys the requested origami_product_commission" do
product_commission = ProductCommission.create! valid_attributes
expect {
delete :destroy, params: {id: product_commission.to_param}, session: valid_session
}.to change(ProductCommission, :count).by(-1)
end
it "redirects to the product_commissions list" do
product_commission = ProductCommission.create! valid_attributes
delete :destroy, params: {id: product_commission.to_param}, session: valid_session
expect(response).to redirect_to(product_commissions_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 Origami::ProductCommissionsHelper. For example:
#
# describe Origami::ProductCommissionsHelper 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 Origami::ProductCommissionsHelper, type: :helper do
pending "add some examples to (or delete) #{__FILE__}"
end

View File

@@ -0,0 +1,5 @@
require 'rails_helper'
RSpec.describe ProductCommission, type: :model do
pending "add some examples to (or delete) #{__FILE__}"
end

View File

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

View File

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

View File

@@ -0,0 +1,14 @@
require 'rails_helper'
RSpec.describe "origami/product_commissions/edit", type: :view do
before(:each) do
@origami_product_commission = assign(:origami_product_commission, ProductCommission.create!())
end
it "renders the edit origami_product_commission form" do
render
assert_select "form[action=?][method=?]", origami_product_commission_path(@origami_product_commission), "post" do
end
end
end

View File

@@ -0,0 +1,14 @@
require 'rails_helper'
RSpec.describe "origami/product_commissions/index", type: :view do
before(:each) do
assign(:product_commissions, [
ProductCommission.create!(),
ProductCommission.create!()
])
end
it "renders a list of origami/product_commissions" do
render
end
end

View File

@@ -0,0 +1,14 @@
require 'rails_helper'
RSpec.describe "origami/product_commissions/new", type: :view do
before(:each) do
assign(:origami_product_commission, ProductCommission.new())
end
it "renders new origami_product_commission form" do
render
assert_select "form[action=?][method=?]", product_commissions_path, "post" do
end
end
end

View File

@@ -0,0 +1,11 @@
require 'rails_helper'
RSpec.describe "origami/product_commissions/show", type: :view do
before(:each) do
@origami_product_commission = assign(:origami_product_commission, ProductCommission.create!())
end
it "renders attributes in <p>" do
render
end
end