Initial commit of foodsoft 2

This commit is contained in:
Benjamin Meichsner 2009-01-06 11:49:19 +01:00
commit 5b9a7e05df
657 changed files with 70444 additions and 0 deletions

4
test/fixtures/article_categories.yml vendored Normal file
View file

@ -0,0 +1,4 @@
# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
fruits:
id: 1
description: fruits and only fruits

29
test/fixtures/articles.yml vendored Normal file
View file

@ -0,0 +1,29 @@
# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
banana:
id: 1
name: banana
current_price_id: 1
unit: 500g
availability: 1
note: delicious
supplier_id: 1
article_category_id: 1
kiwi:
id: 2
name: kiwi
current_price_id: 2
unit: 500g
availability: 1
note: delicious
supplier_id: 1
article_category_id: 1
apple:
id: 3
name: apple
current_price_id: 3
unit: 500g
availability: 0
note: delicious
supplier_id: 1
article_category_id: 1

5
test/fixtures/assignments.yml vendored Normal file
View file

@ -0,0 +1,5 @@
# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
one:
id: 1
two:
id: 2

View file

@ -0,0 +1,5 @@
# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
first:
id: 1
another:
id: 2

View file

@ -0,0 +1,5 @@
# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
first:
id: 1
another:
id: 2

View file

@ -0,0 +1,5 @@
# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
first:
id: 1
another:
id: 2

12
test/fixtures/group_order_results.yml vendored Normal file
View file

@ -0,0 +1,12 @@
# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
one:
id: 1
order_id: 1
group_name: Order Group 1
price: 99.95
two:
id: 2
order_id: 1
group_name: Order Group 2
price: 99.95

13
test/fixtures/groups.yml vendored Normal file
View file

@ -0,0 +1,13 @@
# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
first:
id: 1
name: Order Group 1
type: OrderGroup
another:
id: 2
name: Order Group 2
type: OrderGroup
admins:
id: 3
name: Administrators
role_admin: true

10
test/fixtures/memberships.yml vendored Normal file
View file

@ -0,0 +1,10 @@
# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
first:
id: 1
group_id: 3
user_id: 1
another:
id: 2
group_id: 1
user_id: 2

5
test/fixtures/messages.yml vendored Normal file
View file

@ -0,0 +1,5 @@
# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
one:
id: 1
two:
id: 2

View file

@ -0,0 +1,5 @@
# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
first:
id: 1
another:
id: 2

5
test/fixtures/orders.yml vendored Normal file
View file

@ -0,0 +1,5 @@
# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
first:
id: 1
another:
id: 2

5
test/fixtures/roles.yml vendored Normal file
View file

@ -0,0 +1,5 @@
# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
first:
id: 1
another:
id: 2

15
test/fixtures/suppliers.yml vendored Normal file
View file

@ -0,0 +1,15 @@
# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
first:
id: 1
name: Terra
delivery_days: tuesday
contact_person: thomas terra
url: www.terra-natur.de
note:
fax: 01324-343444
phone: 0123-555555
order_howto:
phone2: 01234-7878787
address: berlin bio
customer_number: 123478
email: terra@terra.com

5
test/fixtures/tasks.yml vendored Normal file
View file

@ -0,0 +1,5 @@
# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
one:
id: 1
two:
id: 2

16
test/fixtures/users.yml vendored Normal file
View file

@ -0,0 +1,16 @@
# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
admin:
id: 1
nick: admin
first_name: Anton
last_name: Admininistrator
email: admin@foo.test
#TODO: password can't loaded directyl to the database
#password_hash:
#password_salt:
test:
id: 2
nick: test
first_name: Tim
last_name: Tester
email: test@foo.test

View file

@ -0,0 +1,18 @@
require File.dirname(__FILE__) + '/../test_helper'
require 'admin_controller'
# Re-raise errors caught by the controller.
class AdminController; def rescue_action(e) raise e end; end
class AdminControllerTest < Test::Unit::TestCase
def setup
@controller = AdminController.new
@request = ActionController::TestRequest.new
@response = ActionController::TestResponse.new
end
# Replace this with your real tests.
def test_truth
assert true
end
end

View file

