diff options
| author | luu <luuduong@gmail.com> | 2014-12-13 16:41:51 +0000 |
|---|---|---|
| committer | luu <luuduong@gmail.com> | 2014-12-13 16:41:51 +0000 |
| commit | 50b94a4ff8a2f462ceb4e8a4f5286683b4ef0e8b (patch) | |
| tree | d87c96d5a1328812ead05464d26e64bbb842373a /spec/controllers | |
| parent | 0a61f5240d1fa127a9bb9bdd0a39ffd84dc8bfb9 (diff) | |
add tool only if it is not in the toolbox.
Diffstat (limited to 'spec/controllers')
| -rw-r--r-- | spec/controllers/admin/products_controller_spec.rb | 43 |
1 files changed, 39 insertions, 4 deletions
diff --git a/spec/controllers/admin/products_controller_spec.rb b/spec/controllers/admin/products_controller_spec.rb index fc191a90..b0731139 100644 --- a/spec/controllers/admin/products_controller_spec.rb +++ b/spec/controllers/admin/products_controller_spec.rb @@ -1,13 +1,48 @@ require 'rails_helper' + module Admin describe ProductsController do - describe "#create" do - let(:admin) { create(:admin)} + let(:admin) { create(:admin)} + + before :each do + http_login(admin) + end + + describe "#show" do + let(:product_api) { double(find: true) } before :each do - http_login(admin) + controller.stub(:product_api).and_return(product_api) + end + + it 'loads the product details from amazon' do + asin = 'asin' + product = "product" + product_api.stub(:find).with(asin).and_return(product) + + get :show, id: asin + + expect(assigns(:product)).to eql(product) + end + + context "when the tool has been added to the toolbox" do + let(:tool) { create(:tool) } + + it "loads the tool" do + get :show, id: tool.asin + expect(assigns(:tool)).to eql(tool) + end end + context "when the tool is not in the toolbox" do + it "does not load a tool" do + get :show, id: "not_added" + expect(assigns(:tool)).to be_nil + end + end + end + + describe "#create" do it "creates new tool" do post :create, {:name=>"pan", :asin=>"34234"} @@ -18,7 +53,7 @@ module Admin it "redirects back to the detail page" do post :create, {name: 'blah', asin: 'blah' } - expect(response).to redirect_to(admin_products_path('blah')) + expect(response).to redirect_to(admin_product_path('blah')) end end end |
