mirror of
https://github.com/Growstuff/growstuff.git
synced 2026-10-23 07:18:22 -04:00
added basic index page for shop
This commit is contained in:
1 parent
42ea14a8e5
commit
5c96bf1541
13 files changed
+101
-59
No files matched your search
@@ -1,2 +1,8 @@
|
||||
class ShopController < ApplicationController
|
||||
def index
|
||||
@products = Product.all
|
||||
respond_to do |format|
|
||||
format.html # index.html.haml
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -1,2 +1,27 @@
|
||||
-content_for :title, 'Shop'
|
||||
|
||||
%p
|
||||
Growstuff relies on your support to build and run this open source
|
||||
platform for food growers.
|
||||
|
||||
%p
|
||||
We offer paid accounts which have access to exclusive features. You can
|
||||
buy a monthly, yearly, or permanent ("seed") account.
|
||||
|
||||
%p
|
||||
All our accounts are priced on a sliding scale. You can choose how much
|
||||
you want to pay. Remember, your subscription supports an open source
|
||||
platform promoting sustainable lifestyles!
|
||||
|
||||
- @products.each do |p|
|
||||
%h2= p.name
|
||||
|
||||
%div
|
||||
:markdown
|
||||
#{ strip_tags p.description }
|
||||
|
||||
%div
|
||||
Base price:
|
||||
#{ number_with_precision(p.min_price, :precision => 2) }
|
||||
#{ Growstuff::Application.config.currency }
|
||||
|
||||
@@ -51,5 +51,6 @@ Growstuff::Application.configure do
|
||||
Growstuff::Application.configure do
|
||||
config.site_name = "Growstuff (dev)"
|
||||
config.analytics_code = ''
|
||||
config.currency = 'AUD'
|
||||
end
|
||||
end
|
||||
@@ -85,6 +85,7 @@ Growstuff::Application.configure do
|
||||
<script type="text/javascript">try{ clicky.init(100594260); }catch(e){}</script>
|
||||
<noscript><p><img alt="Clicky" width="1" height="1" src="//in.getclicky.com/100594260ns.gif" /></p></noscript>
|
||||
eos
|
||||
config.currency = 'AUD'
|
||||
end
|
||||
|
||||
end
|
||||
@@ -81,6 +81,7 @@ Growstuff::Application.configure do
|
||||
Growstuff::Application.configure do
|
||||
config.site_name = "Growstuff (staging)"
|
||||
config.analytics_code = ''
|
||||
config.currency = 'AUD'
|
||||
end
|
||||
|
||||
end
|
||||
@@ -43,6 +43,7 @@ Growstuff::Application.configure do
|
||||
Growstuff::Application.configure do
|
||||
config.site_name = "Growstuff (test)"
|
||||
config.analytics_code = ''
|
||||
config.currency = 'AUD'
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
+2
-4
@@ -1,9 +1,5 @@
|
||||
Growstuff::Application.routes.draw do
|
||||
|
||||
resources :orders
|
||||
|
||||
resources :products
|
||||
|
||||
devise_for :members, :controllers => { :registrations => "registrations" }
|
||||
|
||||
resources :authentications
|
||||
@@ -17,6 +13,8 @@ Growstuff::Application.routes.draw do
|
||||
resources :roles
|
||||
resources :forums
|
||||
resources :notifications
|
||||
resources :orders
|
||||
resources :products
|
||||
|
||||
get "home/index"
|
||||
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
require 'spec_helper'
|
||||
|
||||
|
||||
describe OrdersController do
|
||||
|
||||
login_member(:admin_member)
|
||||
|
||||
def valid_attributes
|
||||
{ "member_id" => "MyString" }
|
||||
end
|
||||
@@ -14,7 +15,7 @@ describe OrdersController do
|
||||
describe "GET index" do
|
||||
it "assigns all orders as @orders" do
|
||||
order = Order.create! valid_attributes
|
||||
get :index, {}, valid_session
|
||||
get :index, {}
|
||||
assigns(:orders).should eq([order])
|
||||
end
|
||||
end
|
||||
@@ -22,14 +23,14 @@ describe OrdersController do
|
||||
describe "GET show" do
|
||||
it "assigns the requested order as @order" do
|
||||
order = Order.create! valid_attributes
|
||||
get :show, {:id => order.to_param}, valid_session
|
||||
get :show, {:id => order.to_param}
|
||||
assigns(:order).should eq(order)
|
||||
end
|
||||
end
|
||||
|
||||
describe "GET new" do
|
||||
it "assigns a new order as @order" do
|
||||
get :new, {}, valid_session
|
||||
get :new, {}
|
||||
assigns(:order).should be_a_new(Order)
|
||||
end
|
||||
end
|
||||
@@ -37,7 +38,7 @@ describe OrdersController do
|
||||
describe "GET edit" do
|
||||
it "assigns the requested order as @order" do
|
||||
order = Order.create! valid_attributes
|
||||
get :edit, {:id => order.to_param}, valid_session
|
||||
get :edit, {:id => order.to_param}
|
||||
assigns(:order).should eq(order)
|
||||
end
|
||||
end
|
||||
@@ -46,18 +47,18 @@ describe OrdersController do
|
||||
describe "with valid params" do
|
||||
it "creates a new Order" do
|
||||
expect {
|
||||
post :create, {:order => valid_attributes}, valid_session
|
||||
post :create, {:order => valid_attributes}
|
||||
}.to change(Order, :count).by(1)
|
||||
end
|
||||
|
||||
it "assigns a newly created order as @order" do
|
||||
post :create, {:order => valid_attributes}, valid_session
|
||||
post :create, {:order => valid_attributes}
|
||||
assigns(:order).should be_a(Order)
|
||||
assigns(:order).should be_persisted
|
||||
end
|
||||
|
||||
it "redirects to the created order" do
|
||||
post :create, {:order => valid_attributes}, valid_session
|
||||
post :create, {:order => valid_attributes}
|
||||
response.should redirect_to(Order.last)
|
||||
end
|
||||
end
|
||||
@@ -66,14 +67,14 @@ describe OrdersController do
|
||||
it "assigns a newly created but unsaved order as @order" do
|
||||
# Trigger the behavior that occurs when invalid params are submitted
|
||||
Order.any_instance.stub(:save).and_return(false)
|
||||
post :create, {:order => { "member_id" => "invalid value" }}, valid_session
|
||||
post :create, {:order => { "member_id" => "invalid value" }}
|
||||
assigns(:order).should be_a_new(Order)
|
||||
end
|
||||
|
||||
it "re-renders the 'new' template" do
|
||||
# Trigger the behavior that occurs when invalid params are submitted
|
||||
Order.any_instance.stub(:save).and_return(false)
|
||||
post :create, {:order => { "member_id" => "invalid value" }}, valid_session
|
||||
post :create, {:order => { "member_id" => "invalid value" }}
|
||||
response.should render_template("new")
|
||||
end
|
||||
end
|
||||
@@ -88,18 +89,18 @@ describe OrdersController do
|
||||
# receives the :update_attributes message with whatever params are
|
||||
# submitted in the request.
|
||||
Order.any_instance.should_receive(:update_attributes).with({ "member_id" => "MyString" })
|
||||
put :update, {:id => order.to_param, :order => { "member_id" => "MyString" }}, valid_session
|
||||
put :update, {:id => order.to_param, :order => { "member_id" => "MyString" }}
|
||||
end
|
||||
|
||||
it "assigns the requested order as @order" do
|
||||
order = Order.create! valid_attributes
|
||||
put :update, {:id => order.to_param, :order => valid_attributes}, valid_session
|
||||
put :update, {:id => order.to_param, :order => valid_attributes}
|
||||
assigns(:order).should eq(order)
|
||||
end
|
||||
|
||||
it "redirects to the order" do
|
||||
order = Order.create! valid_attributes
|
||||
put :update, {:id => order.to_param, :order => valid_attributes}, valid_session
|
||||
put :update, {:id => order.to_param, :order => valid_attributes}
|
||||
response.should redirect_to(order)
|
||||
end
|
||||
end
|
||||
@@ -109,7 +110,7 @@ describe OrdersController do
|
||||
order = Order.create! valid_attributes
|
||||
# Trigger the behavior that occurs when invalid params are submitted
|
||||
Order.any_instance.stub(:save).and_return(false)
|
||||
put :update, {:id => order.to_param, :order => { "member_id" => "invalid value" }}, valid_session
|
||||
put :update, {:id => order.to_param, :order => { "member_id" => "invalid value" }}
|
||||
assigns(:order).should eq(order)
|
||||
end
|
||||
|
||||
@@ -117,7 +118,7 @@ describe OrdersController do
|
||||
order = Order.create! valid_attributes
|
||||
# Trigger the behavior that occurs when invalid params are submitted
|
||||
Order.any_instance.stub(:save).and_return(false)
|
||||
put :update, {:id => order.to_param, :order => { "member_id" => "invalid value" }}, valid_session
|
||||
put :update, {:id => order.to_param, :order => { "member_id" => "invalid value" }}
|
||||
response.should render_template("edit")
|
||||
end
|
||||
end
|
||||
@@ -127,13 +128,13 @@ describe OrdersController do
|
||||
it "destroys the requested order" do
|
||||
order = Order.create! valid_attributes
|
||||
expect {
|
||||
delete :destroy, {:id => order.to_param}, valid_session
|
||||
delete :destroy, {:id => order.to_param}
|
||||
}.to change(Order, :count).by(-1)
|
||||
end
|
||||
|
||||
it "redirects to the orders list" do
|
||||
order = Order.create! valid_attributes
|
||||
delete :destroy, {:id => order.to_param}, valid_session
|
||||
delete :destroy, {:id => order.to_param}
|
||||
response.should redirect_to(orders_url)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -2,6 +2,8 @@ require 'spec_helper'
|
||||
|
||||
describe ProductsController do
|
||||
|
||||
login_member(:admin_member)
|
||||
|
||||
def valid_attributes
|
||||
{
|
||||
:name => "product name",
|
||||
@@ -17,7 +19,7 @@ describe ProductsController do
|
||||
describe "GET index" do
|
||||
it "assigns all products as @products" do
|
||||
product = Product.create! valid_attributes
|
||||
get :index, {}, valid_session
|
||||
get :index, {}
|
||||
assigns(:products).should eq([product])
|
||||
end
|
||||
end
|
||||
@@ -25,14 +27,14 @@ describe ProductsController do
|
||||
describe "GET show" do
|
||||
it "assigns the requested product as @product" do
|
||||
product = Product.create! valid_attributes
|
||||
get :show, {:id => product.to_param}, valid_session
|
||||
get :show, {:id => product.to_param}
|
||||
assigns(:product).should eq(product)
|
||||
end
|
||||
end
|
||||
|
||||
describe "GET new" do
|
||||
it "assigns a new product as @product" do
|
||||
get :new, {}, valid_session
|
||||
get :new, {}
|
||||
assigns(:product).should be_a_new(Product)
|
||||
end
|
||||
end
|
||||
@@ -40,7 +42,7 @@ describe ProductsController do
|
||||
describe "GET edit" do
|
||||
it "assigns the requested product as @product" do
|
||||
product = Product.create! valid_attributes
|
||||
get :edit, {:id => product.to_param}, valid_session
|
||||
get :edit, {:id => product.to_param}
|
||||
assigns(:product).should eq(product)
|
||||
end
|
||||
end
|
||||
@@ -49,18 +51,18 @@ describe ProductsController do
|
||||
describe "with valid params" do
|
||||
it "creates a new Product" do
|
||||
expect {
|
||||
post :create, {:product => valid_attributes}, valid_session
|
||||
post :create, {:product => valid_attributes}
|
||||
}.to change(Product, :count).by(1)
|
||||
end
|
||||
|
||||
it "assigns a newly created product as @product" do
|
||||
post :create, {:product => valid_attributes}, valid_session
|
||||
post :create, {:product => valid_attributes}
|
||||
assigns(:product).should be_a(Product)
|
||||
assigns(:product).should be_persisted
|
||||
end
|
||||
|
||||
it "redirects to the created product" do
|
||||
post :create, {:product => valid_attributes}, valid_session
|
||||
post :create, {:product => valid_attributes}
|
||||
response.should redirect_to(Product.last)
|
||||
end
|
||||
end
|
||||
@@ -69,14 +71,14 @@ describe ProductsController do
|
||||
it "assigns a newly created but unsaved product as @product" do
|
||||
# Trigger the behavior that occurs when invalid params are submitted
|
||||
Product.any_instance.stub(:save).and_return(false)
|
||||
post :create, {:product => { "name" => "invalid value" }}, valid_session
|
||||
post :create, {:product => { "name" => "invalid value" }}
|
||||
assigns(:product).should be_a_new(Product)
|
||||
end
|
||||
|
||||
it "re-renders the 'new' template" do
|
||||
# Trigger the behavior that occurs when invalid params are submitted
|
||||
Product.any_instance.stub(:save).and_return(false)
|
||||
post :create, {:product => { "name" => "invalid value" }}, valid_session
|
||||
post :create, {:product => { "name" => "invalid value" }}
|
||||
response.should render_template("new")
|
||||
end
|
||||
end
|
||||
@@ -91,18 +93,18 @@ describe ProductsController do
|
||||
# receives the :update_attributes message with whatever params are
|
||||
# submitted in the request.
|
||||
Product.any_instance.should_receive(:update_attributes).with({ "name" => "MyString" })
|
||||
put :update, {:id => product.to_param, :product => { "name" => "MyString" }}, valid_session
|
||||
put :update, {:id => product.to_param, :product => { "name" => "MyString" }}
|
||||
end
|
||||
|
||||
it "assigns the requested product as @product" do
|
||||
product = Product.create! valid_attributes
|
||||
put :update, {:id => product.to_param, :product => valid_attributes}, valid_session
|
||||
put :update, {:id => product.to_param, :product => valid_attributes}
|
||||
assigns(:product).should eq(product)
|
||||
end
|
||||
|
||||
it "redirects to the product" do
|
||||
product = Product.create! valid_attributes
|
||||
put :update, {:id => product.to_param, :product => valid_attributes}, valid_session
|
||||
put :update, {:id => product.to_param, :product => valid_attributes}
|
||||
response.should redirect_to(product)
|
||||
end
|
||||
end
|
||||
@@ -112,7 +114,7 @@ describe ProductsController do
|
||||
product = Product.create! valid_attributes
|
||||
# Trigger the behavior that occurs when invalid params are submitted
|
||||
Product.any_instance.stub(:save).and_return(false)
|
||||
put :update, {:id => product.to_param, :product => { "name" => "invalid value" }}, valid_session
|
||||
put :update, {:id => product.to_param, :product => { "name" => "invalid value" }}
|
||||
assigns(:product).should eq(product)
|
||||
end
|
||||
|
||||
@@ -120,7 +122,7 @@ describe ProductsController do
|
||||
product = Product.create! valid_attributes
|
||||
# Trigger the behavior that occurs when invalid params are submitted
|
||||
Product.any_instance.stub(:save).and_return(false)
|
||||
put :update, {:id => product.to_param, :product => { "name" => "invalid value" }}, valid_session
|
||||
put :update, {:id => product.to_param, :product => { "name" => "invalid value" }}
|
||||
response.should render_template("edit")
|
||||
end
|
||||
end
|
||||
@@ -130,13 +132,13 @@ describe ProductsController do
|
||||
it "destroys the requested product" do
|
||||
product = Product.create! valid_attributes
|
||||
expect {
|
||||
delete :destroy, {:id => product.to_param}, valid_session
|
||||
delete :destroy, {:id => product.to_param}
|
||||
}.to change(Product, :count).by(-1)
|
||||
end
|
||||
|
||||
it "redirects to the products list" do
|
||||
product = Product.create! valid_attributes
|
||||
delete :destroy, {:id => product.to_param}, valid_session
|
||||
delete :destroy, {:id => product.to_param}
|
||||
response.should redirect_to(products_url)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe ShopController do
|
||||
|
||||
before :each do
|
||||
@product1 = FactoryGirl.create(:product)
|
||||
@product2 = FactoryGirl.create(:product)
|
||||
end
|
||||
|
||||
describe "GET index" do
|
||||
it "assigns all products as @products" do
|
||||
get :index, {}
|
||||
assigns(:products).should eq([@product1, @product2])
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
@@ -1,11 +0,0 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe "Orders" do
|
||||
describe "GET /orders" do
|
||||
it "works! (now write some real specs)" do
|
||||
# Run the generator again with the --webrat flag if you want to use webrat methods/matchers
|
||||
get orders_path
|
||||
response.status.should be(200)
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -1,11 +0,0 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe "Products" do
|
||||
describe "GET /products" do
|
||||
it "works! (now write some real specs)" do
|
||||
# Run the generator again with the --webrat flag if you want to use webrat methods/matchers
|
||||
get products_path
|
||||
response.status.should be(200)
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -2,7 +2,18 @@ require 'spec_helper'
|
||||
|
||||
describe 'shop/index.html.haml', :type => "view" do
|
||||
before(:each) do
|
||||
@product1 = FactoryGirl.create(:product)
|
||||
@product2 = FactoryGirl.create(:product)
|
||||
assign(:products, [@product1, @product2])
|
||||
render
|
||||
end
|
||||
|
||||
it 'shows products' do
|
||||
assert_select("h2", :text => @product1.name)
|
||||
end
|
||||
|
||||
it 'shows prices in AUD' do
|
||||
rendered.should contain '9.99 AUD'
|
||||
end
|
||||
|
||||
end
|
||||
Reference in new issue
Block a user