ecom 0.1.1 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +2 -0
- data/app/controllers/ecom/cart_controller.rb +28 -38
- data/app/controllers/ecom/products_controller.rb +1 -1
- data/app/models/ecom/category.rb +2 -0
- data/app/models/ecom/line_item.rb +3 -6
- data/app/models/ecom/product.rb +4 -3
- data/app/models/ecom/purchase.rb +12 -3
- data/app/models/ecom/user.rb +1 -1
- data/app/uploaders/ecom/image_uploader.rb +2 -2
- data/app/views/ecom/cart/show.html.erb +8 -9
- data/app/views/ecom/products/_form.html.erb +4 -4
- data/app/views/ecom/products/index.html.erb +27 -9
- data/app/views/ecom/products/show.html.erb +7 -10
- data/config/initializers/devise.rb +2 -2
- data/config/routes.rb +6 -11
- data/lib/ecom/engine.rb +1 -1
- data/lib/ecom/version.rb +1 -1
- data/lib/generators/ecom/install_generator.rb +2 -0
- data/test/controllers/ecom/cart_controller_test.rb +13 -0
- data/test/controllers/ecom/products_controller_test.rb +52 -0
- data/test/dummy/Rakefile +6 -0
- data/test/dummy/app/assets/config/manifest.js +5 -0
- data/test/dummy/app/assets/javascripts/application.js +13 -0
- data/test/dummy/app/assets/javascripts/cable.js +13 -0
- data/test/dummy/app/assets/stylesheets/application.css +15 -0
- data/test/dummy/app/channels/application_cable/channel.rb +4 -0
- data/test/dummy/app/channels/application_cable/connection.rb +4 -0
- data/test/dummy/app/controllers/application_controller.rb +3 -0
- data/test/dummy/app/helpers/application_helper.rb +2 -0
- data/test/dummy/app/jobs/application_job.rb +2 -0
- data/test/dummy/app/mailers/application_mailer.rb +4 -0
- data/test/dummy/app/models/application_record.rb +3 -0
- data/test/dummy/app/views/layouts/application.html.erb +14 -0
- data/test/dummy/app/views/layouts/mailer.html.erb +13 -0
- data/test/dummy/app/views/layouts/mailer.text.erb +1 -0
- data/test/dummy/bin/bundle +3 -0
- data/test/dummy/bin/rails +4 -0
- data/test/dummy/bin/rake +4 -0
- data/test/dummy/bin/setup +34 -0
- data/test/dummy/bin/update +29 -0
- data/test/dummy/config.ru +5 -0
- data/test/dummy/config/application.rb +15 -0
- data/test/dummy/config/boot.rb +5 -0
- data/test/dummy/config/cable.yml +9 -0
- data/test/dummy/config/database.yml +25 -0
- data/test/dummy/config/environment.rb +5 -0
- data/test/dummy/config/environments/development.rb +54 -0
- data/test/dummy/config/environments/production.rb +86 -0
- data/test/dummy/config/environments/test.rb +42 -0
- data/test/dummy/config/initializers/application_controller_renderer.rb +6 -0
- data/test/dummy/config/initializers/assets.rb +11 -0
- data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/test/dummy/config/initializers/cookies_serializer.rb +5 -0
- data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/test/dummy/config/initializers/inflections.rb +16 -0
- data/test/dummy/config/initializers/mime_types.rb +4 -0
- data/test/dummy/config/initializers/new_framework_defaults.rb +24 -0
- data/test/dummy/config/initializers/session_store.rb +3 -0
- data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/test/dummy/config/locales/en.yml +23 -0
- data/test/dummy/config/mongoid.yml +143 -0
- data/test/dummy/config/puma.rb +47 -0
- data/test/dummy/config/routes.rb +3 -0
- data/test/dummy/config/secrets.yml +22 -0
- data/test/dummy/config/spring.rb +6 -0
- data/test/dummy/db/development.sqlite3 +0 -0
- data/test/dummy/log/development.log +8 -0
- data/test/dummy/public/404.html +67 -0
- data/test/dummy/public/422.html +67 -0
- data/test/dummy/public/500.html +66 -0
- data/test/dummy/public/apple-touch-icon-precomposed.png +0 -0
- data/test/dummy/public/apple-touch-icon.png +0 -0
- data/test/dummy/public/favicon.ico +0 -0
- data/test/ecom_test.rb +7 -0
- data/test/fixtures/ecom/categories.yml +7 -0
- data/test/fixtures/ecom/line_items.yml +9 -0
- data/test/fixtures/ecom/products.yml +13 -0
- data/test/fixtures/ecom/purchases.yml +11 -0
- data/test/fixtures/ecom/users.yml +11 -0
- data/test/integration/navigation_test.rb +8 -0
- data/test/models/ecom/category_test.rb +9 -0
- data/test/models/ecom/line_item_test.rb +9 -0
- data/test/models/ecom/product_test.rb +9 -0
- data/test/models/ecom/purchase_test.rb +9 -0
- data/test/models/ecom/user_test.rb +9 -0
- data/test/test_helper.rb +20 -0
- metadata +156 -19
- data/app/assets/javascripts/ecom/categories.js +0 -2
- data/app/assets/stylesheets/ecom/categories.css +0 -4
- data/app/controllers/ecom/categories_controller.rb +0 -62
- data/app/helpers/ecom/categories_helper.rb +0 -4
- data/app/views/ecom/categories/_form.html.erb +0 -22
- data/app/views/ecom/categories/edit.html.erb +0 -6
- data/app/views/ecom/categories/index.html.erb +0 -27
- data/app/views/ecom/categories/new.html.erb +0 -5
- data/app/views/ecom/categories/show.html.erb +0 -9
- data/config/initializers/line_items.rb +0 -1
- data/config/initializers/product.rb +0 -1
- data/config/initializers/purchase.rb +0 -1
- data/config/locales/en.yml +0 -5
@@ -1,62 +0,0 @@
|
|
1
|
-
require_dependency "ecom/application_controller"
|
2
|
-
|
3
|
-
module Ecom
|
4
|
-
class CategoriesController < ApplicationController
|
5
|
-
before_action :set_category, only: [:show, :edit, :update, :destroy]
|
6
|
-
|
7
|
-
# GET /categories
|
8
|
-
def index
|
9
|
-
@categories = Category.all
|
10
|
-
end
|
11
|
-
|
12
|
-
# GET /categories/1
|
13
|
-
def show
|
14
|
-
end
|
15
|
-
|
16
|
-
# GET /categories/new
|
17
|
-
def new
|
18
|
-
@category = Category.new
|
19
|
-
end
|
20
|
-
|
21
|
-
# GET /categories/1/edit
|
22
|
-
def edit
|
23
|
-
end
|
24
|
-
|
25
|
-
# POST /categories
|
26
|
-
def create
|
27
|
-
@category = Category.new(category_params)
|
28
|
-
|
29
|
-
if @category.save
|
30
|
-
redirect_to @category, notice: 'Category was successfully created.'
|
31
|
-
else
|
32
|
-
render :new
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
# PATCH/PUT /categories/1
|
37
|
-
def update
|
38
|
-
if @category.update(category_params)
|
39
|
-
redirect_to @category, notice: 'Category was successfully updated.'
|
40
|
-
else
|
41
|
-
render :edit
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
# DELETE /categories/1
|
46
|
-
def destroy
|
47
|
-
@category.destroy
|
48
|
-
redirect_to categories_url, notice: 'Category was successfully destroyed.'
|
49
|
-
end
|
50
|
-
|
51
|
-
private
|
52
|
-
# Use callbacks to share common setup or constraints between actions.
|
53
|
-
def set_category
|
54
|
-
@category = Category.find(params[:id])
|
55
|
-
end
|
56
|
-
|
57
|
-
# Only allow a trusted parameter "white list" through.
|
58
|
-
def category_params
|
59
|
-
params.require(:category).permit(:title)
|
60
|
-
end
|
61
|
-
end
|
62
|
-
end
|
@@ -1,22 +0,0 @@
|
|
1
|
-
<%= form_for(category) do |f| %>
|
2
|
-
<% if category.errors.any? %>
|
3
|
-
<div id="error_explanation">
|
4
|
-
<h2><%= pluralize(category.errors.count, "error") %> prohibited this category from being saved:</h2>
|
5
|
-
|
6
|
-
<ul>
|
7
|
-
<% category.errors.full_messages.each do |message| %>
|
8
|
-
<li><%= message %></li>
|
9
|
-
<% end %>
|
10
|
-
</ul>
|
11
|
-
</div>
|
12
|
-
<% end %>
|
13
|
-
|
14
|
-
<div class="field">
|
15
|
-
<%= f.label :title %>
|
16
|
-
<%= f.text_field :title %>
|
17
|
-
</div>
|
18
|
-
|
19
|
-
<div class="actions">
|
20
|
-
<%= f.submit %>
|
21
|
-
</div>
|
22
|
-
<% end %>
|
@@ -1,27 +0,0 @@
|
|
1
|
-
<p id="notice"><%= notice %></p>
|
2
|
-
|
3
|
-
<h1>Categories</h1>
|
4
|
-
|
5
|
-
<table>
|
6
|
-
<thead>
|
7
|
-
<tr>
|
8
|
-
<th>Title</th>
|
9
|
-
<th colspan="3"></th>
|
10
|
-
</tr>
|
11
|
-
</thead>
|
12
|
-
|
13
|
-
<tbody>
|
14
|
-
<% @categories.each do |category| %>
|
15
|
-
<tr>
|
16
|
-
<td><%= category.title %></td>
|
17
|
-
<td><%= link_to 'Show', category %></td>
|
18
|
-
<td><%= link_to 'Edit', edit_category_path(category) %></td>
|
19
|
-
<td><%= link_to 'Destroy', category, method: :delete, data: { confirm: 'Are you sure?' } %></td>
|
20
|
-
</tr>
|
21
|
-
<% end %>
|
22
|
-
</tbody>
|
23
|
-
</table>
|
24
|
-
|
25
|
-
<br>
|
26
|
-
|
27
|
-
<%= link_to 'New Category', new_category_path %>
|
@@ -1 +0,0 @@
|
|
1
|
-
require Rails.root.join('app','models','ecom','line_item.rb')
|
@@ -1 +0,0 @@
|
|
1
|
-
require Rails.root.join('app','models','ecom','product.rb')
|
@@ -1 +0,0 @@
|
|
1
|
-
require Rails.root.join('app','models','ecom','purchase.rb')
|