Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Annotate models + Order scope bug #31

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions Gemfile
Expand Up @@ -5,6 +5,7 @@ gem 'rails', '3.2.11'
group :development do
gem 'sqlite3'
gem 'pry-rails'
gem 'annotate', ">=2.5.0"
end

group :production do
Expand Down
3 changes: 3 additions & 0 deletions Gemfile.lock
Expand Up @@ -32,6 +32,8 @@ GEM
activesupport (>= 3.0.14)
multi_xml (~> 0.2.0)
rest-client (~> 1.6.1)
annotate (2.5.0)
rake
arel (3.0.2)
bourne (1.1.2)
mocha (= 0.10.5)
Expand Down Expand Up @@ -154,6 +156,7 @@ PLATFORMS

DEPENDENCIES
amazon_flex_pay
annotate (>= 2.5.0)
coffee-rails (~> 3.2.1)
jquery-rails
pg
Expand Down
29 changes: 28 additions & 1 deletion app/models/order.rb
@@ -1,11 +1,38 @@
# == Schema Information
#
# Table name: orders
#
# token :string(255)
# transaction_id :string(255)
# address_one :string(255)
# address_two :string(255)
# city :string(255)
# state :string(255)
# zip :string(255)
# country :string(255)
# status :string(255)
# number :string(255)
# uuid :string(255) primary key
# user_id :string(255)
# price :decimal(, )
# shipping :decimal(, )
# tracking_number :string(255)
# phone :string(255)
# name :string(255)
# expiration :date
# created_at :datetime not null
# updated_at :datetime not null
# payment_option_id :integer
#

class Order < ActiveRecord::Base
attr_accessible :address_one, :address_two, :city, :country, :number, :state, :status, :token, :transaction_id, :zip,
:shipping, :tracking_number, :name, :price, :phone, :expiration, :payment_option
attr_readonly :uuid
before_validation :generate_uuid!, :on => :create
belongs_to :user
belongs_to :payment_option
scope :completed, where("token != ? OR token != ?", "", nil)
scope :completed, where("token != ? OR token IS NOT NULL", "")
self.primary_key = 'uuid'

# This is where we create our Caller Reference for Amazon Payments, and prefill some other information.
Expand Down
15 changes: 15 additions & 0 deletions app/models/payment_option.rb
@@ -1,3 +1,18 @@
# == Schema Information
#
# Table name: payment_options
#
# id :integer not null, primary key
# amount :decimal(, )
# amount_display :string(255)
# description :text
# shipping_desc :string(255)
# delivery_desc :string(255)
# limit :integer
# created_at :datetime not null
# updated_at :datetime not null
#

class PaymentOption < ActiveRecord::Base
attr_accessible :amount, :amount_display, :delivery_desc, :description, :limit, :shipping_desc
has_many :orders
Expand Down
10 changes: 10 additions & 0 deletions app/models/user.rb
@@ -1,3 +1,13 @@
# == Schema Information
#
# Table name: users
#
# id :integer not null, primary key
# email :string(255)
# created_at :datetime not null
# updated_at :datetime not null
#

class User < ActiveRecord::Base
attr_accessible :email
has_many :orders
Expand Down
29 changes: 28 additions & 1 deletion spec/models/order_spec.rb
@@ -1,3 +1,30 @@
# == Schema Information
#
# Table name: orders
#
# token :string(255)
# transaction_id :string(255)
# address_one :string(255)
# address_two :string(255)
# city :string(255)
# state :string(255)
# zip :string(255)
# country :string(255)
# status :string(255)
# number :string(255)
# uuid :string(255) primary key
# user_id :string(255)
# price :decimal(, )
# shipping :decimal(, )
# tracking_number :string(255)
# phone :string(255)
# name :string(255)
# expiration :date
# created_at :datetime not null
# updated_at :datetime not null
# payment_option_id :integer
#

describe Order do

context "attributes" do
Expand Down Expand Up @@ -206,4 +233,4 @@

end

end
end
15 changes: 15 additions & 0 deletions spec/models/payment_option_spec.rb
@@ -1,3 +1,18 @@
# == Schema Information
#
# Table name: payment_options
#
# id :integer not null, primary key
# amount :decimal(, )
# amount_display :string(255)
# description :text
# shipping_desc :string(255)
# delivery_desc :string(255)
# limit :integer
# created_at :datetime not null
# updated_at :datetime not null
#

require 'spec_helper'

describe PaymentOption do
Expand Down
12 changes: 11 additions & 1 deletion spec/models/user_spec.rb
@@ -1,6 +1,16 @@
# == Schema Information
#
# Table name: users
#
# id :integer not null, primary key
# email :string(255)
# created_at :datetime not null
# updated_at :datetime not null
#

describe User do

it { should have_many :orders }
it { should respond_to :email }

end
end