mechanize_store 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- YjA4YWI3ODY4YzFjZjc3NTQ5OGE2NmEzNzg3YThkNjM0OWUwNjMxMg==
4
+ ZGQ3NmJmNmExMDhhYjlmZjdkYTMyZjM2NWYyNDdjMTAzMTk2MmIyMA==
5
5
  data.tar.gz: !binary |-
6
- MDlmZTY1OWIxZTFiNGJkZjE4M2MyYjM1ODNkNDUzZDAzNmRiOTYxMg==
6
+ NDIyY2Y2ZGU2NWNiYmVhY2NhOTZmZDE5NGZhMTFhYjBmM2U4ZDQzYg==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- N2ZjMDBhMWJlNzc1ZTc5OTJmNDgxYTU5MWQzZDgxYzc1ZTkwYWY1ZmQxOThl
10
- NjkyMWU1ZWZhMzE4ODA5MGRlYmQyMzM5N2ZmM2ZjNGJhOWRlYzA0MTU5MWMw
11
- MTIyYTI1ODlhYjdkOWE2ZmMwMDhlZDc2ZTk0NDRmYTM5ZDdjZWM=
9
+ ZDU4ZTI4ZWY3MGNkYmY0OTAyMjhjZjI0OTE4YjI4NmNmMjEzNmJkNGFjZjQx
10
+ NTNhMDUxYmQ3YzhhZGZhNWQ5ZjE4NjYwOTg1YWNiNGFjOGFhZjAwMDExMjhj
11
+ MTY2ZGI5MmYyNTQ2ZmNkNDk3MTc1Zjc1NzhjZmExZWVhNDM3OGM=
12
12
  data.tar.gz: !binary |-
13
- MTgyYzJkZGZiNDdmNWY2ZDc2OTI2MTc5NmVlMWYwOTViYmRkZTE5YWRlMzFk
14
- M2RkMTZiZjhmYzVhZWU4YTJjYWRlOWRhMGE2ZDg2OGY4OWMzNzBiYWYzYjYw
15
- NTU0NDkwODcwZjQ5YWNjZjhjYWM3MGE5M2QxZDdkMmQ5MzRlMTA=
13
+ MDI1M2E0Y2ViNTg4NmE2MjI1MGM0ZWNkOWMyYjU5ZTVlZTVkZGFkZWUyMjU0
14
+ MTNjMzY2ZTAwYTc4ODBkZmJlNzczZDEzOWI4MzAwZDRjZDlmYWYyNmI5YmU1
15
+ ZGI0YjJmNGY4MzU1YWUwNjVkYzVkYjM4ZTZhNTY3ZmY1ODZlMTA=
@@ -71,7 +71,7 @@ module MechanizeStore
71
71
 
72
72
  # Only allow a trusted parameter "white list" through.
73
73
  def product_params
74
- params.require(:product).permit(:name, :description, :short_description, :price, :weight, :length, :height, :product_category_id)
74
+ params.require(:product).permit(:name, :description, :short_description, :width, :price, :weight, :length, :height, :product_category_id)
75
75
  end
76
76
  end
77
77
  end
@@ -1,4 +1,5 @@
1
1
  module MechanizeStore
2
2
  class Flag < ActiveRecord::Base
3
+ validates :name, presence: true
3
4
  end
4
5
  end
@@ -15,6 +15,8 @@ module MechanizeStore
15
15
  before_create :set_defaults
16
16
  after_create :after_create
17
17
 
18
+ validates :payment, :order_status_id, :freight, presence: true
19
+
18
20
  def set_defaults
19
21
  self.order_status_id = OrderStatus::ACCOMPLISHED
20
22
  end
@@ -3,6 +3,8 @@ module MechanizeStore
3
3
  belongs_to :order
4
4
  belongs_to :product
5
5
 
6
+ validates :quantity, :price, :product_id, presence: true
7
+
6
8
  def total
7
9
  self.quantity.to_f * self.price.to_f
8
10
  end
@@ -5,6 +5,12 @@ module MechanizeStore
5
5
  belongs_to :payment_type
6
6
  belongs_to :flag
7
7
 
8
- validates_presence_of :payment_type_id
8
+ validates :payment_type_id, :flag_id, presence: true
9
+
10
+ before_create :before_create
11
+
12
+ def before_create
13
+ self.payment_status_id = PaymentStatus::AWAITING
14
+ end
9
15
  end
