Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Whitespace cleanup

  • Loading branch information...
commit 1d63179ef1086e3d6ef6aeaa8b7456100beec2ce 1 parent 37f3b63
@myabc authored
Showing with 555 additions and 557 deletions.
  1. +1 −1  .gitignore
  2. +0 −1  CHANGELOG
  3. +1 −1  README
  4. +3 −3 Rakefile
  5. +0 −1  TODO
  6. +2 −2 app/controllers/admin/files.rb
  7. +2 −2 app/controllers/admin/orders.rb
  8. +2 −2 app/controllers/admin/preferences.rb
  9. +2 −2 app/controllers/admin/products.rb
  10. +2 −2 app/controllers/admin/promotions.rb
  11. +2 −2 app/controllers/admin/tags.rb
  12. +2 −2 app/controllers/customers.rb
  13. +2 −2 app/controllers/exceptions.rb
  14. +3 −3 app/controllers/sessions.rb
  15. +3 −3 app/controllers/store.rb
  16. +5 −5 app/controllers/users.rb
  17. +1 −1  app/helpers/admin/files_helper.rb
  18. +1 −1  app/helpers/admin/orders_helper.rb
  19. +1 −1  app/helpers/admin/products_helper.rb
  20. +1 −1  app/helpers/admin/promotions_helper.rb
  21. +1 −1  app/helpers/admin/sections_helper.rb
  22. +1 −1  app/helpers/admin/tags_helper.rb
  23. +1 −1  app/helpers/customers_helper.rb
  24. +1 −1  app/helpers/global_helpers.rb
  25. +4 −4 app/mailers/user_mailer.rb
  26. +1 −1  app/mailers/views/layout/application.html.erb
  27. +1 −1  app/mailers/views/layout/application.text.erb
  28. +1 −1  app/mailers/views/user_mailer/activation_notification.html.erb
  29. +1 −1  app/mailers/views/user_mailer/activation_notification.text.erb
  30. +1 −1  app/mailers/views/user_mailer/signup_notification.html.erb
  31. +1 −1  app/mailers/views/user_mailer/signup_notification.text.erb
  32. +2 −2 app/models/address.rb
  33. +3 −3 app/models/country.rb
  34. +2 −2 app/models/mart/abstract_upload.rb
  35. +4 −4 app/models/mart/accounts/abstract_account.rb
  36. +3 −3 app/models/mart/accounts/bank_account.rb
  37. +2 −2 app/models/mart/accounts/credit_card_account.rb
  38. +3 −3 app/models/mart/accounts/google_checkout_account.rb
  39. +1 −1  app/models/mart/accounts/paypal_account.rb
  40. +1 −1  app/models/mart/asset.rb
  41. +3 −3 app/models/mart/customer.rb
  42. +11 −11 app/models/mart/customers/cart.rb
  43. +5 −5 app/models/mart/customers/wishlist_item.rb
  44. +2 −2 app/models/mart/image.rb
  45. +7 −7 app/models/mart/order.rb
  46. +4 −4 app/models/mart/orders/line_item.rb
  47. +5 −5 app/models/mart/orders/status_code.rb
  48. +1 −1  app/models/mart/shipping/type.rb
  49. +2 −2 app/models/mart/shipping/weight.rb
  50. +4 −4 app/models/mart/store/abstract_item.rb
  51. +4 −4 app/models/mart/store/product.rb
  52. +3 −3 app/models/mart/store/product_image.rb
  53. +6 −6 app/models/mart/store/promotion.rb
  54. +3 −3 app/models/mart/store/variation.rb
  55. +3 −3 app/models/right.rb
  56. +2 −2 app/models/role.rb
  57. +3 −3 app/models/state.rb
  58. +6 −6 app/models/tag.rb
  59. +9 −9 app/models/user.rb
  60. +1 −1  app/parts/views/layout/application.html.haml
  61. +1 −1  app/views/customers/index.html.haml
  62. +2 −2 app/views/layout/application.html.haml
  63. +1 −1  app/views/store/index.html.haml
  64. +1 −1  app/views/users/new.html.haml
  65. +1 −1  autotest.bak/discover.rb
  66. +39 −39 autotest.bak/merb.rb
  67. +1 −1  config/environments/rake.rb
  68. +6 −6 config/init.rb
  69. +1 −1  config/rack.rb
  70. +4 −4 config/router.rb
  71. +9 −9 lib/authenticated_system/authenticated_system_controller.rb
  72. +12 −12 lib/authenticated_system/authenticated_system_model.rb
  73. +9 −9 lib/authenticated_system/authenticated_system_orm_map.rb
  74. +4 −4 lib/mart.rb
  75. +4 −4 public/merb.fcgi
  76. +3 −3 spec/authenticated_system_spec_helper.rb
  77. +1 −1  spec/controllers/admin/files_spec.rb
  78. +1 −1  spec/controllers/admin/orders_spec.rb
  79. +1 −1  spec/controllers/admin/preferences_spec.rb
  80. +1 −1  spec/controllers/admin/products_spec.rb
  81. +1 −1  spec/controllers/admin/promotions_spec.rb
  82. +1 −1  spec/controllers/admin/tags_spec.rb
  83. +1 −1  spec/controllers/customers_spec.rb
  84. +16 −16 spec/controllers/sessions_spec.rb
  85. +12 −12 spec/controllers/users_spec.rb
  86. +1 −1  spec/helpers/admin/files_helper_spec.rb
  87. +1 −1  spec/helpers/admin/orders_helper_spec.rb
  88. +1 −1  spec/helpers/admin/preferences_helper_spec.rb
  89. +1 −1  spec/helpers/admin/products_helper_spec.rb
  90. +1 −1  spec/helpers/admin/promotions_helper_spec.rb
  91. +1 −1  spec/helpers/admin/tags_helper_spec.rb
  92. +1 −1  spec/helpers/customers_helper_spec.rb
  93. +15 −15 spec/mailers/user_mailer_spec.rb
  94. +12 −12 spec/models/address_spec.rb
  95. +9 −9 spec/models/country_spec.rb
  96. +2 −2 spec/models/mart/abstract_upload_spec.rb
  97. +11 −11 spec/models/mart/accounts/abstract_account_spec.rb
  98. +1 −1  spec/models/mart/accounts/bank_account_spec.rb
  99. +1 −1  spec/models/mart/accounts/credit_card_account_spec.rb
  100. +1 −1  spec/models/mart/accounts/google_checkout_account_spec.rb
  101. +1 −1  spec/models/mart/accounts/paypal_account_spec.rb
  102. +4 −4 spec/models/mart/asset_spec.rb
  103. +14 −14 spec/models/mart/customer_spec.rb
  104. +6 −6 spec/models/mart/customers/cart_spec.rb
  105. +5 −5 spec/models/mart/customers/wishlist_item_spec.rb
  106. +6 −6 spec/models/mart/image_spec.rb
  107. +20 −20 spec/models/mart/order_spec.rb
  108. +3 −3 spec/models/mart/orders/line_item_spec.rb
  109. +3 −3 spec/models/mart/orders/status_code_spec.rb
  110. +4 −4 spec/models/mart/shipping/type_spec.rb
  111. +1 −1  spec/models/mart/shipping/weight_spec.rb
  112. +3 −3 spec/models/mart/store/abstract_item_spec.rb
  113. +2 −2 spec/models/mart/store/product_image_spec.rb
  114. +11 −11 spec/models/mart/store/product_spec.rb
  115. +3 −3 spec/models/mart/store/promotion_spec.rb
  116. +5 −5 spec/models/mart/store/variation_spec.rb
  117. +1 −1  spec/models/right_spec.rb
  118. +4 −4 spec/models/role_spec.rb
  119. +8 −8 spec/models/state_spec.rb
  120. +5 −5 spec/models/tag_spec.rb
  121. +78 −78 spec/models/user_spec.rb
  122. +1 −1  spec/user_spec_helper.rb
  123. +20 −20 spec/views/store/index_spec.rb
