Initial import
This commit is contained in:
108
test/functional/attachments_controller_test.rb
Normal file
108
test/functional/attachments_controller_test.rb
Normal file
@@ -0,0 +1,108 @@
|
||||
# Engenharia de Software 2007.1
|
||||
# Copyright (C) 2007, Adriano, Alinson, Andre, Rafael e Bustamante
|
||||
#
|
||||
# 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
|
||||
# at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
|
||||
require File.dirname(__FILE__) + '/../test_helper'
|
||||
require 'attachments_controller'
|
||||
|
||||
# Re-raise errors caught by the controller.
|
||||
class AttachmentsController; def rescue_action(e) raise e end; end
|
||||
|
||||
class AttachmentsControllerTest < Test::Unit::TestCase
|
||||
fixtures :attachments
|
||||
|
||||
def setup
|
||||
@controller = AttachmentsController.new
|
||||
@request = ActionController::TestRequest.new
|
||||
@response = ActionController::TestResponse.new
|
||||
end
|
||||
|
||||
def test_truth
|
||||
assert true
|
||||
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(:attachments)
|
||||
# end
|
||||
#
|
||||
# def test_show
|
||||
# get :show, :id => @first_id
|
||||
#
|
||||
# assert_response :success
|
||||
# assert_template 'show'
|
||||
#
|
||||
# assert_not_nil assigns(:attachment)
|
||||
# assert assigns(:attachment).valid?
|
||||
# end
|
||||
#
|
||||
# def test_new
|
||||
# get :new
|
||||
#
|
||||
# assert_response :success
|
||||
# assert_template 'new'
|
||||
#
|
||||
# assert_not_nil assigns(:attachment)
|
||||
# end
|
||||
#
|
||||
# def test_create
|
||||
# num_attachments = Attachment.count
|
||||
#
|
||||
# post :create, :attachment => {}
|
||||
#
|
||||
# assert_response :redirect
|
||||
# assert_redirected_to :action => 'list'
|
||||
#
|
||||
# assert_equal num_attachments + 1, Attachment.count
|
||||
# end
|
||||
#
|
||||
# def test_edit
|
||||
# get :edit, :id => @first_id
|
||||
#
|
||||
# assert_response :success
|
||||
# assert_template 'edit'
|
||||
#
|
||||
# assert_not_nil assigns(:attachment)
|
||||
# assert assigns(:attachment).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 {
|
||||
# Attachment.find(@first_id)
|
||||
# }
|
||||
#
|
||||
# post :destroy, :id => @first_id
|
||||
# assert_response :redirect
|
||||
# assert_redirected_to :action => 'list'
|
||||
#
|
||||
# assert_raise(ActiveRecord::RecordNotFound) {
|
||||
# Attachment.find(@first_id)
|
||||
# }
|
||||
# end
|
||||
end
|
||||
50
test/functional/courses_controller_test.rb
Normal file
50
test/functional/courses_controller_test.rb
Normal file
@@ -0,0 +1,50 @@
|
||||
# Engenharia de Software 2007.1
|
||||
# Copyright (C) 2007, Adriano, Alinson, Andre, Rafael e Bustamante
|
||||
#
|
||||
# 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
|
||||
# at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
|
||||
require File.dirname(__FILE__) + '/../test_helper'
|
||||
require 'courses_controller'
|
||||
|
||||
# Re-raise errors caught by the controller.
|
||||
class CoursesController; def rescue_action(e) raise e end; end
|
||||
|
||||
class CoursesControllerTest < Test::Unit::TestCase
|
||||
|
||||
def setup
|
||||
@controller = CoursesController.new
|
||||
@request = ActionController::TestRequest.new
|
||||
@response = ActionController::TestResponse.new
|
||||
@course = Course.find(:first)
|
||||
end
|
||||
|
||||
# REST - usuários autenticados
|
||||
context "A user" do
|
||||
setup { login_as :bob }
|
||||
should_be_restful do |resource|
|
||||
resource.create.params = { :short_name => 'test', :full_name => 'test', :description => 'test' }
|
||||
resource.update.params = { :short_name => 'test', :full_name => 'test', :description => 'test' }
|
||||
end
|
||||
end
|
||||
|
||||
# REST - usuários quaisquer
|
||||
context "A stranger" do
|
||||
setup { logout }
|
||||
should_be_restful do |resource|
|
||||
resource.create.params = { :short_name => 'test', :full_name => 'test', :description => 'test' }
|
||||
resource.update.params = { :short_name => 'test', :full_name => 'test', :description => 'test' }
|
||||
resource.denied.actions = [ :new, :edit, :create, :update, :destroy ]
|
||||
resource.denied.redirect = "'/login'"
|
||||
resource.denied.flash = /must be logged in/i
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
58
test/functional/events_controller_test.rb
Normal file
58
test/functional/events_controller_test.rb
Normal file
@@ -0,0 +1,58 @@
|
||||
# Engenharia de Software 2007.1
|
||||
# Copyright (C) 2007, Adriano, Alinson, Andre, Rafael e Bustamante
|
||||
#
|
||||
# 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
|
||||
# at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
|
||||
require File.dirname(__FILE__) + '/../test_helper'
|
||||
require 'events_controller'
|
||||
|
||||
# Re-raise errors caught by the controller.
|
||||
class EventsController; def rescue_action(e) raise e end; end
|
||||
|
||||
class EventsControllerTest < Test::Unit::TestCase
|
||||
|
||||
def setup
|
||||
@controller = EventsController.new
|
||||
@request = ActionController::TestRequest.new
|
||||
@response = ActionController::TestResponse.new
|
||||
@course = Course.find(:first)
|
||||
@event = @course.events.find(:first)
|
||||
end
|
||||
|
||||
# REST - usuários autenticados
|
||||
context "A user" do
|
||||
setup { login_as :bob }
|
||||
should_be_restful do |resource|
|
||||
resource.parent = [ :course ]
|
||||
resource.create.params = { :title => 'test', :date => Date.today, :time => Time.now, :description => 'test', :created_by => 1 }
|
||||
resource.update.params = { :title => 'test', :date => Date.today, :time => Time.now, :description => 'test', :created_by => 1 }
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
# REST - usuários quaisquer
|
||||
context "A stranger" do
|
||||
setup { logout }
|
||||
should_be_restful do |resource|
|
||||
resource.parent = [ :course ]
|
||||
resource.create.params = { :title => 'test', :date => Date.today, :time => Time.now, :description => 'test', :created_by => 1 }
|
||||
resource.update.params = { :title => 'test', :date => Date.today, :time => Time.now, :description => 'test', :created_by => 1 }
|
||||
resource.denied.actions = [ :new, :edit, :create, :update, :destroy ]
|
||||
resource.denied.redirect = "'/login'"
|
||||
resource.denied.flash = /must be logged in/i
|
||||
end
|
||||
end
|
||||
|
||||
def test_should_accept_icalendar_on_index
|
||||
get :index, :format => 'ics', :course_id => 1
|
||||
assert_formatted_response :ics
|
||||
end
|
||||
end
|
||||
8
test/functional/log_controller_test.rb
Normal file
8
test/functional/log_controller_test.rb
Normal file
@@ -0,0 +1,8 @@
|
||||
require File.dirname(__FILE__) + '/../test_helper'
|
||||
|
||||
class LogControllerTest < ActionController::TestCase
|
||||
# Replace this with your real tests.
|
||||
def test_truth
|
||||
assert true
|
||||
end
|
||||
end
|
||||
49
test/functional/news_controller_test.rb
Normal file
49
test/functional/news_controller_test.rb
Normal file
@@ -0,0 +1,49 @@
|
||||
require File.dirname(__FILE__) + '/../test_helper'
|
||||
require 'news_controller'
|
||||
|
||||
# Re-raise errors caught by the controller.
|
||||
class NewsController; def rescue_action(e) raise e end; end
|
||||
|
||||
class NewsControllerTest < Test::Unit::TestCase
|
||||
def setup
|
||||
@controller = NewsController.new
|
||||
@request = ActionController::TestRequest.new
|
||||
@response = ActionController::TestResponse.new
|
||||
|
||||
@course = Course.find(:first)
|
||||
@news = @course.news.find(:first)
|
||||
end
|
||||
|
||||
# REST - usuários autenticados
|
||||
context "A user" do
|
||||
setup { login_as :bob }
|
||||
should_be_restful do |resource|
|
||||
resource.klass = News
|
||||
resource.object = 'news'
|
||||
resource.parent = [ :course ]
|
||||
resource.create.params = { :title => 'test', :body => 'test', :receiver_id => 1 }
|
||||
resource.update.params = { :title => 'test', :body => 'test', :receiver_id => 1 }
|
||||
resource.destroy.redirect = "course_news_index_url(@course)"
|
||||
end
|
||||
end
|
||||
|
||||
# REST - usuários quaisquer
|
||||
context "A stranger" do
|
||||
setup { logout }
|
||||
should_be_restful do |resource|
|
||||
resource.klass = News
|
||||
resource.object = 'news'
|
||||
resource.parent = [ :course ]
|
||||
resource.create.params = { :title => 'test', :body => 'test', :receiver_id => 1 }
|
||||
resource.update.params = { :title => 'test', :body => 'test', :receiver_id => 1 }
|
||||
resource.denied.actions = [ :new, :edit, :create, :update, :destroy ]
|
||||
resource.denied.redirect = "'/login'"
|
||||
resource.denied.flash = /must be logged in/i
|
||||
end
|
||||
end
|
||||
|
||||
def test_should_accept_rss_on_index
|
||||
get :index, :format => 'rss', :course_id => 1
|
||||
assert_formatted_response :rss
|
||||
end
|
||||
end
|
||||
33
test/functional/stylesheets_controller_test.rb
Normal file
33
test/functional/stylesheets_controller_test.rb
Normal file
@@ -0,0 +1,33 @@
|
||||
# Engenharia de Software 2007.1
|
||||
# Copyright (C) 2007, Adriano, Alinson, Andre, Rafael e Bustamante
|
||||
#
|
||||
# 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
|
||||
# at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
|
||||
require File.dirname(__FILE__) + '/../test_helper'
|
||||
require 'stylesheets_controller'
|
||||
|
||||
# Re-raise errors caught by the controller.
|
||||
class StylesheetsController; def rescue_action(e) raise e end; end
|
||||
|
||||
class StylesheetsControllerTest < Test::Unit::TestCase
|
||||
|
||||
def setup
|
||||
@controller = StylesheetsController.new
|
||||
@request = ActionController::TestRequest.new
|
||||
@response = ActionController::TestResponse.new
|
||||
end
|
||||
|
||||
# Replace this with your real tests.
|
||||
def test_truth
|
||||
assert true
|
||||
end
|
||||
|
||||
end
|
||||
30
test/functional/user_controller_test.rb
Normal file
30
test/functional/user_controller_test.rb
Normal file
@@ -0,0 +1,30 @@
|
||||
# Engenharia de Software 2007.1
|
||||
# Copyright (C) 2007, Adriano, Alinson, Andre, Rafael e Bustamante
|
||||
#
|
||||
# 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
|
||||
# at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
|
||||
require File.dirname(__FILE__) + '/../test_helper'
|
||||
require 'users_controller'
|
||||
|
||||
# Re-raise errors caught by the controller.
|
||||
class UsersController; def rescue_action(e) raise e end; end
|
||||
|
||||
class UsersControllerTest < Test::Unit::TestCase
|
||||
|
||||
self.use_instantiated_fixtures = true
|
||||
|
||||
fixtures :users
|
||||
|
||||
def test_true
|
||||
assert true
|
||||
end
|
||||
|
||||
end
|
||||
76
test/functional/wiki_controller_test.rb
Normal file
76
test/functional/wiki_controller_test.rb
Normal file
@@ -0,0 +1,76 @@
|
||||
|
||||
# Engenharia de Software 2007.1
|
||||
# Copyright (C) 2007, Adriano, Alinson, Andre, Rafael e Bustamante
|
||||
#
|
||||
# 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
|
||||
# at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
|
||||
require File.dirname(__FILE__) + '/../test_helper'
|
||||
require 'wiki_controller'
|
||||
|
||||
# Re-raise errors caught by the controller.
|
||||
class WikiController; def rescue_action(e) raise e end; end
|
||||
|
||||
class WikiControllerTest < Test::Unit::TestCase
|
||||
def setup
|
||||
@controller = WikiController.new
|
||||
@request = ActionController::TestRequest.new
|
||||
@response = ActionController::TestResponse.new
|
||||
@course = Course.find(:first)
|
||||
@wiki_page = @course.wiki_pages.create(:title => 'test1', :content => 'test1', :description => 'test', :version => 1)
|
||||
@wiki_page.user = users(:bob)
|
||||
@wiki_page.save!
|
||||
end
|
||||
|
||||
# REST - usuários autenticados
|
||||
context "A user" do
|
||||
setup { login_as :bob }
|
||||
should_be_restful do |resource|
|
||||
resource.klass = WikiPage
|
||||
resource.parent = [ :course ]
|
||||
resource.create.params = { :title => 'test2', :description => 'test', :content => 'test2', :course_id => 1 }
|
||||
resource.update.params = { :title => 'test3', :description => 'test', :content => 'test3', :course_id => 1 }
|
||||
resource.actions = [ :show, :new, :edit, :update, :create, :destroy ]
|
||||
resource.destroy.redirect = "course_url(@course)"
|
||||
resource.create.redirect = "course_wiki_url(@course, @wiki_page)"
|
||||
resource.update.redirect = "course_wiki_url(@course, @wiki_page)"
|
||||
end
|
||||
end
|
||||
|
||||
# REST - usuários quaisquer
|
||||
context "A stranger" do
|
||||
setup { logout }
|
||||
should_be_restful do |resource|
|
||||
resource.klass = WikiPage
|
||||
resource.parent = [ :course ]
|
||||
resource.create.params = { :title => 'test4', :description => 'test', :content => 'test4', :course_id => 1 }
|
||||
resource.update.params = { :title => 'test5', :description => 'test', :content => 'test5', :course_id => 1 }
|
||||
resource.actions = [ :show, :new, :edit, :update, :create, :destroy ]
|
||||
resource.denied.actions = [ :new, :edit, :create, :update, :destroy ]
|
||||
resource.denied.redirect = "'/login'"
|
||||
resource.denied.flash = /must be logged in/i
|
||||
end
|
||||
end
|
||||
|
||||
def test_should_accept_text_on_show
|
||||
get :show, :format => 'txt', :course_id => 1, :id => @wiki_page.id
|
||||
assert_formatted_response :text
|
||||
end
|
||||
|
||||
def test_should_accept_html_on_versions
|
||||
get :versions, :course_id => 1, :id => @wiki_page.id
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
def test_should_accept_xml_on_versions
|
||||
get :versions, :format => 'xml', :course_id => 1, :id => @wiki_page.id
|
||||
assert_formatted_response :xml, :versions
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user