@ -0,0 +1,88 @@
require File.dirname(__FILE__) + '/../test_helper'
require 'articles_controller'
# Re-raise errors caught by the controller.
class ArticlesController; def rescue_action(e) raise e end; end
class ArticlesControllerTest < Test::Unit::TestCase
fixtures :articles
def setup
@controller = ArticlesController.new
@request = ActionController::TestRequest.new
@response = ActionController::TestResponse.new
end
def test_index
get :index
assert_response :success
assert_template 'list'
end
def test_list
get :list
assert_response :success
assert_template 'list'
assert_not_nil assigns(:articles)
end
def test_show
get :show, :id => 1
assert_response :success
assert_template 'show'
assert_not_nil assigns(:article)
assert assigns(:article).valid?
end
def test_new
get :new
assert_response :success
assert_template 'new'
assert_not_nil assigns(:article)
end
def test_create
num_articles = Article.count
post :create, :article => {}
assert_response :redirect
assert_redirected_to :action => 'list'
assert_equal num_articles + 1, Article.count
end
def test_edit
get :edit, :id => 1
assert_response :success
assert_template 'edit'
assert_not_nil assigns(:article)
assert assigns(:article).valid?
end
def test_update
post :update, :id => 1
assert_response :redirect
assert_redirected_to :action => 'show', :id => 1
end
def test_destroy
assert_not_nil Article.find(1)
post :destroy, :id => 1
assert_response :redirect
assert_redirected_to :action => 'list'
assert_raise(ActiveRecord::RecordNotFound) {
Article.find(1)
}
end
end

View file

@ -0,0 +1,18 @@
require File.dirname(__FILE__) + '/../test_helper'
require 'finance_controller'
# Re-raise errors caught by the controller.
class FinanceController; def rescue_action(e) raise e end; end
class FinanceControllerTest < Test::Unit::TestCase
def setup
@controller = FinanceController.new
@request = ActionController::TestRequest.new
@response = ActionController::TestResponse.new
end
# Replace this with your real tests.
def test_truth
assert true
end
end

View file

@ -0,0 +1,18 @@
require File.dirname(__FILE__) + '/../test_helper'
require 'index_controller'
# Re-raise errors caught by the controller.
class IndexController; def rescue_action(e) raise e end; end
class IndexControllerTest < Test::Unit::TestCase
def setup
@controller = IndexController.new
@request = ActionController::TestRequest.new
@response = ActionController::TestResponse.new
end
# Replace this with your real tests.
def test_truth
assert true
end
end

View file

@ -0,0 +1,50 @@
require File.dirname(__FILE__) + '/../test_helper'
require 'login_controller'
# Re-raise errors caught by the controller.
class LoginController; def rescue_action(e) raise e end; end
class LoginControllerTest < Test::Unit::TestCase
fixtures :users
def setup
@controller = LoginController.new
@request = ActionController::TestRequest.new
@response = ActionController::TestResponse.new
@admin = User.find(1)
@admin.set_password({:required => true}, "secret", "secret")
@admin.save
@emails = ActionMailer::Base.deliveries
@emails.clear
end
def test_login_with_invalid_user
post :login, :login => {:user => 'bubu', :password => 'baba'}
assert_response :success
assert_equal "Sorry, anmelden nicht möglich", assigns(:error)
end
def test_login_with_valid_user
post :login, :login => {:user => 'admin', :password => 'secret'}
assert_redirected_to :controller => 'index'
#assert_not_nil session[:user_nick] #TODO: make this work !
#user = User.find(session[:user_id])
#assert_equal 'admin@foo.test', user.email
end
def test_reset_password_with_invalid_email
post :reset_password, :login => {:email => "admin@bubu.baba"}
assert_match "Leider keine passende Emailadresse", flash[:error]
end
def test_reset_password_and_mail_delivery
post :reset_password, :login => {:email => "admin@foo.test"}
assert_redirected_to :action => 'login'
assert_equal 1, @emails.size #FIXME: Why this doesn't function ?
email = @email.first
assert_match(/admin/, response.subject)
assert_equal("admin@foo.test", response.to[0])
assert_match(/Dein Passwort neues lautet: /, response.body)
end
end

View file

@ -0,0 +1,92 @@
require File.dirname(__FILE__) + '/../test_helper'
require 'messages_controller'
# Re-raise errors caught by the controller.
class MessagesController; def rescue_action(e) raise e end; end
class MessagesControllerTest < Test::Unit::TestCase
fixtures :messages
def setup
@controller = MessagesController.new
@request = ActionController::TestRequest.new
@response = ActionController::TestResponse.new
@first_id = messages(:first).id
end
def test_index
get :index
assert_response :success
assert_template 'list'
end
def test_list
get :list
assert_response :success
assert_template 'list'
assert_not_nil assigns(:messages)
end
def test_show
get :show, :id => @first_id
assert_response :success
assert_template 'show'
assert_not_nil assigns(:messages)
assert assigns(:messages).valid?
end
def test_new
get :new
assert_response :success
assert_template 'new'
assert_not_nil assigns(:messages)
end
def test_create
num_messages = Messages.count
post :create, :messages => {}
assert_response :redirect
assert_redirected_to :action => 'list'
assert_equal num_messages + 1, Messages.count
end
def test_edit
get :edit, :id => @first_id
assert_response :success
assert_template 'edit'
assert_not_nil assigns(:messages)
assert assigns(:messages).valid?
end
def test_update
post :update, :id => @first_id
assert_response :redirect
assert_redirected_to :action => 'show', :id => @first_id
end
def test_destroy
assert_nothing_raised {
Messages.find(@first_id)
}
post :destroy, :id => @first_id
assert_response :redirect
assert_redirected_to :action => 'list'
assert_raise(ActiveRecord::RecordNotFound) {
Messages.find(@first_id)
}
end
end

