-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
98 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
class ChangeColumnInCartsTable < ActiveRecord::Migration | ||
def change | ||
change_column :carts, :unit_price, :decimal, {:precision => 8, :scale =>2} | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
|
||
[1mFrom:[0m /home/shaleenchugh/development/eshop/app/models/cart.rb @ line 10 Cart.items_in_cart: | ||
|
||
[1;34m8[0m: [32mdef[0m [1;36mself[0m.[1;34mitems_in_cart[0m(session_id) | ||
[1;34m9[0m: cart_json = [1;36mself[0m.where([31m[1;31m'[0m[31msession_id = ?[1;31m'[0m[31m[0m, session_id).as_json | ||
=> [1;34m10[0m: binding.pry | ||
[1;34m11[0m: cart_json.collect [32mdo[0m |line_item| | ||
[1;34m12[0m: product = line_item[[31m[1;31m'[0m[31mproduct[1;31m'[0m[31m[0m] | ||
[1;34m13[0m: { | ||
[1;34m14[0m: [33m:name[0m => product[[31m[1;31m'[0m[31mname[1;31m'[0m[31m[0m], | ||
[1;34m15[0m: [33m:number[0m => product[[31m[1;31m'[0m[31mdescription[1;31m'[0m[31m[0m], | ||
[1;34m16[0m: [33m:quantity[0m => line_item[[31m[1;31m'[0m[31mquantity[1;31m'[0m[31m[0m], | ||
[1;34m17[0m: [33m:amount[0m => line_item[[31m[1;31m'[0m[31munit_price[1;31m'[0m[31m[0m] * [1;34m100[0m | ||
[1;34m18[0m: } | ||
[1;34m19[0m: [32mend[0m | ||
[1;34m20[0m: | ||
[1;34m21[0m: [32mend[0m | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') | ||
|
||
describe Address do | ||
it { should belong_to :user } | ||
it { should belong_to :address_type } | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') | ||
|
||
describe AddressType do | ||
it { should have_many :addresses } | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') | ||
|
||
describe Cart do | ||
before :each do | ||
cart_item = Cart.new :product_id => 18, :unit_price => 6.50, :quantity => 7, :session_id => 999 | ||
cart_item2 = Cart.new :product_id => 29, :unit_price => 12.50, :quantity => 10, :session_id => 999 | ||
cart_item.save | ||
cart_item2.save | ||
end | ||
it { should belong_to :product } | ||
|
||
it "should get the right total" do | ||
expect(described_class.total(999)).to eq(170.50) | ||
end | ||
|
||
it "should have the correct items" do | ||
described_class.any_instance.stub(:as_json).and_return('product' => {'name' => 'Soap','description' => "Some desc" }, | ||
'quantity' => 10, 'unit_price' => 5 | ||
) | ||
|
||
result = [{:name=>"Soap", :description=>"Some desc", :quantity=>10, :amount=>50}, {:name=>"Soap", :description=>"Some desc", :quantity=>10, :amount=>50}] | ||
expect(described_class.items_in_cart(999)).to eq(result) | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') | ||
|
||
describe Category do | ||
it { should have_many :products } | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,26 @@ | ||
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') | ||
|
||
describe User do | ||
|
||
it { should have_many :orders } | ||
it { should have_many :addresses } | ||
it { should have_many :phones } | ||
|
||
=begin | ||
decribe "callbacks" do | ||
it "should call hash_password before a save" do | ||
model = stub_model(User) | ||
model.stub(:valid?).and_return(true) | ||
model.should_receive(:hash_password) | ||
model.save | ||
end | ||
describe "callbacks" do | ||
it "should call hash_password before a save" do | ||
model = stub_model(User) | ||
model.stub(:valid?).and_return(true) | ||
model.should_receive(:hash_password) | ||
model.save | ||
end | ||
|
||
# test your method works... | ||
it "should set hash the password" do | ||
model = stub_model(User, :encrypted_password => "donotreveal").as_new_record | ||
Digest::SHA1.stub(:hexdigest).and_return('other') | ||
model.send :hash_password | ||
model.encrypted_password.should_not == "donotreveal" | ||
end | ||
it "should set hash the password" do | ||
model = stub_model(User, :encrypted_password => "donotreveal").as_new_record | ||
Digest::SHA1.stub(:hexdigest).and_return('other') | ||
model.send :hash_password | ||
model.encrypted_password.should_not == "donotreveal" | ||
end | ||
end | ||
end | ||
end=end | ||
|