Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Neeraj Singh committed Jan 27, 2012
0 parents commit f51989e
Show file tree
Hide file tree
Showing 25 changed files with 300 additions and 0 deletions.
13 changes: 13 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
.bundle
db/*.sqlite3
log/*.log
tmp/
.sass-cache/
vendor/ruby
config/database.yml
guides/output
public/assets
public/uploads
.DS_Store
.tddium*
.tddium
1 change: 1 addition & 0 deletions .rvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
rvm use ruby-1.9.2-p180@nimbleshop
6 changes: 6 additions & 0 deletions spec/factories/country_shipping_zone_factory.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
FactoryGirl.define do
factory :country_shipping_zone do |f|
name "USA"
code "US"
end
end
13 changes: 13 additions & 0 deletions spec/factories/creditcard_factory.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FactoryGirl.define do
factory :creditcard do |f|
cvv '123'
number '4007000000027'
cardtype 'visa'
first_name 'Johnny'
last_name 'Walker'
address1 '100 Main street'
state 'Florida'
zipcode '33333'
expires_on { 1.year.from_now }
end
end
6 changes: 6 additions & 0 deletions spec/factories/custom_field_answer_factory.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
FactoryGirl.define do
factory :custom_field_answer do
custom_field
product
end
end
21 changes: 21 additions & 0 deletions spec/factories/custom_field_factory.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
FactoryGirl.define do
factory :custom_field do
sequence(:name) { |t| "name#{t}" }

trait :number do
field_type 'number'
end

trait :date do
field_type 'date'
end

trait :text do
field_type 'text'
end

factory :number_custom_field, traits: [:number]
factory :date_custom_field, traits: [:date ]
factory :text_custom_field, traits: [:text]
end
end
8 changes: 8 additions & 0 deletions spec/factories/line_item_factory.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
FactoryGirl.define do
factory :line_item do |f|
order
product
quantity 1
end
end

5 changes: 5 additions & 0 deletions spec/factories/link_group_factory.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
FactoryGirl.define do
factory :link_group do
sequence(:name) { |t| "name#{t}" }
end
end
6 changes: 6 additions & 0 deletions spec/factories/order_factory.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
FactoryGirl.define do
factory :order do |f|
sequence(:number) { |t| "xxx#{t}" }
end
end

5 changes: 5 additions & 0 deletions spec/factories/payment_method_factory.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
FactoryGirl.define do
factory :payment_method do |f|
name 'Cash'
end
end
8 changes: 8 additions & 0 deletions spec/factories/picture_factory.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
FactoryGirl.define do
factory :picture do |f|
product
file_name nil
content_type nil
file_size nil
end
end
40 changes: 40 additions & 0 deletions spec/factories/product_group_condition_factory.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
FactoryGirl.define do
factory :product_group_condition do

trait :price_condition do
name :price
operator 'lt'
value 43
end

trait :name_condition do
name :name
operator 'starts'
value 'george'
end

trait :text_condition do
name { Factory.create(:text_custom_field).id }
operator 'starts'
value 'george'
end

trait :number_condition do
name { Factory.create(:number_custom_field).id }
operator 'lt'
value 43
end

trait :date_condition do
name { Factory.create(:date_custom_field).id }
operator 'gt'
value { '1/1/2001' }
end

factory :date_group_condition, :traits => [ :date_condition ]
factory :text_group_condition, :traits => [ :text_condition ]
factory :number_group_condition,:traits => [ :number_condition ]
factory :price_group_condition, :traits => [ :price_condition ]
factory :name_group_condition, :traits => [ :name_condition ]
end
end
5 changes: 5 additions & 0 deletions spec/factories/product_group_factory.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
FactoryGirl.define do
factory :product_group do
sequence(:name) { |t| "name#{t}" }
end
end
11 changes: 11 additions & 0 deletions spec/factories/products_factory.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
FactoryGirl.define do
factory :product do
sequence(:name) { |t| "name#{t}" }
sequence(:description) { |t| "This is product description#{t}" }
price 50

# When a product is created through admin interface then carrierwave creates a record for each product
# even if no picture is uploaded
after_create { |product| product.pictures.create }
end
end
7 changes: 7 additions & 0 deletions spec/factories/regional_shipping_zone_factory.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
FactoryGirl.define do
factory :regional_shipping_zone do |f|
country_shipping_zone
code "AL"
name "ALABAMA"
end
end
21 changes: 21 additions & 0 deletions spec/factories/shipping_method_factory.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
FactoryGirl.define do
factory :shipping_method do
sequence(:name) { |t| "name#{t}" }

trait :country do
association :shipping_zone, :factory => :country_shipping_zone
lower_price_limit 10
upper_price_limit 20
base_price 2.99
end

trait :regional do
association :shipping_zone, :factory => :regional_shipping_zone
offset 1.00
association :parent, :factory => :country_shipping_method
end

factory :country_shipping_method, traits: [:country]
factory :regional_shipping_method, traits: [:regional]
end
end
9 changes: 9 additions & 0 deletions spec/factories/shop_factory.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
FactoryGirl.define do
factory :shop do |f|
sequence(:name){|n| "store-#{n}"}
twitter_handle '@nimbleshop'
intercept_email 'johnnie.walker@nimbleshop.com'
from_email 'support@nimbleshop.com'
end
end

10 changes: 10 additions & 0 deletions spec/factories/variant_factory.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
FactoryGirl.define do
factory :variant do |f|
product
price 100
variation1_value 'v1'
variation2_value 'v2'
variation3_value 'v3'
end
end

8 changes: 8 additions & 0 deletions spec/factories/variation_factory.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
FactoryGirl.define do
factory :variantion do |f|
product
name 'Color'
variation_type 'variation1'
active false
end
end
11 changes: 11 additions & 0 deletions spec/fixtures/creditcard_transactions.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
record1:
order_id: 1
transaction_gid: 21786353
amount: 100.0
creditcard_id: 200
status: t
params: ! '---
amount: 106.00
creditcard_id: 1
active: true
status: authorized
4 changes: 4 additions & 0 deletions spec/fixtures/creditcards.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
record1:
masked_number: XXXX-XXXX-XXXX-0027
expires_on: <%= 2.months.from_now %>
cardtype: visa
17 changes: 17 additions & 0 deletions spec/mailers/mailer_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
require "spec_helper"

describe Mailer do

before do
ActionMailer::Base.deliveries.clear
end

let(:order) { create(:order) }

describe '#order_notification' do
it 'should have one creditcard record if fixtures are read properly' do
Creditcard.count.must_equal 1
end
end

end
54 changes: 54 additions & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
require 'bundler'

Bundler.setup(:test)

ENV["RAILS_ENV"] = "test"

require File.expand_path('../../config/environment', __FILE__)

require 'minitest/autorun'
require 'minitest/spec'
require "minitest/rails"
require "minitest/pride"
require "capybara/rails"
require 'database_cleaner'
#require "capybara-webkit"
require 'rails/test_help'

#Capybara.default_driver = :webkit

# Require ruby files in support dir.
Dir[File.expand_path('spec/support/*.rb')].each { |file| require file }

# Do not change to :transaction since :truncation is much faster.
DatabaseCleaner.strategy = :truncation

class MiniTest::Spec
include Factory::Syntax::Methods
include ActiveSupport::Testing::SetupAndTeardown
include ActiveRecord::TestFixtures

alias :method_name :__name__ if defined? :__name__
self.fixture_path = File.join(Rails.root, 'spec', 'fixtures')
fixtures :all

# Add methods to be used by all specs here...
before :each do
DatabaseCleaner.clean

create(:shop)
create(:link_group, name: "Shop by category", permalink: 'shop-by-category')
create(:link_group, name: "Shop by price", permalink: 'shop-by-price')
PaymentMethod.load_default!
end
end


def create_authorizenet_payment_method
unless PaymentMethod.find_by_permalink('authorize-net')
payment_method = PaymentMethod::AuthorizeNet.create!(name: 'Authorize.net')
payment_method.authorize_net_login_id = '56yBAar72'
payment_method.authorize_net_transaction_key = '9r3pbH5bnKH29f7d'
payment_method.save!
end
end
5 changes: 5 additions & 0 deletions spec/support/must_be_like.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class Object
def must_be_like other
gsub(/\s+/, ' ').strip.must_equal other.gsub(/\s+/, ' ').strip
end
end
6 changes: 6 additions & 0 deletions spec/support/request_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
class RequestSpec < MiniTest::Spec
include Capybara::DSL
include Rails.application.routes.url_helpers
end

MiniTest::Spec.register_spec_type /integration$/i, RequestSpec

0 comments on commit f51989e

Please sign in to comment.