View file

@ -0,0 +1,88 @@
require File.dirname(__FILE__) + '/../test_helper'
require 'orders_controller'
# Re-raise errors caught by the controller.
class OrdersController; def rescue_action(e) raise e end; end
class OrdersControllerTest < Test::Unit::TestCase
fixtures :orders
def setup
@controller = OrdersController.new
@request = ActionController::TestRequest.new
@response = ActionController::TestResponse.new
end
def test_index
get :index
assert_response :success
assert_template 'list'
end
def test_list
get :list
assert_response :success
assert_template 'list'
assert_not_nil assigns(:orders)
end
def test_show
get :show, :id => 1
assert_response :success
assert_template 'show'
assert_not_nil assigns(:order)
assert assigns(:order).valid?
end
def test_new
get :new
assert_response :success
assert_template 'new'
assert_not_nil assigns(:order)
end
def test_create
num_orders = Order.count
post :create, :order => {}
assert_response :redirect
assert_redirected_to :action => 'list'
assert_equal num_orders + 1, Order.count
end
def test_edit
get :edit, :id => 1
assert_response :success
assert_template 'edit'
assert_not_nil assigns(:order)
assert assigns(:order).valid?
end
def test_update
post :update, :id => 1
assert_response :redirect
assert_redirected_to :action => 'show', :id => 1
end
def test_destroy
assert_not_nil Order.find(1)
post :destroy, :id => 1
assert_response :redirect
assert_redirected_to :action => 'list'
assert_raise(ActiveRecord::RecordNotFound) {
Order.find(1)
}
end
end

View file

@ -0,0 +1,18 @@
require File.dirname(__FILE__) + '/../test_helper'
require 'tasks_controller'
# Re-raise errors caught by the controller.
class TasksController; def rescue_action(e) raise e end; end
class TasksControllerTest < Test::Unit::TestCase
def setup
@controller = TasksController.new
@request = ActionController::TestRequest.new
@response = ActionController::TestResponse.new
end
# Replace this with your real tests.
def test_truth
assert true
end
end

28
test/test_helper.rb Normal file
View file

@ -0,0 +1,28 @@
ENV["RAILS_ENV"] = "test"
require File.expand_path(File.dirname(__FILE__) + "/../config/environment")
require 'test_help'
class Test::Unit::TestCase
# Transactional fixtures accelerate your tests by wrapping each test method
# in a transaction that's rolled back on completion. This ensures that the
# test database remains unchanged so your fixtures don't have to be reloaded
# between every test method. Fewer database queries means faster tests.
#
# Read Mike Clark's excellent walkthrough at
# http://clarkware.com/cgi/blosxom/2005/10/24#Rails10FastTesting
#
# Every Active Record database supports transactions except MyISAM tables
# in MySQL. Turn off transactional fixtures in this case; however, if you
# don't care one way or the other, switching from MyISAM to InnoDB tables
# is recommended.
self.use_transactional_fixtures = true
# Instantiated fixtures are slow, but give you @david where otherwise you
# would need people(:david). If you don't want to migrate your existing
# test cases which use the @david style and don't mind the speed hit (each
# instantiated fixtures translates to a database query per test method),
# then set this back to true.
self.use_instantiated_fixtures = false
# Add more helper methods to be used by all tests here...
end

View file

@ -0,0 +1,10 @@
require File.dirname(__FILE__) + '/../test_helper'
class ArticleCategoryTest < Test::Unit::TestCase
fixtures :article_categories
# Replace this with your real tests.
def test_truth
assert true
end
end

10
test/unit/article_test.rb Normal file
View file

@ -0,0 +1,10 @@
require File.dirname(__FILE__) + '/../test_helper'
class ArticleTest < Test::Unit::TestCase
fixtures :articles
# Replace this with your real tests.
def test_truth
assert true
end
end

View file

@ -0,0 +1,10 @@
require File.dirname(__FILE__) + '/../test_helper'
class AssignmentTest < Test::Unit::TestCase
fixtures :assignments
# Replace this with your real tests.
def test_truth
assert true
end
end

View file