View
2  .gitignore
@@ -12,4 +12,4 @@ nbproject
pkg
pkg/*
tmp
-www/output
+www/output
View
1  CHANGELOG
@@ -1,2 +1 @@
= Change Log
-
View
2  README
@@ -1,4 +1,4 @@
= merb_mart
== Open-source e-commerce built on the Merb MVC Framework
-Please see README.markdown.
+Please see README.markdown.
View
6 Rakefile
@@ -11,13 +11,13 @@ require 'merb-core'
require 'rubigen'
include FileUtils
-# Load the basic runtime dependencies; this will include
+# Load the basic runtime dependencies; this will include
# any plugins and therefore plugin rake tasks.
init_env = ENV['MERB_ENV'] || 'rake'
Merb.load_dependencies(:environment => init_env)
-
+
# Get Merb plugins and dependencies
-Merb::Plugins.rakefiles.each { |r| require r }
+Merb::Plugins.rakefiles.each { |r| require r }
desc "start runner environment"
task :merb_env do
View
1  TODO
@@ -1,2 +1 @@
= To-Do
-
View
4 app/controllers/admin/files.rb
@@ -1,9 +1,9 @@
module Admin
class Files < Application
-
+
def index
render
end
-
+
end
end # Admin
View
4 app/controllers/admin/orders.rb
@@ -1,9 +1,9 @@
module Admin
class Orders < Application
-
+
def index
render
end
-
+
end
end # Admin
View
4 app/controllers/admin/preferences.rb
@@ -1,9 +1,9 @@
module Admin
class Preferences < Application
-
+
def index
render
end
-
+
end
end # Admin
View
4 app/controllers/admin/products.rb
@@ -1,9 +1,9 @@
module Admin
class Products < Application
-
+
def index
render
end
-
+
end
end # Admin
View
4 app/controllers/admin/promotions.rb
@@ -1,9 +1,9 @@
module Admin
class Promotions < Application
-
+
def index
render
end
-
+
end
end # Admin
View
4 app/controllers/admin/tags.rb
@@ -1,9 +1,9 @@
module Admin
class Tags < Application
-
+
def index
render
end
-
+
end
end # Admin
View
4 app/controllers/customers.rb
@@ -1,7 +1,7 @@
class Customers < Application
-
+
def index
render
end
-
+
end
View
4 app/controllers/exceptions.rb
@@ -1,5 +1,5 @@
class Exceptions < Application
-
+
# handle NotFound exceptions (404)
def not_found
render :format => :html
@@ -10,4 +10,4 @@ def not_acceptable
render :format => :html
end
-end
+end
View
6 app/controllers/sessions.rb
@@ -1,9 +1,9 @@
# require 'lib/authenticated_system_controller'
require File.join(File.dirname(__FILE__), '..', '..', "lib", "authenticated_system", "authenticated_dependencies")
class Sessions < Application
-
+
skip_before :login_required
-
+
def new
render
end
@@ -27,5 +27,5 @@ def destroy
reset_session
redirect_back_or_default('/')
end
-
+
end
View
6 app/controllers/store.rb
@@ -1,7 +1,7 @@
class Store < Application
-
+
def index
render
end
-
-end
+
+end
View
10 app/controllers/users.rb
@@ -1,18 +1,18 @@
require File.join(File.dirname(__FILE__), '..', '..', "lib", "authenticated_system", "authenticated_dependencies")
class Users < Application
provides :xml
-
+
skip_before :login_required
-
+
def new
only_provides :html
@user = User.new(params[:user] || {})
display @user
end
-
+
def create
cookies.delete :auth_token
-
+
@user = User.new(params[:user])
if @user.save
redirect_back_or_default('/')
@@ -20,7 +20,7 @@ def create
render :new
end
end
-
+
def activate
self.current_user = User.find_activated_authenticated_model(params[:activation_code])
if logged_in? && !current_user.active?
View
2  app/helpers/admin/files_helper.rb
@@ -4,4 +4,4 @@ module FilesHelper
end
end # Admin
-end
+end
View
2  app/helpers/admin/orders_helper.rb
@@ -4,4 +4,4 @@ module OrdersHelper
end
end # Admin
-end
+end
View
2  app/helpers/admin/products_helper.rb
@@ -4,4 +4,4 @@ module ProductsHelper
end
end # Admin
-end
+end
View
2  app/helpers/admin/promotions_helper.rb
@@ -4,4 +4,4 @@ module PromotionsHelper
end
end # Admin
-end
+end
View
2  app/helpers/admin/sections_helper.rb
@@ -4,4 +4,4 @@ module SectionsHelper
end
end # Admin
-end
+end
View
2  app/helpers/admin/tags_helper.rb
@@ -4,4 +4,4 @@ module TagsHelper
end
end # Admin
-end
+end
View
2  app/helpers/customers_helper.rb
@@ -2,4 +2,4 @@ module Merb
module CustomersHelper
end
-end
+end
View
2  app/helpers/global_helpers.rb
@@ -1,5 +1,5 @@
module Merb
module GlobalHelpers
- # helpers defined here available to all views.
+ # helpers defined here available to all views.
end
end
View
8 app/mailers/user_mailer.rb
@@ -1,13 +1,13 @@
class UserMailer < Merb::MailController
-
+
def signup_notification
@user = params[:user]
render_mail
end
-
+
def activation_notification
@user = params[:user]
render_mail
end
-
-end
+
+end
View
2  app/mailers/views/layout/application.html.erb
@@ -1 +1 @@
-<%= catch_content :for_layout %>
+<%= catch_content :for_layout %>
View
2  app/mailers/views/layout/application.text.erb
@@ -1 +1 @@
-<%= catch_content :for_layout %>
+<%= catch_content :for_layout %>
View
2  app/mailers/views/user_mailer/activation_notification.html.erb
@@ -1 +1 @@
-Your email has been authenticated <%= @user.login %>
+Your email has been authenticated <%= @user.login %>
View
2  app/mailers/views/user_mailer/activation_notification.text.erb
@@ -1 +1 @@
-Your email has been authenticated <%= @user.login %>
+Your email has been authenticated <%= @user.login %>
View
2  app/mailers/views/user_mailer/signup_notification.html.erb
@@ -5,4 +5,4 @@ Your account has been created.
Visit this url to activate your account:
- <%= url(:user_activation, :activation_code => @user.activation_code) %>
+ <%= url(:user_activation, :activation_code => @user.activation_code) %>
View
2  app/mailers/views/user_mailer/signup_notification.text.erb
@@ -5,4 +5,4 @@ Your account has been created.
Visit this url to activate your account:
- <%= url(:user_activation, :activation_code => @user.activation_code) %>
+ <%= url(:user_activation, :activation_code => @user.activation_code) %>
View
4 app/models/address.rb
@@ -13,7 +13,7 @@ class Address
property :address1, String, :length => 200, :nullable => false
property :address2, String, :length => 200
property :city, String, :length => 50
- property :postal_code, String, :length => 10
+ property :postal_code, String, :length => 10
property :state_id, Fixnum # foreign-key
property :country_code, String # foreign-key
@@ -38,4 +38,4 @@ def name
"#{self.first_name} #{self.last_name}"
end
-end
+end
View
6 app/models/country.rb
@@ -3,9 +3,9 @@
# ISO 3166-1 geographic code.
#
class Country
-
+
include DataMapper::Resource
-
+
property :code, String, :key => true, :length => 2 # ISO 3166-1 alpha-2
property :name, String, :length => 100, :nullable => false, :unique => true
@@ -16,4 +16,4 @@ class Country
alias :provinces :states
-end
+end
View
4 app/models/mart/abstract_upload.rb
@@ -1,6 +1,6 @@
module Mart
class AbstractUpload
-
+
include DataMapper::Resource
property :id, Fixnum, :serial => true
@@ -18,7 +18,7 @@ def filename_base
def extension
filename.split('.').last
end
-
+
def relative_path
filename # TODO
end
View
8 app/models/mart/accounts/abstract_account.rb
@@ -3,7 +3,7 @@
module Mart
module Accounts
class AbstractAccount
-
+
include DataMapper::Resource
include DataMapper::Validate
require 'ezcrypto'
@@ -12,14 +12,14 @@ class AbstractAccount
property :type, Class # single-table inheritance
property :order_id, Fixnum # foreign-key
property :customer_id, Fixnum # foreign-key
-
+
has 1, :order
belongs_to :customer #, :accessor => :protected
def self.months
(1..12).to_a
end
-
+
def self.years
year = Date.today.year
years = Array.new
@@ -31,4 +31,4 @@ def self.years
end
end
-end
+end
View
6 app/models/mart/accounts/bank_account.rb
@@ -2,11 +2,11 @@ module Mart
module Accounts
class BankAccount < AbstractAccount
- #property :account_subtype, DataMapper::Types::Enum
+ #property :account_subtype, DataMapper::Types::Enum
property :account_number, String
property :routing_number, String, :length => 20
property :bank_name, String, :length => 50
-
+
end
end
-end
+end
View
4 app/models/mart/accounts/credit_card_account.rb
@@ -1,7 +1,7 @@
module Mart
module Accounts
class CreditCardAccount < Accounts::AbstractAccount
-
+
property :cc_number, String
property :expiration_month, Fixnum, :length => 2
property :expiration_year, Fixnum, :length => 4
@@ -9,4 +9,4 @@ class CreditCardAccount < Accounts::AbstractAccount
end
end
-end
+end
View
6 app/models/mart/accounts/google_checkout_account.rb
@@ -1,9 +1,9 @@
module Mart
module Accounts
class GoogleCheckoutAccount < AbstractAccount
-
+
# TODO: Implement Me
-
+
end
end
-end
+end
View
2  app/models/mart/accounts/paypal_account.rb
@@ -6,4 +6,4 @@ class PaypalAccount < AbstractAccount
end
end
-end
+end
View
2  app/models/mart/asset.rb
@@ -2,4 +2,4 @@ module Mart
class Asset < AbstractUpload
end
-end
+end
View
6 app/models/mart/customer.rb
@@ -2,9 +2,9 @@
module Mart
class Customer
-
+
include DataMapper::Resource
-
+
property :id, Fixnum, :serial => true
property :username, String, :length => 50
property :email_address, String, :length => 50, :nullable => false, :index => :unique
@@ -27,4 +27,4 @@ def last_order
end
end
-end
+end
View
22 app/models/mart/customers/cart.rb
@@ -3,14 +3,14 @@
module Mart
module Customers
class Cart
-
+
attr_reader :items, :shipping_cost, :tax, :total
-
+
# Initializes the shopping cart
def initialize
empty!
end
-
+
# Empties or initializes the cart
def empty!
@items = []
@@ -18,15 +18,15 @@ def empty!
@total = 0.0
@shipping_cost = 0.0
end
-
+
def tax_cost
@tax * @total
end
-
+
def empty?
@items.length == 0
end
-
+
# Returns the total price of our cart
def total
@total = 0.0
@@ -41,7 +41,7 @@ def total
def line_items_total
total
end
-
+
# Adds a product to our shopping cart
def add_product(product, quantity=1)
item = @items.find { |i| i.product_id == product.id }
@@ -55,7 +55,7 @@ def add_product(product, quantity=1)
@items << item
end
end
-
+
# Removes all quantities of product from our cart
def remove_product(product, quantity=nil)
item = @items.find { |i| i.product_id == product.id }
@@ -70,7 +70,7 @@ def remove_product(product, quantity=nil)
end
end
end
-
+
# Checks inventory of products, and removes them if
# they're out of stock.
#
@@ -90,7 +90,7 @@ def check_inventory
end
return removed_items
end
-
+
end
end
-end
+end
View
10 app/models/mart/customers/wishlist_item.rb
@@ -1,18 +1,18 @@
module Mart
module Customers
class WishlistItem
-
+
include DataMapper::Resource
include DataMapper::Validate
-
+
property :id, Fixnum, :serial => true
property :created_on, DateTime
property :customer_id, Fixnum # foreign-key
property :store_item_id, Fixnum # foreign-key
-
+
belongs_to :customer
belongs_to :store_item
-
+
end
end
-end
+end
View
4 app/models/mart/image.rb
@@ -2,7 +2,7 @@ module Mart
class Image < AbstractUpload
IMAGE_EXTENSIONS = ['gif', 'jpg', 'jpeg', 'png', 'bmp']
-
+
property :width, Fixnum, :default => 0, :nullable => false
property :height, Fixnum, :default => 0, :nullable => false
@@ -10,4 +10,4 @@ class Image < AbstractUpload
#has n, :products, :through => :product_images ## FIXME
end
-end
+end
View
14 app/models/mart/order.rb
@@ -3,7 +3,7 @@
module Mart
class Order
-
+
include DataMapper::Resource
property :id, Fixnum, :serial => true
@@ -22,20 +22,20 @@ class Order
property :order_shipping_type_id, Fixnum # foreign-key
property :status_code_id,Fixnum # foreign-key
property :promotion_id, Fixnum # foreign-key
-
+
has 1..n, :line_items, :class_name => 'Orders::LineItem' #, :dependent => :destroy
has 1, :billing_address, :class_name => 'Address' #, :foreign_key => 'billing_address_id'
has 1, :shipping_address, :class_name => 'Address' #, :foreign_key => 'shipping_address_id'
-
+
belongs_to :account
belongs_to :customer
belongs_to :order_shipping_type
belongs_to :status_code, :class_name => 'Orders::StatusCode'
belongs_to :promotion
-
+
attr_accessor :promotion_code
-
+
validates_present :order_number
-
+
end
-end
+end
View
8 app/models/mart/orders/line_item.rb
@@ -3,7 +3,7 @@
module Mart
module Orders
class LineItem
-
+
include DataMapper::Resource
property :id, Fixnum, :serial => true
@@ -12,10 +12,10 @@ class LineItem
property :name, String
property :product_id, Fixnum ## FIXME: should not be both product_id + store_item_id
property :store_item_id, Fixnum # foreign-key
-
+
belongs_to :product ## FIXME: should not be both product_id + store_item_id
belongs_to :store_item
-
+
end
end
-end
+end
View
10 app/models/mart/orders/status_code.rb
@@ -1,14 +1,14 @@
module Mart
module Orders
class StatusCode
-
+
include DataMapper::Resource
-
+
property :id, Fixnum, :serial => true
property :name, String, :length => 30, :nullable => false
-
+
has n, :orders
-
+
end
end
-end
+end
View
2  app/models/mart/shipping/type.rb
@@ -27,4 +27,4 @@ def self.get_foreign
end
end
-end
+end
View
4 app/models/mart/shipping/weight.rb
@@ -13,7 +13,7 @@ class Weight
property :order_shipping_type_id, Fixnum # foreign-key
belongs_to :type
-
+
end
end
-end
+end
View
8 app/models/mart/store/abstract_item.rb
@@ -21,12 +21,12 @@ class AbstractItem
property :weight, Float, :default => 0.0, :nullable => false
property :is_discontinued, TrueClass, :default => false
property :type, Class # single-table inheritance
-
+
has n, :line_items, :class_name => "Mart::Orders::LineItem"
has n, :wishlist_items, :class_name => "Mart::Customers::WishlistItem" #, :dependent => :destroy
-
+
validates_present :name, :code
-
+
end
end
-end
+end
View
8 app/models/mart/store/product.rb
@@ -8,15 +8,15 @@ class Product < AbstractItem
#:through => :product_images,
#:order => "-product_images.rank DESC",
#:dependent => :destroy
-
+
many_to_many :related_products,
:class_name => 'Product' #,
#:join_table => 'related_products',
#:association_foreign_key => 'related_id',
#:foreign_key => 'product_id'
-
+
many_to_many :tags
-
+
end
end
-end
+end
View
6 app/models/mart/store/product_image.rb
@@ -1,9 +1,9 @@
module Mart
module Store
class ProductImage
-
+
include DataMapper::Resource
-
+
property :product_id, Fixnum # foreign-key
property :image_id, Fixnum # foreign-key
property :rank, Fixnum
@@ -13,4 +13,4 @@ class ProductImage
end
end
-end
+end
View
12 app/models/mart/store/promotion.rb
@@ -4,15 +4,15 @@
module Mart
module Store
class Promotion
-
+
include DataMapper::Resource
## TODO: add support for subtypes:
# - dollars off
# - percetnage off
# - buy n, get n free
- # -
-
+ # -
+
property :id, Fixnum, :serial => true
property :code, String, :length => 15, :nullable => false
property :discount_type, Fixnum, :default => 0, :nullable => false
@@ -25,10 +25,10 @@ class Promotion
has n, :orders
belongs_to :item, :class_name => "Mart::Store::AbstractItem"
-
+
validates_present :code, :discount_amount, :discount_type, :description
- validates_is_number :discount_amount
+ validates_is_number :discount_amount
end
end
-end
+end
View
6 app/models/mart/store/variation.rb
@@ -1,11 +1,11 @@
module Mart
module Store
class Variation < AbstractItem
-
+
property :product_id, Fixnum # foreign-key
-
+
belongs_to :product
end
end
-end
+end
View
6 app/models/right.rb
@@ -1,7 +1,7 @@
class Right
-
+
include DataMapper::Resource
-
+
property :id, Fixnum, :serial => true
property :name, String
property :controller, String
@@ -22,4 +22,4 @@ class RightRoles
include DataMapper::Resource
property :right_id, Fixnum, :key => true
property :role_id, Fixnum, :key => true
-end
+end
View
4 app/models/role.rb
@@ -1,5 +1,5 @@
class Role
-
+
include DataMapper::Resource
property :id, Fixnum, :serial => true
@@ -9,4 +9,4 @@ class Role
many_to_many :users
many_to_many :rights #, :order => 'name ASC'
-end
+end
View
6 app/models/state.rb
@@ -17,7 +17,7 @@ class State
property :country_code, String, :key => true # foreign-key, ISO 3166-1 alpha-2
property :abbr, String, :key => true, :length => 10
property :name, String, :length => 50, :nullable => false
-
+
belongs_to :country
-
-end
+
+end
View
12 app/models/tag.rb
@@ -3,18 +3,18 @@
# A free-form, flat taxonomoy.
#
class Tag
-
+
include DataMapper::Resource
-
+
property :id, Fixnum, :serial => true
property :name, String, :length => 100, :nullable => false, :key => :unique
property :rank, Fixnum
-
+
validates_present :name
validates_is_unique :rank
-
+
def self.all_ordered
all(:order => [ :name.asc ])
end
-
-end
+
+end
View
18 app/models/user.rb
@@ -4,16 +4,16 @@
require "dm-validations"
begin
require File.join(File.dirname(__FILE__), '..', '..', "lib", "authenticated_system", "authenticated_dependencies")
-rescue
+rescue
nil
end
class User
-
+
include DataMapper::Resource
include AuthenticatedSystem::Model
-
+
attr_accessor :password, :password_confirmation
-
+
property :id, Fixnum, :serial => true
property :login, String, :unique => true
property :email, String
@@ -44,11 +44,11 @@ class User
def login=(value)
@login = value.downcase unless value.nil?
end
-
+
EMAIL_FROM = "info@mysite.com"
SIGNUP_MAIL_SUBJECT = "Welcome to MYSITE. Please activate your account."
ACTIVATE_MAIL_SUBJECT = "Welcome to MYSITE"
-
+
# Activates the user in the database
def activate
@activated = true
@@ -65,15 +65,15 @@ def activate
:user => self )
end
-
+
#def send_signup_notification
# UserMailer.dispatch_and_deliver(
# :signup_notification,
# { :from => User::EMAIL_FROM,
# :to => self.email,
# :subject => User::SIGNUP_MAIL_SUBJECT },
- # :user => self
+ # :user => self
# )
#end
-
+
end
View
2  app/parts/views/layout/application.html.haml
@@ -1 +1 @@
-<%= catch_content :layout %>
+<%= catch_content :layout %>
View
2  app/views/customers/index.html.haml
@@ -1 +1 @@
-You're in index of the Customers
+You're in index of the Customers
View
4 app/views/layout/application.html.haml
@@ -13,10 +13,10 @@
%h1 MerbMart
#navigation
%ul
- %li
+ %li
=link_to 'Store', ''
#content
= catch_content :for_layout
#footer
%p Powered by MerbMart, Merb and DataMapper.
- %p Copyright &copy; 2008, Alex Coles.
+ %p Copyright &copy; 2008, Alex Coles.
View
2  app/views/store/index.html.haml
@@ -1 +1 @@
-This is the frontpage of the MerbMart store.
+This is the frontpage of the MerbMart store.
View
2  app/views/users/new.html.haml
@@ -4,4 +4,4 @@
%p= text_control :email, :label => "Email"
%p= password_control :password, :label => "Password"
%p= password_control :password_confirmation, :label => "Password Confirmation"
- %p= submit_button "Sign up"
+ %p= submit_button "Sign up"
View
2  autotest.bak/discover.rb
@@ -1 +1 @@
-Autotest.add_discovery { "merb" }
+Autotest.add_discovery { "merb" }
View
78 autotest.bak/merb.rb
@@ -2,81 +2,81 @@
require 'autotest'
class Autotest::Merb < Autotest
-
+
# +model_tests_dir+:: the directory to find model-centric tests
# +controller_tests_dir+:: the directory to find controller-centric tests
# +view_tests_dir+:: the directory to find view-centric tests
# +fixtures_dir+:: the directory to find fixtures in
attr_accessor :model_tests_dir, :controller_tests_dir, :view_tests_dir, :fixtures_dir
-
+
def initialize # :nodoc:
super
-
+
initialize_test_layout
-
+
# Ignore any happenings in these directories
add_exception %r%^\./(?:doc|log|public|tmp)%
-
+
# Ignore any mappings that Autotest may have already set up
clear_mappings
-
- # Any changes to a file in the root of the 'lib' directory will run any
+
+ # Any changes to a file in the root of the 'lib' directory will run any
# model test with a corresponding name.
add_mapping %r%^lib\/.*\.rb% do |filename, _|
files_matching Regexp.new(["^#{model_test_for(filename)}$"])
end
-
- # Any changes to a fixture will run corresponding view, controller and
+
+ # Any changes to a fixture will run corresponding view, controller and
# model tests
add_mapping %r%^#{fixtures_dir}/(.*)s.yml% do |_, m|
[
- model_test_for(m[1]),
- controller_test_for(m[1]),
+ model_test_for(m[1]),
+ controller_test_for(m[1]),
view_test_for(m[1])
]
end
-
+
# Any change to a test or test will cause it to be run
add_mapping %r%^test/(unit|models|integration|controllers|views|functional)/.*rb$% do |filename, _|
filename
end
-
+
# Any change to a model will cause it's corresponding test to be run
add_mapping %r%^app/models/(.*)\.rb$% do |_, m|
model_test_for(m[1])
end
-
- # Any change to the global helper will result in all view and controller
+
+ # Any change to the global helper will result in all view and controller
# tests being run
add_mapping %r%^app/helpers/global_helpers.rb% do
files_matching %r%^test/(views|functional|controllers)/.*_test\.rb$%
end
-
- # Any change to a helper will run it's corresponding view and controller
- # tests, unless the helper is the global helper. Changes to the global
+
+ # Any change to a helper will run it's corresponding view and controller
+ # tests, unless the helper is the global helper. Changes to the global
# helper run all view and controller tests.
add_mapping %r%^app/helpers/(.*)_helper(s)?.rb% do |_, m|
if m[1] == "global" then
files_matching %r%^test/(views|functional|controllers)/.*_test\.rb$%
else
[
- view_test_for(m[1]),
+ view_test_for(m[1]),
controller_test_for(m[1])
]
end
end
-
- # Changes to views result in their corresponding view and controller test
+
+ # Changes to views result in their corresponding view and controller test
# being run
add_mapping %r%^app/views/(.*)/% do |_, m|
[
- view_test_for(m[1]),
+ view_test_for(m[1]),
controller_test_for(m[1])
]
end
-
- # Changes to a controller result in its corresponding test being run. If
- # the controller is the exception or application controller, all
+
+ # Changes to a controller result in its corresponding test being run. If
+ # the controller is the exception or application controller, all
# controller tests are run.
add_mapping %r%^app/controllers/(.*)\.rb$% do |_, m|
if ["application", "exception"].include?(m[1])
@@ -91,16 +91,16 @@ def initialize # :nodoc:
files_matching %r%^test/(controllers|views|functional)/.*_test\.rb$%
end
- # If any of the major files governing the environment are altered, run
+ # If any of the major files governing the environment are altered, run
# everything
add_mapping %r%^test/test_helper.rb|config/(init|rack|environments/test.rb|database.yml)% do # FIX
files_matching %r%^test/(unit|models|controllers|views|functional)/.*_test\.rb$%
end
end
-
+
private
- # Determines the paths we can expect tests or specs to reside, as well as
+ # Determines the paths we can expect tests or specs to reside, as well as
# corresponding fixtures.
def initialize_test_layout
self.model_tests_dir = "test/unit"
@@ -108,19 +108,19 @@ def initialize_test_layout
self.view_tests_dir = "test/views"
self.fixtures_dir = "test/fixtures"
end
-
- # Given a filename and the test type, this method will return the
+
+ # Given a filename and the test type, this method will return the
# corresponding test's or spec's name.
- #
+ #
# ==== Arguments
# +filename+<String>:: the file name of the model, view, or controller
# +kind_of_test+<Symbol>:: the type of test we that we should run
- #
+ #
# ==== Returns
# String:: the name of the corresponding test or spec
- #
+ #
# ==== Example
- #
+ #
# > test_for("user", :model)
# => "user_test.rb"
# > test_for("login", :controller)
@@ -133,17 +133,17 @@ def test_for(filename, kind_of_test) # :nodoc:
name << "test"
return name.join("_") + ".rb"
end
-
+
def model_test_for(filename)
[model_tests_dir, test_for(filename, :model)].join("/")
end
-
+
def controller_test_for(filename)
[controller_tests_dir, test_for(filename, :controller)].join("/")
end
-
+
def view_test_for(filename)
[view_tests_dir, test_for(filename, :view)].join("/")
end
-
-end
+
+end
View
2  config/environments/rake.rb
@@ -4,4 +4,4 @@
c[:reload_classes] = false
c[:log_auto_flush ] = true
c[:log_file] = Merb.log_path / 'merb_rake.log'
-}
+}
View
12 config/init.rb
@@ -1,10 +1,10 @@
-# __ __ _ __ __ _
-# | \/ |___ _ _| |__| \/ |__ _ _ _| |_
+# __ __ _ __ __ _
+# | \/ |___ _ _| |__| \/ |__ _ _ _| |_
# | |\/| / -_) '_| '_ \ |\/| / _` | '_| _|
# |_| |_\___|_| |_.__/_| |_\__,_|_| \__|
#
# Copyright (C) 2008 Alex Coles
-#
+#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
@@ -20,7 +20,7 @@
#
# ==== Load paths
-
+
# Make the app's "gems" directory a place where gems are loaded from
Gem.clear_paths
Gem.path.unshift(Merb.root / "gems")
@@ -73,8 +73,8 @@
c[:session_store] = 'cookie'
# c[:session_store] = 'datamapper' ## FIXME: temporarily disabled
# c[:use_mutex] = false ## FIXME: disable Mutex
-
-end
+
+end
# ==== Inflector Customization
View
2  config/rack.rb
@@ -1 +1 @@
-run Merb::Rack::Application.new
+run Merb::Rack::Application.new
View
8 config/router.rb
@@ -16,11 +16,11 @@
# RESTful routes
r.resources :users
-
+
r.match("/login").to(:controller => "Sessions", :action => "create").name(:login)
r.match("/logout").to(:controller => "Sessions", :action => "destroy").name(:logout)
r.match("/users/activate/:activation_code").to(:controller => "Users", :action => "activate").name(:user_activation)
-
+
r.match('/').to(:controller => 'Store', :action => 'index')
# Default administration mapping
@@ -31,12 +31,12 @@
#r.match('/blog').to(:controller => 'ContentNodes', :action => 'index')
#r.match('/blog/section/:section_name').to(:controller => 'ContentNodes', :action => 'list_by_section')
#r.match('/blog/:name').to(:controller => 'ContentNodes', :action => 'show_by_name')
-
+
# map.connect '/store/show_by_tags/*tags',
# :controller => 'store',
# :action => 'show_by_tags'
# For things like /about_us, etc
#r.match('/:name').to(:controller => 'ContentNodes', :action => 'show_by_name')
-
+
end
View
18 lib/authenticated_system/authenticated_system_controller.rb
@@ -6,19 +6,19 @@ module Controller
def logged_in?
current_user != :false
end
-
+
# Accesses the current user from the session. Set it to :false if login fails
# so that future calls do not hit the database.
def current_user
@current_user ||= (login_from_session || login_from_basic_auth || login_from_cookie || :false)
end
-
+
# Store the given user in the session.
def current_user=(new_user)
session[:user] = (new_user.nil? || new_user.is_a?(Symbol)) ? nil : new_user.id
@current_user = new_user
end
-
+
# Check if the user is authorized
#
# Override this method in your controllers if you want to restrict access
@@ -77,14 +77,14 @@ def access_denied
render "Couldn't authenticate you"
end
end
-
+
# Store the URI of the current request in the session.
#
# We can return to this location by calling #redirect_back_or_default.
def store_location
session[:return_to] = request.uri
end
-
+
# Redirect to the URI stored by the most recent store_location call or
# to the passed default.
def redirect_back_or_default(default)
@@ -92,7 +92,7 @@ def redirect_back_or_default(default)
session[:return_to] = nil
redirect loc
end
-
+
# Inclusion hook to make #current_user and #logged_in?
# available as ActionView helper methods.
# def self.included(base)
@@ -111,7 +111,7 @@ def login_from_basic_auth
end
# Called from #current_user. Finaly, attempt to login by an expiring token in the cookie.
- def login_from_cookie
+ def login_from_cookie
user = cookies[:auth_token] && User.find_authenticated_model_with_remember_token(cookies[:auth_token])
if user && user.remember_token?
user.remember_me
@@ -119,7 +119,7 @@ def login_from_cookie
self.current_user = user
end
end
-
+
def reset_session
session.data.each{|k,v| session.data.delete(k)}
end
@@ -131,7 +131,7 @@ def reset_session
def get_auth_data
auth_key = @@http_auth_headers.detect { |h| request.env.has_key?(h) }
auth_data = request.env[auth_key].to_s.split unless auth_key.blank?
- return auth_data && auth_data[0] == 'Basic' ? Base64.decode64(auth_data[1]).split(':')[0..1] : [nil, nil]
+ return auth_data && auth_data[0] == 'Basic' ? Base64.decode64(auth_data[1]).split(':')[0..1] : [nil, nil]
end
end
end
View
24 lib/authenticated_system/authenticated_system_model.rb
@@ -1,30 +1,30 @@
module AuthenticatedSystem
module Model
-
+
def self.included(base)
base.send(:include, InstanceMethods)
base.send(:extend, ClassMethods)
base.send(:extend, AuthenticatedSystem::OrmMap )
end
-
+
module InstanceMethods
def authenticated?(password)
crypted_password == encrypt(password)
- end
+ end
- # before filter
+ # before filter
def encrypt_password
return if password.blank?
self.salt = Digest::SHA1.hexdigest("--#{Time.now.to_s}--#{login}--") if new_record?
self.crypted_password = encrypt(password)
end
-
+
# Encrypts the password with the user salt
def encrypt(password)
self.class.encrypt(password, salt)
end
-
+
def remember_token?
remember_token_expires_at && DateTime.now < DateTime.parse(remember_token_expires_at.to_s)
end
@@ -40,7 +40,7 @@ def remember_me_for(time)
end
# These create and unset the fields required for remembering users between browser closes
- # Default of 2 weeks
+ # Default of 2 weeks
def remember_me
remember_me_for (Merb::Const::WEEK * 2)
end
@@ -50,7 +50,7 @@ def forget_me
self.remember_token = nil
self.save
end
-
+
# Returns true if the <%= singular_name %> has just been activated.
def recently_activated?
@activated
@@ -64,7 +64,7 @@ def activated?
def active?
# the existence of an activation code means they have not activated yet
activation_code.nil?
- end
+ end
def password_required?
crypted_password.blank? || !password.blank?
@@ -76,13 +76,13 @@ def make_activation_code
end
end
-
+
module ClassMethods
# Encrypts some data with the salt.
def encrypt(password, salt)
Digest::SHA1.hexdigest("--#{salt}--#{password}--")
end
-
+
# Authenticates a user by their login name and unencrypted password. Returns the user or nil.
def authenticate(login, password)
u = find_activated_authenticated_model_with_login(login) # need to get the salt
@@ -90,6 +90,6 @@ def authenticate(login, password)
end
end
-
+
end
end
View
18 lib/authenticated_system/authenticated_system_orm_map.rb
@@ -1,14 +1,14 @@
module AuthenticatedSystem
module OrmMap
-
+
def find_authenticated_model_with_id(id)
User.first(:id => id)
end
-
+
def find_authenticated_model_with_remember_token(rt)
User.first(:remember_token => rt)
end
-
+
def find_activated_authenticated_model_with_login(login)
if User.instance_methods.include?("activated_at")
User.first(:login => login, :activated_at.not => nil)
@@ -16,19 +16,19 @@ def find_activated_authenticated_model_with_login(login)
User.first(:login => login)
end
end
-
+
def find_activated_authenticated_model(activation_code)
User.first(:activation_code => activation_code)
- end
-
+ end
+
def find_with_conditions(conditions)
User.first(conditions)
end
-
+
# A method to assist with specs
def clear_database_table
User.auto_migrate!
end
end
-
-end
+
+end
View
8 lib/mart.rb
@@ -1,6 +1,6 @@
module Mart
-
-
-
-end
+
+
+
+end
View
8 public/merb.fcgi
@@ -1,21 +1,21 @@
#!/usr/bin/env ruby
-
+
require 'rubygems'
require 'merb-core'
# this is Merb.root, change this if you have some funky setup.
merb_root = File.expand_path(File.dirname(__FILE__) / '../')
-
+
# If the fcgi process runs as apache, make sure
# we have an inlinedir set for Rubyinline action-args to work
unless ENV["INLINEDIR"] || ENV["HOME"]
tmpdir = merb_root / "tmp"
unless File.directory?(tmpdir)
Dir.mkdir(tmpdir)
- end
+ end
ENV["INLINEDIR"] = tmpdir
end
-
+
# start merb with the fcgi adapter, add options or change the log dir here
Merb.start(:adapter => 'fcgi',
:merb_root => merb_root,
View
6 spec/authenticated_system_spec_helper.rb
@@ -7,13 +7,13 @@ class Merb::Mailer
end
class Hash
-
+
def with( opts )
self.merge(opts)
end
-
+
def without(*args)
self.dup.delete_if{ |k,v| args.include?(k)}
end
-
+
end
View
2  spec/controllers/admin/files_spec.rb
@@ -5,4 +5,4 @@
@controller = Admin::Files.build(fake_request)
@controller.dispatch('index')
end
-end
+end
View
2  spec/controllers/admin/orders_spec.rb
@@ -5,4 +5,4 @@
@controller = Admin::Orders.build(fake_request)
@controller.dispatch('index')
end
-end
+end
View
2  spec/controllers/admin/preferences_spec.rb
@@ -5,4 +5,4 @@
@controller = Admin::Preferences.build(fake_request)
@controller.dispatch('index')
end
-end
+end
View
2  spec/controllers/admin/products_spec.rb
@@ -5,4 +5,4 @@
@controller = Admin::Products.build(fake_request)
@controller.dispatch('index')
end
-end
+end
View
2  spec/controllers/admin/promotions_spec.rb
@@ -5,4 +5,4 @@
@controller = Admin::Promotions.build(fake_request)
@controller.dispatch('index')
end
-end
+end
View
2  spec/controllers/admin/tags_spec.rb
@@ -5,4 +5,4 @@
@controller = Admin::Tags.build(fake_request)
@controller.dispatch('index')
end
-end
+end
View
2  spec/controllers/customers_spec.rb
@@ -4,4 +4,4 @@
before(:each) do
dispatch_to(Customers, :index)
end
-end
+end
View
32 spec/controllers/sessions_spec.rb
@@ -5,42 +5,42 @@
describe "Sessions Controller", "index action" do
include UserSpecHelper
-
+
before(:each) do
User.clear_database_table
@quentin = User.create(valid_user_hash.with(:login => "quentin", :password => "test", :password_confirmation => "test"))
@controller = Sessions.new(fake_request)
@quentin.activate
end
-
+
it "should have a route to Sessions#new from '/login'" do
request_to("/login") do |params|
params[:controller].should == "Sessions"
params[:action].should == "create"
- end
+ end
end
-
+
it "should route to Sessions#create from '/login' via post" do
request_to("/login", :post) do |params|
params[:controller].should == "Sessions"
params[:action].should == "create"
- end
+ end
end
-
+
it "should have a named route :login" do
@controller.url(:login).should == "/login"
end
-
+
it "should have route to Sessions#destroy from '/logout' via delete" do
request_to("/logout", :delete) do |params|
params[:controller].should == "Sessions"
params[:action].should == "destroy"
- end
+ end
end
-
+
it "should route to Sessions#destroy from '/logout' via get" do
request_to("/logout") do |params|
- params[:controller].should == "Sessions"
+ params[:controller].should == "Sessions"
params[:action].should == "destroy"
end
end
@@ -51,7 +51,7 @@
controller.session[:user].should == @quentin.id
controller.should redirect_to("/")
end
-
+
it 'fails login and does not redirect' do
controller = post "/login", :login => 'quentin', :password => 'bad password'
controller.session[:user].should be_nil
@@ -68,18 +68,18 @@
controller = post "/login", :login => 'quentin', :password => 'test', :remember_me => "1"
controller.cookies["auth_token"].should_not be_nil
end
-
+
it 'does not remember me' do
controller = post "/login", :login => 'quentin', :password => 'test', :remember_me => "0"
controller.cookies["auth_token"].should be_nil
end
-
+
it 'deletes token on logout' do
controller = get("/logout") {|request| request.stub!(:current_user).and_return(@quentin) }
controller.cookies["auth_token"].should == nil
end
-
-
+
+
it 'logs in with cookie' do
@quentin.remember_me
controller = get "/login" do |c|
@@ -91,7 +91,7 @@
def auth_token(token)
CGI::Cookie.new('name' => 'auth_token', 'value' => token)
end
-
+
def cookie_for(user)
auth_token user.remember_token
end
View
24 spec/controllers/users_spec.rb
@@ -3,17 +3,17 @@
require File.join( File.dirname(__FILE__), "..", "authenticated_system_spec_helper")
describe Users do
-
+
include UserSpecHelper
-
+
before(:each) do
User.clear_database_table
end
-
+
it 'allows signup' do
lambda do
controller = create_user
- controller.should redirect
+ controller.should redirect
end.should change(User, :count).by(1)
end
@@ -24,7 +24,7 @@
controller.should respond_successfully
end.should_not change(User, :count)
end
-
+
it 'requires password on signup' do
lambda do
controller = create_user(:password => nil)
@@ -32,7 +32,7 @@
controller.should respond_successfully
end.should_not change(User, :count)
end
-
+
it 'requires password confirmation on signup' do
lambda do
controller = create_user(:password_confirmation => nil)
@@ -40,7 +40,7 @@
controller.should respond_successfully
end.should_not change(User, :count)
end
-
+
it 'requires email on signup' do
lambda do
controller = create_user(:email => nil)
@@ -48,12 +48,12 @@
controller.should respond_successfully
end.should_not change(User, :count)
end
-
+
it "should have a route for user activation" do
request_to("/users/activate/1234") do |params|
params[:controller].should == "Users"
- params[:action].should == "activate"
- params[:activation_code].should == "1234"
+ params[:action].should == "activate"
+ params[:activation_code].should == "1234"
end
end
@@ -61,10 +61,10 @@
controller = create_user(:login => "aaron", :password => "test", :password_confirmation => "test")
@user = controller.assigns(:user)
User.authenticate('aaron', 'test').should be_nil
- controller = get "/users/activate/1234"
+ controller = get "/users/activate/1234"
controller.should redirect_to("/")
end
-
+
def create_user(options = {})
post "/users", :user => valid_user_hash.merge(options)
end
View
2  spec/helpers/admin/files_helper_spec.rb
@@ -2,4 +2,4 @@
describe Merb::Admin::FilesHelper do
-end
+end
View
2  spec/helpers/admin/orders_helper_spec.rb
@@ -2,4 +2,4 @@
describe Merb::Admin::OrdersHelper do
-end
+end
View
2  spec/helpers/admin/preferences_helper_spec.rb
@@ -2,4 +2,4 @@
describe Merb::Admin::PreferencesHelper do
-end
+end
View
2  spec/helpers/admin/products_helper_spec.rb
@@ -2,4 +2,4 @@
describe Merb::Admin::ProductsHelper do
-end
+end
View
2  spec/helpers/admin/promotions_helper_spec.rb
@@ -2,4 +2,4 @@
describe Merb::Admin::PromotionsHelper do
-end
+end
View
2  spec/helpers/admin/tags_helper_spec.rb
@@ -2,4 +2,4 @@
describe Merb::Admin::TagsHelper do
-end
+end
View
2  spec/helpers/customers_helper_spec.rb
@@ -2,4 +2,4 @@
describe Merb::CustomersHelper do
-end
+end
View
30 spec/mailers/user_mailer_spec.rb
@@ -3,61 +3,61 @@
require File.join( File.dirname(__FILE__), "..", "authenticated_system_spec_helper")
describe UserMailer do
-
+
def deliver(action, mail_opts= {}, opts = {})
UserMailer.dispatch_and_deliver(action, mail_opts, opts)
@delivery = Merb::Mailer.deliveries.last
end
-
+
before(:each) do
@u = User.new(:email => "homer@simpsons.com", :login => "homer", :activation_code => "12345")
@mailer_params = { :from => "info@mysite.com",
:to => @u.email,
:subject => "Welcome to MySite.com" }
end
-
+
after(:each) do
Merb::Mailer.deliveries.clear
end
-
+
it "should send mail to homer@simpsons.com for the signup email" do
deliver(:signup_notification, @mailer_params, :user => @u)
@delivery.assigns(:headers).should include("to: homer@simpsons.com")
end
-
+
it "should send the mail from 'info@mysite.com' for the signup email" do
deliver(:signup_notification, @mailer_params, :user => @u)
@delivery.assigns(:headers).should include("from: info@mysite.com")
end
-
+
it "should mention the users login in the text signup mail" do
deliver(:signup_notification, @mailer_params, :user => @u)
@delivery.text.should include(@u.login)
end
-
+
it "should mention the users login in the HTML signup mail" do
deliver(:signup_notification, @mailer_params, :user => @u)
@delivery.html.should include(@u.login)
end
-
+
it "should mention the activation link in the signup emails" do
deliver(:signup_notification, @mailer_params, :user => @u)
the_url = UserMailer.new.url(:user_activation, :activation_code => @u.activation_code)
the_url.should_not be_nil
- @delivery.text.should include( the_url )
+ @delivery.text.should include( the_url )
@delivery.html.should include( the_url )
end
-
+
it "should send mail to homer@simpson.com for the activation email" do
deliver(:activation_notification, @mailer_params, :user => @u)
@delivery.assigns(:headers).should include("to: homer@simpsons.com")
end
-
+