Initial commit of foodsoft 2
This commit is contained in:
commit
5b9a7e05df
657 changed files with 70444 additions and 0 deletions
18
test/functional/admin_controller_test.rb
Normal file
18
test/functional/admin_controller_test.rb
Normal 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
|
||||
88
test/functional/articles_controller_test.rb
Normal file
88
test/functional/articles_controller_test.rb
Normal 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
|
||||
18
test/functional/finance_controller_test.rb
Normal file
18
test/functional/finance_controller_test.rb
Normal 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
|
||||
18
test/functional/index_controller_test.rb
Normal file
18
test/functional/index_controller_test.rb
Normal 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
|
||||
50
test/functional/login_controller_test.rb
Normal file
50
test/functional/login_controller_test.rb
Normal 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
|
||||
92
test/functional/messages_controller_test.rb
Normal file
92
test/functional/messages_controller_test.rb
Normal 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
|
||||
88
test/functional/orders_controller_test.rb
Normal file
88
test/functional/orders_controller_test.rb
Normal 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
|
||||
18
test/functional/tasks_controller_test.rb
Normal file
18
test/functional/tasks_controller_test.rb
Normal 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
|
||||
Loading…
Add table
Add a link
Reference in a new issue