@ -0,0 +1,10 @@
require File.dirname(__FILE__) + '/../test_helper'
class FinancialTransactionTest < Test::Unit::TestCase
fixtures :financial_transactions
# Replace this with your real tests.
def test_truth
assert true
end
end

View file

@ -0,0 +1,10 @@
require File.dirname(__FILE__) + '/../test_helper'
class GroupOrderArticleQuantityTest < Test::Unit::TestCase
fixtures :group_order_article_quantities
# Replace this with your real tests.
def test_truth
assert true
end
end

View file

@ -0,0 +1,10 @@
require File.dirname(__FILE__) + '/../test_helper'
class GroupOrderArticleResultTest < Test::Unit::TestCase
fixtures :group_order_article_results
# Replace this with your real tests.
def test_truth
assert true
end
end

View file

@ -0,0 +1,10 @@
require File.dirname(__FILE__) + '/../test_helper'
class GroupOrderResultTest < Test::Unit::TestCase
fixtures :group_order_results
# Replace this with your real tests.
def test_truth
assert true
end
end

10
test/unit/group_test.rb Normal file
View file

@ -0,0 +1,10 @@
require File.dirname(__FILE__) + '/../test_helper'
class GroupTest < Test::Unit::TestCase
fixtures :groups
# Replace this with your real tests.
def test_truth
assert true
end
end

View file

@ -0,0 +1,10 @@
require File.dirname(__FILE__) + '/../test_helper'
class MembershipTest < Test::Unit::TestCase
fixtures :memberships
# Replace this with your real tests.
def test_truth
assert true
end
end

View file

@ -0,0 +1,10 @@
require File.dirname(__FILE__) + '/../test_helper'
class MessagesTest < Test::Unit::TestCase
fixtures :messages
# Replace this with your real tests.
def test_truth
assert true
end
end

View file

@ -0,0 +1,10 @@
require File.dirname(__FILE__) + '/../test_helper'
class OrderArticleResultTest < Test::Unit::TestCase
fixtures :order_article_results
# Replace this with your real tests.
def test_truth
assert true
end
end

10
test/unit/order_test.rb Normal file
View file

@ -0,0 +1,10 @@
require File.dirname(__FILE__) + '/../test_helper'
class OrderTest < Test::Unit::TestCase
fixtures :orders
# Replace this with your real tests.
def test_truth
assert true
end
end

View file

@ -0,0 +1,10 @@
require File.dirname(__FILE__) + '/../test_helper'
class SharedArticleTest < Test::Unit::TestCase
fixtures :shared_articles
# Replace this with your real tests.
def test_truth
assert true
end
end

View file

@ -0,0 +1,10 @@
require File.dirname(__FILE__) + '/../test_helper'
class SharedSupplierTest < Test::Unit::TestCase
fixtures :shared_suppliers
# Replace this with your real tests.
def test_truth
assert true
end
end

View file

@ -0,0 +1,22 @@
require File.dirname(__FILE__) + '/../test_helper'
class SupplierTest < Test::Unit::TestCase
fixtures :suppliers
def setup
@supplier = Supplier.find_by_name("Terra")
end
def test_read
assert_equal "Terra", @supplier.name
assert_equal "www.terra-natur.de", @supplier.url
end
def test_update
assert_equal "tuesday", @supplier.delivery_days
@supplier.delivery_days = 'wednesday'
assert @supplier.save, @supplier.errors.full_messages.join("; ")
@supplier.reload
assert_equal 'wednesday', @supplier.delivery_days
end
end

10
test/unit/task_test.rb Normal file
View file

@ -0,0 +1,10 @@
require File.dirname(__FILE__) + '/../test_helper'
class TaskTest < Test::Unit::TestCase
fixtures :tasks
# Replace this with your real tests.
def test_truth
assert true
end
end

33
test/unit/user_test.rb Normal file
View file

@ -0,0 +1,33 @@
require File.dirname(__FILE__) + '/../test_helper'
class UserTest < Test::Unit::TestCase
fixtures :users
def setup
@admin = users(:admin)
end
def test_read_user
assert_kind_of User, @admin
assert_equal "Anton", @admin.first_name
assert_equal "Admininistrator", @admin.last_name
assert_equal "admin@foo.test", @admin.email
assert @admin.role_admin?
end
def test_create_and_read_password
@admin.set_password({:required => true}, "secret", "secret")
@admin.save
assert @admin.has_password("secret")
end
def test_invalid_password
@admin.set_password({:required => true}, "foo", "foo")
assert_equal 'Passwort muss zwischen 6 u. 25 Zeichen haben', @admin.errors.on_base
end
def test_password_not_match
@admin.set_password({:required => true}, "foobar", "foobor")
assert_equal 'Passworteingaben stimmen nicht überein', @admin.errors.on_base
end
end