Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

improve test coverage a bit

  • Loading branch information...
commit 62a0ba1de9b9c90df926e356e2a37043ec11500e 1 parent 4949617
@citrus authored
View
3  .gitignore
@@ -3,7 +3,8 @@
*.sqlite3
.bundle
.DS_Store
+coverage
Gemfile.lock
pkg/*
test/dummy_hooks/after_migrate.rb
-test/dummy
+test/dummy
View
2  app/controllers/spree/admin/markdown_controller.rb
@@ -4,4 +4,4 @@ def preview
render :text => RDiscount.new(params[:data].to_s).to_html
end
-end
+end
View
4 app/controllers/spree/admin/uploads_controller.rb
@@ -6,10 +6,6 @@ def index
private
- def translated_object_name
- I18n.t("upload.model_name")
- end
-
def collection
params[:search] ||= {}
params[:search][:meta_sort] ||= "created_at.desc"
View
9 config/routes.rb
@@ -1,6 +1,7 @@
+#Rails.application
Spree::Core::Engine.routes.draw do
- namespace :admin do
- post "/markdown/preview" => "markdown#preview"
- resources :uploads
- end
+ namespace :admin do
+ post "/markdown/preview" => "markdown#preview", :as => :markdown_preview
+ resources :uploads
+ end
end
View
18 test/unit/spree/asset_test.rb
@@ -0,0 +1,18 @@
+require 'test_helper'
+
+class Spree::AssetTest < ActiveSupport::TestCase
+
+ setup do
+ @asset = Spree::Asset.new
+ end
+
+ should "return true if asset has_alt?" do
+ @asset.alt = "omg"
+ assert_equal true, @asset.has_alt?
+ end
+
+ should "return false unless asset has_alt?" do
+ assert_equal false, @asset.has_alt?
+ end
+
+end
View
5 test/unit/spree/extension_test.rb
@@ -29,4 +29,9 @@ def setup
assert_equal 1, SpreeEssentials.essentials.length
end
+ should "check if spree essentials has an extension" do
+ SpreeEssentials.register :example, SpreeEssentialExample
+ assert SpreeEssentials.has?(:example)
+ end
+
end
View
29 test/unit/validators/datetime_validator_test.rb
@@ -0,0 +1,29 @@
+require 'test_helper'
+
+class DatetimeValidatorTest < ActiveSupport::TestCase
+
+ class ModelWithDate
+ include ActiveModel::Validations
+ attr_accessor :timestamp
+ validates :timestamp, :datetime => true
+ end
+
+ setup do
+ @record = ModelWithDate.new
+ end
+
+ [ "1/1/2012", "1/1/12", "1-1-12", "12-1-1", "Jan 1, 2012", "January 1 2012" ].each do |date|
+ should "validate #{date} as valid" do
+ @record.timestamp = date
+ assert @record.valid?
+ end
+ end
+
+ [ "1", "dec 1" "11 111 11", "2012-1", "99/99", "tomorrow", "NOW" ].each do |date|
+ should "validate #{date} as invalid" do
+ @record.timestamp = date
+ assert_equal false, @record.valid?
+ end
+ end
+
+end
Please sign in to comment.
Something went wrong with that request. Please try again.