10
16
  end
@@ -1,6 +1,7 @@
1
1
  module MechanizeStore
2
2
  class PaymentStatus < ActiveRecord::Base
3
-
3
+ validates :name, presence: true
4
+
4
5
  #ids inseridos na base de dados
5
6
  ACCOMPLISHED = 1
6
7
  IN_ANALISIS = 2
@@ -1,5 +1,5 @@
1
1
  module MechanizeStore
2
2
  class PaymentType < ActiveRecord::Base
3
-
3
+ validates :name, presence: true
4
4
  end
5
5
  end
@@ -3,6 +3,8 @@ module MechanizeStore
3
3
  belongs_to :product_category, class_name: MechanizeStore::ProductCategory
4
4
  has_many :product_photos, class_name: MechanizeStore::ProductPhoto
5
5
 
6
+ validates :name, :price, :description, :short_description, :weight, :length, :width, :height, presence: true
7
+
6
8
  def first_photo
7
9
  return nil if self.product_photos.empty?
8
10
  return self.product_photos.first
@@ -1,5 +1,7 @@
1
1
  module MechanizeStore
2
2
  class ProductCategory < ActiveRecord::Base
3
3
  belongs_to :product_category, class_name: MechanizeStore::ProductCategory
4
+
5
+ validates :name, presence: true
4
6
  end
5
7
  end
@@ -6,7 +6,7 @@ module MechanizeStore
6
6
  :styles => { :medium => "300x300>", :thumb => "100x100>" },
7
7
  :default_url => "/images/:style/missing.png",
8
8
  path: "#{Rails.root}/public/photos/:id/:style.:extension",
9
- url: "/photos/:id/:style.:extension"#,
9
+ url: "/photos/:id/:style.:extension"
10
10
  # storage: :s3,
11
11
  # s3_credentials: "#{Rails.root}/config/amazon_s3.yml"
12
12
 
@@ -1,3 +1,3 @@
1
1
  module MechanizeStore
2
- VERSION = "0.0.5"
2
+ VERSION = "0.0.6"
3
3
  end
@@ -6,9 +6,11 @@ module MechanizeStore
6
6
 
7
7
  before do
8
8
  @payment_type = FactoryGirl.create(:mechanize_store_payment_type)
9
- @payment = FactoryGirl.create(:mechanize_store_payment, payment_type: @payment_type)
9
+ @flag = FactoryGirl.create(:mechanize_store_flag)
10
+ @payment = FactoryGirl.build(:mechanize_store_payment, payment_type: @payment_type, flag: @flag)
10
11
  @order_status = FactoryGirl.create(:mechanize_store_order_status)
11
- @order = FactoryGirl.create(:mechanize_store_order, payment: @payment, order_status: @order_status)
12
+ @freight = FactoryGirl.create(:mechanize_store_freight)
13
+ @order = FactoryGirl.create(:mechanize_store_order, payment: @payment, order_status: @order_status, freight: @freight)
12
14
  end
13
15
 
14
16
  let(:valid_session) { {} }
@@ -5,7 +5,7 @@ module MechanizeStore
5
5
 
6
6
  routes { MechanizeStore::Engine.routes }
7
7
 
8
- let(:valid_attributes) { { "name" => "MyString" } }
8
+ let(:valid_attributes) { { "name" => "MyString", price: 10, width: 1, height: 2, length: 2, weight: 1, description: "Product description", short_description: "Short" } }
9
9
  let(:valid_session) { {} }
10
10
 
11
11
  describe "GET index" do
Binary file
@@ -25409,3 +25409,88 @@ Processing by MechanizeStore::ProductsController#new as HTML
25409
25409
  Rendered /Users/wilbert/apps/mechanize_store/app/views/mechanize_store/products/_form.html.erb (218.5ms)
25410
25410
  Rendered /Users/wilbert/apps/mechanize_store/app/views/mechanize_store/products/new.html.erb (242.4ms)
25411
25411
  Completed 200 OK in 285ms (Views: 256.7ms | ActiveRecord: 0.8ms)
25412
+  (7.5ms) CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL) 
25413
+  (0.9ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
25414
+ ActiveRecord::SchemaMigration Load (0.2ms) SELECT "schema_migrations".* FROM "schema_migrations"
25415
+ Migrating to CreateMechanizeStoreFreights (20140508135827)
25416
+  (0.1ms) begin transaction
25417
+  (0.4ms) CREATE TABLE "mechanize_store_freights" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "value" float, "service" varchar(255), "order_id" integer, "zipcode" varchar(255), "created_at" datetime, "updated_at" datetime) 
25418
+  (0.1ms) CREATE INDEX "index_mechanize_store_freights_on_order_id" ON "mechanize_store_freights" ("order_id")
25419
+ SQL (3.1ms) INSERT INTO "schema_migrations" ("version") VALUES (?) [["version", "20140508135827"]]
25420
+  (0.8ms) commit transaction
25421
+ Migrating to CreateMechanizeStoreOrderStatuses (20140508135828)
25422
+  (0.1ms) begin transaction
25423
+  (0.4ms) CREATE TABLE "mechanize_store_order_statuses" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255), "created_at" datetime, "updated_at" datetime)
25424
+ SQL (0.1ms) INSERT INTO "schema_migrations" ("version") VALUES (?) [["version", "20140508135828"]]
25425
+  (0.7ms) commit transaction
25426
+ Migrating to CreateMechanizeStorePaymentStatuses (20140508135829)
25427
+  (0.1ms) begin transaction
25428
+  (0.4ms) CREATE TABLE "mechanize_store_payment_statuses" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255), "created_at" datetime, "updated_at" datetime)
25429
+ SQL (0.2ms) INSERT INTO "schema_migrations" ("version") VALUES (?) [["version", "20140508135829"]]
25430
+  (0.7ms) commit transaction
25431
+ Migrating to CreateMechanizeStorePaymentTypes (20140508135830)
25432
+  (0.1ms) begin transaction
25433
+  (0.3ms) CREATE TABLE "mechanize_store_payment_types" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255), "created_at" datetime, "updated_at" datetime)
25434
+ SQL (0.3ms) INSERT INTO "schema_migrations" ("version") VALUES (?) [["version", "20140508135830"]]
25435
+  (0.6ms) commit transaction
25436
+ Migrating to CreateMechanizeStorePayments (20140508135831)
25437
+  (0.1ms) begin transaction
25438
+  (0.3ms) CREATE TABLE "mechanize_store_payments" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "order_id" integer, "payment_status_id" integer, "value" float, "paid_value" float, "paid_in" datetime, "plot" integer, "flag_id" integer, "created_at" datetime, "updated_at" datetime)
25439
+  (0.1ms) CREATE INDEX "index_mechanize_store_payments_on_payment_status_id" ON "mechanize_store_payments" ("payment_status_id")
25440
+  (0.1ms) CREATE INDEX "index_mechanize_store_payments_on_flag_id" ON "mechanize_store_payments" ("flag_id")
25441
+ SQL (0.1ms) INSERT INTO "schema_migrations" ("version") VALUES (?) [["version", "20140508135831"]]
25442
+  (0.8ms) commit transaction
25443
+ Migrating to CreateMechanizeStoreFlags (20140508135832)
25444
+  (0.1ms) begin transaction
25445
+  (0.3ms) CREATE TABLE "mechanize_store_flags" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255), "created_at" datetime, "updated_at" datetime)
25446
+ SQL (0.1ms) INSERT INTO "schema_migrations" ("version") VALUES (?) [["version", "20140508135832"]]
25447
+  (0.7ms) commit transaction
25448
+ Migrating to CreateMechanizeStoreProducts (20140508135833)
25449
+  (0.1ms) begin transaction
25450
+  (0.4ms) CREATE TABLE "mechanize_store_products" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255), "description" text, "short_description" varchar(255), "price" float, "weight" float, "length" float, "height" float, "product_category_id" integer, "created_at" datetime, "updated_at" datetime)
25451
+  (0.3ms) CREATE INDEX "index_mechanize_store_products_on_product_category_id" ON "mechanize_store_products" ("product_category_id")
25452
+ SQL (0.1ms) INSERT INTO "schema_migrations" ("version") VALUES (?) [["version", "20140508135833"]]
25453
+  (0.6ms) commit transaction
25454
+ Migrating to CreateMechanizeStoreProductPhotos (20140508135834)
25455
+  (0.1ms) begin transaction
25456
+  (0.3ms) CREATE TABLE "mechanize_store_product_photos" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "file_file_name" varchar(255), "file_content_type" varchar(255), "file_file_size" integer, "file_updated_at" datetime, "product_id" integer, "created_at" datetime, "updated_at" datetime) 
25457
+  (0.1ms) CREATE INDEX "index_mechanize_store_product_photos_on_product_id" ON "mechanize_store_product_photos" ("product_id")
25458
+ SQL (0.1ms) INSERT INTO "schema_migrations" ("version") VALUES (?) [["version", "20140508135834"]]
25459
+  (0.7ms) commit transaction
25460
+ Migrating to CreateMechanizeStoreOrders (20140508135835)
25461
+  (0.1ms) begin transaction
25462
+  (0.4ms) CREATE TABLE "mechanize_store_orders" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "order_status_id" integer, "store_id" integer, "delivery_date" datetime, "created_at" datetime, "updated_at" datetime)
25463
+  (0.1ms) CREATE INDEX "index_mechanize_store_orders_on_order_status_id" ON "mechanize_store_orders" ("order_status_id")
25464
+  (0.1ms) CREATE INDEX "index_mechanize_store_orders_on_store_id" ON "mechanize_store_orders" ("store_id")
25465
+ SQL (0.1ms) INSERT INTO "schema_migrations" ("version") VALUES (?) [["version", "20140508135835"]]
25466
+  (0.8ms) commit transaction
25467
+ Migrating to CreateMechanizeStoreProductCategories (20140508135836)
25468
+  (0.1ms) begin transaction
25469
+  (0.3ms) CREATE TABLE "mechanize_store_product_categories" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255), "product_category_id" integer, "created_at" datetime, "updated_at" datetime)
25470
+ SQL (0.1ms) INSERT INTO "schema_migrations" ("version") VALUES (?) [["version", "20140508135836"]]
25471
+  (0.8ms) commit transaction
25472
+ Migrating to AddWidthToMechanizeStoreProduct (20140508135837)
25473
+  (0.1ms) begin transaction
25474
+  (0.3ms) ALTER TABLE "mechanize_store_products" ADD "width" float
25475
+ SQL (0.2ms) INSERT INTO "schema_migrations" ("version") VALUES (?) [["version", "20140508135837"]]
25476
+  (0.7ms) commit transaction
25477
+ Migrating to CreateMechanizeStoreOrderItems (20140508135838)
25478
+  (0.2ms) begin transaction
25479
+  (0.5ms) CREATE TABLE "mechanize_store_order_items" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "quantity" integer, "price" float, "order_id" integer, "product_id" integer, "created_at" datetime, "updated_at" datetime)
25480
+  (0.1ms) CREATE INDEX "index_mechanize_store_order_items_on_order_id" ON "mechanize_store_order_items" ("order_id")
25481
+  (0.1ms) CREATE INDEX "index_mechanize_store_order_items_on_product_id" ON "mechanize_store_order_items" ("product_id")
25482
+ SQL (0.2ms) INSERT INTO "schema_migrations" ("version") VALUES (?) [["version", "20140508135838"]]
25483
+  (0.9ms) commit transaction
25484
+ Migrating to AddPaymentTypeIdToPayment (20140508135839)
25485
+  (0.1ms) begin transaction
25486
+  (0.5ms) ALTER TABLE "mechanize_store_payments" ADD "payment_type_id" integer
25487
+  (0.2ms) CREATE INDEX "index_mechanize_store_payments_on_payment_type_id" ON "mechanize_store_payments" ("payment_type_id")
25488
+ SQL (0.2ms) INSERT INTO "schema_migrations" ("version") VALUES (?) [["version", "20140508135839"]]
25489
+  (0.8ms) commit transaction
25490
+ Migrating to AddTimeToFreight (20140508135840)
25491
+  (0.1ms) begin transaction
25492
+  (0.4ms) ALTER TABLE "mechanize_store_freights" ADD "delivery_time" integer
25493
+ SQL (0.2ms) INSERT INTO "schema_migrations" ("version") VALUES (?) [["version", "20140508135840"]]
25494
+  (0.7ms) commit transaction
25495
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
25496
+ MechanizeStore::Product Load (0.3ms) SELECT "mechanize_store_products".* FROM "mechanize_store_products" ORDER BY "mechanize_store_products"."id" ASC LIMIT 1