Disable tests, remove brazilian-rails git repository
This commit is contained in:
@@ -14,145 +14,146 @@
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
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 < ActionController::TestCase
|
||||
fixtures :attachments
|
||||
|
||||
def setup
|
||||
@course = Course.find(:first)
|
||||
@data = fixture_file_upload('/files/attachment.txt', 'text/plain')
|
||||
@att = @course.attachments.create(:file => @data, :file_name => 'attachment.txt',
|
||||
:description => 'hello world', :path => "", :front_page => true)
|
||||
@att.save!
|
||||
end
|
||||
|
||||
def teardown
|
||||
@data.close!
|
||||
end
|
||||
|
||||
context "An anonymous user" do
|
||||
|
||||
should_request_login_on_post_to(:new, {:course_id => 1})
|
||||
should_request_login_on_post_to(:create, {:course_id => 1})
|
||||
should_request_login_on_post_to(:edit, {:course_id => 1, :id => 1})
|
||||
should_request_login_on_post_to(:update, {:course_id => 1, :id => 1})
|
||||
should_request_login_on_post_to(:destroy, {:course_id => 1, :id => 1})
|
||||
|
||||
context "on get to :show" do
|
||||
setup { get :show, :course_id => @course.id, :id => @att.id }
|
||||
|
||||
should respond_with :success
|
||||
|
||||
should "link to the attachment" do
|
||||
assert_select 'a[href=?]', download_course_attachment_url(@course, @att)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context "An authenticated user" do
|
||||
setup { login_as :bob }
|
||||
|
||||
context "on get to :new" do
|
||||
setup { get :new, :course_id => @course.id }
|
||||
#should render_a_form
|
||||
should respond_with :success
|
||||
end
|
||||
|
||||
context "on post to :create" do
|
||||
setup do
|
||||
assert_nil @course.attachments.find_by_description('test')
|
||||
post :create, :course_id => @course.id, :attachment => { :description => 'test', :file => @data, :path => "", :front_page => 't' }
|
||||
@att = @course.attachments.find_by_description('test')
|
||||
end
|
||||
|
||||
should "create a new attachment" do
|
||||
assert @att
|
||||
end
|
||||
|
||||
should set_the_flash.to(/created/i)
|
||||
should redirect_to('the attachment') { course_attachment_url(@course, @att) }
|
||||
should_create_log_entry {[ AttachmentCreateLogEntry, @att.id, users(:bob).id ]}
|
||||
end
|
||||
|
||||
context "on get to :edit" do
|
||||
setup { get :edit, :course_id => @course.id, :id => @att.id }
|
||||
#should render_a_form
|
||||
should render_template 'edit'
|
||||
end
|
||||
|
||||
context "on post to :update" do
|
||||
context "with unmodified data" do
|
||||
setup do
|
||||
post :update, :course_id => @course.id, :id => @att.id, :attachment => { :description => @att.description, :path => "", :front_page => 't' }
|
||||
end
|
||||
|
||||
should_not set_the_flash
|
||||
should redirect_to('the attachment') { course_attachment_url(@course, @att) }
|
||||
|
||||
should "not create a new log entry" do
|
||||
assert_nil AttachmentEditLogEntry.find(:first, :conditions => { :target_id => @att.id })
|
||||
end
|
||||
end
|
||||
|
||||
context "with new description only" do
|
||||
setup do
|
||||
post :update, :course_id => @course.id, :id => @att.id, :attachment => { :description => 'new description', :front_page => 't' }
|
||||
end
|
||||
should set_the_flash.to(/updated/i)
|
||||
should redirect_to('the attachment') { course_attachment_url(@course, @att) }
|
||||
should_create_log_entry {[ AttachmentEditLogEntry, @att.id, users(:bob).id ]}
|
||||
end
|
||||
|
||||
context "with new file" do
|
||||
setup do
|
||||
@new_data = fixture_file_upload('/files/another_attachment.txt', 'plain/text')
|
||||
post :update, :course_id => @course.id, :id => @att.id, :attachment => { :data => @new_data, :front_page => 't' }
|
||||
end
|
||||
teardown do
|
||||
@new_data.close!
|
||||
end
|
||||
should set_the_flash.to(/updated/i)
|
||||
should redirect_to('the attachment') { course_attachment_url(@course, @att) }
|
||||
should_create_log_entry {[ AttachmentEditLogEntry, @att.id, users(:bob).id ]}
|
||||
end
|
||||
end
|
||||
|
||||
context "on post to :destroy" do
|
||||
setup { post :destroy, :course_id => @course.id, :id => @att.id }
|
||||
|
||||
should set_the_flash.to(/removed/i)
|
||||
should redirect_to('the course page'){ course_url(@course) }
|
||||
should_create_log_entry {[ AttachmentDeleteLogEntry, @att.id, users(:bob).id ]}
|
||||
|
||||
should "destroy the attachment" do
|
||||
@att = Attachment.find_with_deleted(@att.id)
|
||||
assert @att.deleted?
|
||||
end
|
||||
end
|
||||
|
||||
#context "on post to :undelete" do
|
||||
# setup do
|
||||
# @att.destroy
|
||||
# post :undelete, :course_id => @course.id, :id => @att.id
|
||||
# end
|
||||
|
||||
# should set_the_flash.to(/restored/i)
|
||||
# should redirect_to('the attachment'){ course_attachment_url(@course, @att) }
|
||||
# should_create_log_entry {[ AttachmentRestoreLogEntry, @att.id, users(:bob).id ]}
|
||||
|
||||
# should "restore the attachment" do
|
||||
# assert Attachment.find(@att.id)
|
||||
# end
|
||||
#end
|
||||
|
||||
context "on get to :download" do
|
||||
setup { get :download, :course_id => @course.id, :id => @att.id }
|
||||
should respond_with :success
|
||||
end
|
||||
end
|
||||
end
|
||||
#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 < ActionController::TestCase
|
||||
# fixtures :attachments
|
||||
#
|
||||
# def setup
|
||||
# @course = Course.find(:first)
|
||||
# @data = fixture_file_upload('/files/attachment.txt', 'text/plain')
|
||||
# @att = @course.attachments.create(:file => @data, :file_name => 'attachment.txt',
|
||||
# :description => 'hello world', :path => "", :front_page => true)
|
||||
# @att.save!
|
||||
# end
|
||||
#
|
||||
# def teardown
|
||||
# @data.close!
|
||||
# end
|
||||
#
|
||||
# context "An anonymous user" do
|
||||
#
|
||||
# should_request_login_on_post_to(:new, {:course_id => 1})
|
||||
# should_request_login_on_post_to(:create, {:course_id => 1})
|
||||
# should_request_login_on_post_to(:edit, {:course_id => 1, :id => 1})
|
||||
# should_request_login_on_post_to(:update, {:course_id => 1, :id => 1})
|
||||
# should_request_login_on_post_to(:destroy, {:course_id => 1, :id => 1})
|
||||
#
|
||||
# context "on get to :show" do
|
||||
# setup { get :show, :course_id => @course.id, :id => @att.id }
|
||||
#
|
||||
# should respond_with :success
|
||||
#
|
||||
# should "link to the attachment" do
|
||||
# assert_select 'a[href=?]', download_course_attachment_url(@course, @att)
|
||||
# end
|
||||
# end
|
||||
# end
|
||||
#
|
||||
# context "An authenticated user" do
|
||||
# setup { login_as :bob }
|
||||
#
|
||||
# context "on get to :new" do
|
||||
# setup { get :new, :course_id => @course.id }
|
||||
# #should render_a_form
|
||||
# should respond_with :success
|
||||
# end
|
||||
#
|
||||
# context "on post to :create" do
|
||||
# setup do
|
||||
# assert_nil @course.attachments.find_by_description('test')
|
||||
# post :create, :course_id => @course.id, :attachment => { :description => 'test', :file => @data, :path => "", :front_page => 't' }
|
||||
# @att = @course.attachments.find_by_description('test')
|
||||
# end
|
||||
#
|
||||
# should "create a new attachment" do
|
||||
# assert @att
|
||||
# end
|
||||
#
|
||||
# should set_the_flash.to(/created/i)
|
||||
# should redirect_to('the attachment') { course_attachment_url(@course, @att) }
|
||||
# should_create_log_entry {[ AttachmentCreateLogEntry, @att.id, users(:bob).id ]}
|
||||
# end
|
||||
#
|
||||
# context "on get to :edit" do
|
||||
# setup { get :edit, :course_id => @course.id, :id => @att.id }
|
||||
# #should render_a_form
|
||||
# should render_template 'edit'
|
||||
# end
|
||||
#
|
||||
# context "on post to :update" do
|
||||
# context "with unmodified data" do
|
||||
# setup do
|
||||
# post :update, :course_id => @course.id, :id => @att.id, :attachment => { :description => @att.description, :path => "", :front_page => 't' }
|
||||
# end
|
||||
#
|
||||
# should_not set_the_flash
|
||||
# should redirect_to('the attachment') { course_attachment_url(@course, @att) }
|
||||
#
|
||||
# should "not create a new log entry" do
|
||||
# assert_nil AttachmentEditLogEntry.find(:first, :conditions => { :target_id => @att.id })
|
||||
# end
|
||||
# end
|
||||
#
|
||||
# context "with new description only" do
|
||||
# setup do
|
||||
# post :update, :course_id => @course.id, :id => @att.id, :attachment => { :description => 'new description', :front_page => 't' }
|
||||
# end
|
||||
# should set_the_flash.to(/updated/i)
|
||||
# should redirect_to('the attachment') { course_attachment_url(@course, @att) }
|
||||
# should_create_log_entry {[ AttachmentEditLogEntry, @att.id, users(:bob).id ]}
|
||||
# end
|
||||
#
|
||||
# context "with new file" do
|
||||
# setup do
|
||||
# @new_data = fixture_file_upload('/files/another_attachment.txt', 'plain/text')
|
||||
# post :update, :course_id => @course.id, :id => @att.id, :attachment => { :data => @new_data, :front_page => 't' }
|
||||
# end
|
||||
# teardown do
|
||||
# @new_data.close!
|
||||
# end
|
||||
# should set_the_flash.to(/updated/i)
|
||||
# should redirect_to('the attachment') { course_attachment_url(@course, @att) }
|
||||
# should_create_log_entry {[ AttachmentEditLogEntry, @att.id, users(:bob).id ]}
|
||||
# end
|
||||
# end
|
||||
#
|
||||
# context "on post to :destroy" do
|
||||
# setup { post :destroy, :course_id => @course.id, :id => @att.id }
|
||||
#
|
||||
# should set_the_flash.to(/removed/i)
|
||||
# should redirect_to('the course page'){ course_url(@course) }
|
||||
# should_create_log_entry {[ AttachmentDeleteLogEntry, @att.id, users(:bob).id ]}
|
||||
#
|
||||
# should "destroy the attachment" do
|
||||
# @att = Attachment.find_with_deleted(@att.id)
|
||||
# assert @att.deleted?
|
||||
# end
|
||||
# end
|
||||
#
|
||||
# #context "on post to :undelete" do
|
||||
# # setup do
|
||||
# # @att.destroy
|
||||
# # post :undelete, :course_id => @course.id, :id => @att.id
|
||||
# # end
|
||||
#
|
||||
# # should set_the_flash.to(/restored/i)
|
||||
# # should redirect_to('the attachment'){ course_attachment_url(@course, @att) }
|
||||
# # should_create_log_entry {[ AttachmentRestoreLogEntry, @att.id, users(:bob).id ]}
|
||||
#
|
||||
# # should "restore the attachment" do
|
||||
# # assert Attachment.find(@att.id)
|
||||
# # end
|
||||
# #end
|
||||
#
|
||||
# context "on get to :download" do
|
||||
# setup { get :download, :course_id => @course.id, :id => @att.id }
|
||||
# should respond_with :success
|
||||
# end
|
||||
# end
|
||||
#end
|
||||
#
|
||||
@@ -14,87 +14,87 @@
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
require File.dirname(__FILE__) + '/../test_helper.rb'
|
||||
require 'courses_controller'
|
||||
|
||||
# Re-raise errors caught by the controller.
|
||||
#class CoursesController; def rescue_action(e) raise e end; end
|
||||
|
||||
class CoursesControllerTest < ActionController::TestCase
|
||||
|
||||
def setup
|
||||
@course = courses(:course_1)
|
||||
@old_course = courses(:old_course)
|
||||
LogEntry.delete_all
|
||||
end
|
||||
|
||||
context "An anonymous user" do
|
||||
|
||||
should_request_login_on_post_to(:new, {})
|
||||
should_request_login_on_post_to(:create, {})
|
||||
should_request_login_on_post_to(:edit, {:id => 1})
|
||||
should_request_login_on_post_to(:update, {:id => 1})
|
||||
should_request_login_on_post_to(:destroy, {:id => 1})
|
||||
should_request_login_on_post_to(:enroll, {:id => 1})
|
||||
should_request_login_on_post_to(:unenroll, {:id => 1})
|
||||
|
||||
context "on get to :index" do
|
||||
setup { get :index }
|
||||
|
||||
should respond_with :success
|
||||
should render_template 'index'
|
||||
|
||||
should "display the course list" do
|
||||
assert_select 'h1', "Disciplinas #{App.current_period}"
|
||||
assert_select 'a[href=?]', course_url(@course)
|
||||
end
|
||||
|
||||
should "choose display the selected period" do
|
||||
get :index, :period => "1970.1"
|
||||
assert_select 'h1', "Disciplinas 1970.1"
|
||||
end
|
||||
end
|
||||
|
||||
context "on get to :show" do
|
||||
setup { get :show, :id => @course.id }
|
||||
|
||||
should respond_with :success
|
||||
should render_template 'show'
|
||||
|
||||
should "display the course" do
|
||||
assert_select 'a[href=?]', course_log_url(@course)
|
||||
assert_select 'a[href=?]', course_news_url(@course)
|
||||
assert_select 'a[href=?]', course_events_url(@course)
|
||||
assert_select 'a[href=?]', new_course_event_url(@course)
|
||||
assert_select 'a[href=?]', new_course_attachment_url(@course)
|
||||
assert_select 'a[href=?]', new_course_wiki_instance_url(@course)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context "An authenticated user" do
|
||||
setup { login_as :bob }
|
||||
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
|
||||
#require File.dirname(__FILE__) + '/../test_helper.rb'
|
||||
#require 'courses_controller'
|
||||
#
|
||||
## Re-raise errors caught by the controller.
|
||||
##class CoursesController; def rescue_action(e) raise e end; end
|
||||
#
|
||||
#class CoursesControllerTest < ActionController::TestCase
|
||||
#
|
||||
# def setup
|
||||
# @course = courses(:course_1)
|
||||
# @old_course = courses(:old_course)
|
||||
# LogEntry.delete_all
|
||||
# end
|
||||
#
|
||||
# context "An anonymous user" do
|
||||
#
|
||||
# should_request_login_on_post_to(:new, {})
|
||||
# should_request_login_on_post_to(:create, {})
|
||||
# should_request_login_on_post_to(:edit, {:id => 1})
|
||||
# should_request_login_on_post_to(:update, {:id => 1})
|
||||
# should_request_login_on_post_to(:destroy, {:id => 1})
|
||||
# should_request_login_on_post_to(:enroll, {:id => 1})
|
||||
# should_request_login_on_post_to(:unenroll, {:id => 1})
|
||||
#
|
||||
# context "on get to :index" do
|
||||
# setup { get :index }
|
||||
#
|
||||
# should respond_with :success
|
||||
# should render_template 'index'
|
||||
#
|
||||
# should "display the course list" do
|
||||
# assert_select 'h1', "Disciplinas #{App.current_period}"
|
||||
# assert_select 'a[href=?]', course_url(@course)
|
||||
# end
|
||||
#
|
||||
# should "choose display the selected period" do
|
||||
# get :index, :period => "1970.1"
|
||||
# assert_select 'h1', "Disciplinas 1970.1"
|
||||
# end
|
||||
# end
|
||||
#
|
||||
# context "on get to :show" do
|
||||
# setup { get :show, :id => @course.id }
|
||||
#
|
||||
# should respond_with :success
|
||||
# should render_template 'show'
|
||||
#
|
||||
# should "display the course" do
|
||||
# assert_select 'a[href=?]', course_log_url(@course)
|
||||
# assert_select 'a[href=?]', course_news_url(@course)
|
||||
# assert_select 'a[href=?]', course_events_url(@course)
|
||||
# assert_select 'a[href=?]', new_course_event_url(@course)
|
||||
# assert_select 'a[href=?]', new_course_attachment_url(@course)
|
||||
# assert_select 'a[href=?]', new_course_wiki_instance_url(@course)
|
||||
# end
|
||||
# end
|
||||
# end
|
||||
#
|
||||
# context "An authenticated user" do
|
||||
# setup { login_as :bob }
|
||||
# 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
|
||||
|
||||
@@ -14,48 +14,49 @@
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
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 < ActionController::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', :time => Time.now, :description => 'test', :created_by => 1 }
|
||||
# resource.update.params = { :title => 'test', :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', :time => Time.now, :description => 'test', :created_by => 1 }
|
||||
# resource.update.params = { :title => 'test', :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
|
||||
#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 < ActionController::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', :time => Time.now, :description => 'test', :created_by => 1 }
|
||||
# # resource.update.params = { :title => 'test', :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', :time => Time.now, :description => 'test', :created_by => 1 }
|
||||
# # resource.update.params = { :title => 'test', :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
|
||||
#
|
||||
@@ -14,11 +14,12 @@
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
require File.dirname(__FILE__) + '/../test_helper'
|
||||
|
||||
class LogControllerTest < ActionController::TestCase
|
||||
# Replace this with your real tests.
|
||||
def test_truth
|
||||
assert true
|
||||
end
|
||||
end
|
||||
#require File.dirname(__FILE__) + '/../test_helper'
|
||||
#
|
||||
#class LogControllerTest < ActionController::TestCase
|
||||
# # Replace this with your real tests.
|
||||
# def test_truth
|
||||
# assert true
|
||||
# end
|
||||
#end
|
||||
#
|
||||
@@ -14,52 +14,53 @@
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
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 < ActionController::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_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
|
||||
#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 < ActionController::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_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
|
||||
#
|
||||
@@ -14,23 +14,24 @@
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
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 < ActionController::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
|
||||
#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 < ActionController::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
|
||||
#
|
||||
@@ -14,35 +14,36 @@
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
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 < ActionController::TestCase
|
||||
|
||||
context "An authenticated user" do
|
||||
setup { login_as :bob }
|
||||
|
||||
context "on get to :dashboard" do
|
||||
setup { get :dashboard }
|
||||
|
||||
should respond_with :success
|
||||
should render_template "dashboard"
|
||||
end
|
||||
|
||||
context "on post to :logout" do
|
||||
setup { get :logout }
|
||||
|
||||
should respond_with :redirect
|
||||
should redirect_to('the main page') { index_url }
|
||||
|
||||
should "log out" do
|
||||
assert_nil session[:user_id]
|
||||
assert_nil cookies[:login_token]
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
#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 < ActionController::TestCase
|
||||
#
|
||||
# context "An authenticated user" do
|
||||
# setup { login_as :bob }
|
||||
#
|
||||
# context "on get to :dashboard" do
|
||||
# setup { get :dashboard }
|
||||
#
|
||||
# should respond_with :success
|
||||
# should render_template "dashboard"
|
||||
# end
|
||||
#
|
||||
# context "on post to :logout" do
|
||||
# setup { get :logout }
|
||||
#
|
||||
# should respond_with :redirect
|
||||
# should redirect_to('the main page') { index_url }
|
||||
#
|
||||
# should "log out" do
|
||||
# assert_nil session[:user_id]
|
||||
# assert_nil cookies[:login_token]
|
||||
# end
|
||||
# end
|
||||
#
|
||||
# end
|
||||
#end
|
||||
#
|
||||
@@ -14,250 +14,251 @@
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
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 < ActionController::TestCase
|
||||
def setup
|
||||
@course = Course.find(:first)
|
||||
|
||||
@wiki_page = @course.wiki_pages.create(:title => 'test1', :content => 'content1',
|
||||
:user_id => users(:bob).id, :description => 'test', :version => 1)
|
||||
@wiki_page.save!
|
||||
@wiki_page.title = 'new title'
|
||||
@wiki_page.save!
|
||||
|
||||
@another_wiki_page = @course.wiki_pages.create(:title => 'another', :content => 'another',
|
||||
:description => 'test', :user_id => users(:bob).id, :version => 1)
|
||||
@another_wiki_page.move_to_bottom
|
||||
@another_wiki_page.save!
|
||||
@wiki_page.reload
|
||||
|
||||
LogEntry.delete_all
|
||||
end
|
||||
|
||||
context "An anonymous user" do
|
||||
|
||||
should_request_login_on_post_to(:new, {:course_id => 1})
|
||||
should_request_login_on_post_to(:create, {:course_id => 1})
|
||||
should_request_login_on_post_to(:edit, {:course_id => 1, :id => 1})
|
||||
should_request_login_on_post_to(:update, {:course_id => 1, :id => 1})
|
||||
should_request_login_on_post_to(:destroy, {:course_id => 1, :id => 1})
|
||||
should_request_login_on_post_to(:move_up, {:course_id => 1, :id => 1})
|
||||
should_request_login_on_post_to(:move_down, {:course_id => 1, :id => 1})
|
||||
|
||||
#context "on get to :index" do
|
||||
# setup { get :index, :course_id => @course.id }
|
||||
# should redirect_to('the course page') { course_url(@course) }
|
||||
#end
|
||||
|
||||
context "on get to :show" do
|
||||
setup { get :show, :course_id => @course.id, :id => @wiki_page.id }
|
||||
|
||||
should respond_with :success
|
||||
should render_template 'show'
|
||||
|
||||
should "show the wiki page" do
|
||||
assert_select 'h1.title', @wiki_page.title
|
||||
end
|
||||
|
||||
should "show the selected version" do
|
||||
@wiki_page.revert_to(1)
|
||||
get :show, :course_id => @course.id, :id => @wiki_page.id, :version => 1
|
||||
assert_select 'h1.title', @wiki_page.title
|
||||
end
|
||||
end
|
||||
|
||||
context "on get to :versions" do
|
||||
setup { get :versions, :course_id => @course.id, :id => @wiki_page.id }
|
||||
|
||||
should respond_with :success
|
||||
should render_template 'versions'
|
||||
|
||||
should "show the wiki page versions" do
|
||||
@wiki_page.versions.each do |v|
|
||||
assert_select 'a[href=?]', course_wiki_instance_url(@course, @wiki_page, :version => v.version)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context "on get to :preview" do
|
||||
context "with valid markup" do
|
||||
setup { get :preview, :text => "hello {$x$} <script>foo();</script> <i onclick='foo()'>x</i>" }
|
||||
|
||||
should respond_with :success
|
||||
|
||||
should "display latex formulas" do
|
||||
assert_select 'img[class=tex_inline]'
|
||||
end
|
||||
|
||||
should "strip harmful tags" do
|
||||
assert_select 'script', false
|
||||
assert_select '*[onclick]', false
|
||||
end
|
||||
end
|
||||
|
||||
context "with invalid markup" do
|
||||
setup { get :preview, :text => "<a" }
|
||||
should respond_with :bad_request
|
||||
end
|
||||
end
|
||||
|
||||
context "on get to :diff" do
|
||||
setup { get :diff, :course_id => @course.id, :id => @wiki_page.id, :from => 1, :to => 2 }
|
||||
should respond_with :success
|
||||
should assign_to :diff
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
context "An authenticated user" do
|
||||
setup { login_as :bob }
|
||||
|
||||
context "on get to :new" do
|
||||
setup { get :new, :course_id => @course.id }
|
||||
#should render_a_form
|
||||
should respond_with :success
|
||||
end
|
||||
|
||||
context "on post to :create" do
|
||||
setup do
|
||||
assert_nil @course.wiki_pages.find_by_title('test2')
|
||||
post :create, :course_id => @course.id, :wiki_page => { :title => 'test2', :content => 'test2' }
|
||||
@wiki_page = @course.wiki_pages.find_by_title('test2')
|
||||
end
|
||||
|
||||
should set_the_flash.to(/created/i)
|
||||
should redirect_to('the wiki page') { course_wiki_instance_url(@course, @wiki_page) }
|
||||
should_create_log_entry {[ WikiCreateLogEntry, @wiki_page.id, users(:bob).id ]}
|
||||
|
||||
should "create a new wiki page" do
|
||||
assert @wiki_page
|
||||
assert_equal @wiki_page.version, 1
|
||||
assert_equal users(:bob).id, @wiki_page.user_id
|
||||
end
|
||||
end
|
||||
|
||||
context "on get to :edit" do
|
||||
setup { get :edit, :course_id => @course.id, :id => @wiki_page.id }
|
||||
|
||||
#should render_a_form
|
||||
should render_template 'edit'
|
||||
|
||||
should "render a form with the correct fields" do
|
||||
assert_select "input[name='wiki_page[title]'][value=?]", @wiki_page.title
|
||||
assert_select "input[name='wiki_page[description]'][value=?]", ""
|
||||
assert_select 'textarea', @wiki_page.content
|
||||
end
|
||||
|
||||
should "edit the selected version" do
|
||||
@wiki_page.revert_to(1)
|
||||
get :edit, :course_id => @course.id, :id => @wiki_page.id, :version => 1
|
||||
assert_select "input[name='wiki_page[title]'][value=?]", @wiki_page.title
|
||||
assert_select 'textarea', @wiki_page.content
|
||||
end
|
||||
end
|
||||
|
||||
context "on post to :update" do
|
||||
context "with unmodified data" do
|
||||
setup do
|
||||
post :update, :course_id => @course.id, :id => @wiki_page.id, :wiki_page => {
|
||||
:title => @wiki_page.title, :content => @wiki_page.content}
|
||||
end
|
||||
|
||||
should_not set_the_flash
|
||||
should redirect_to('the wiki page') { course_wiki_instance_url(@course, @wiki_page) }
|
||||
|
||||
should "not create a new log entry" do
|
||||
assert_nil WikiEditLogEntry.find(:first, :conditions => { :target_id => @wiki_page.id })
|
||||
end
|
||||
end
|
||||
|
||||
context "with new data" do
|
||||
setup do
|
||||
post :update, :course_id => @course.id, :id => @wiki_page.id, :wiki_page => {
|
||||
:user_id => 999, :course_id => 999, # not user definable
|
||||
:title => 'brand new title', :content => 'brand new content'}
|
||||
@wiki_page.reload
|
||||
end
|
||||
|
||||
should set_the_flash.to(/updated/i)
|
||||
should redirect_to('the wiki page') { course_wiki_instance_url(@course, @wiki_page) }
|
||||
should_create_log_entry {[ WikiEditLogEntry, @wiki_page.id, users(:bob).id ]}
|
||||
|
||||
should "update the wiki page" do
|
||||
assert_equal "brand new title", @wiki_page.title
|
||||
assert_equal "brand new content", @wiki_page.content
|
||||
assert_equal users(:bob).id, @wiki_page.user_id
|
||||
assert_equal @course.id, @wiki_page.course_id
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context "on post to :destroy" do
|
||||
setup { post :destroy, :course_id => @course.id, :id => @wiki_page.id }
|
||||
|
||||
should set_the_flash.to(/removed/i)
|
||||
should redirect_to('the course page') { course_url(@course) }
|
||||
should_create_log_entry {[ WikiDeleteLogEntry, @wiki_page.id, users(:bob).id ]}
|
||||
|
||||
should "delete the wiki page" do
|
||||
@wiki_page = WikiPage.find_with_deleted(@wiki_page.id)
|
||||
assert @wiki_page.deleted?
|
||||
end
|
||||
end
|
||||
|
||||
context "on get to :move_up" do
|
||||
setup do
|
||||
assert_equal 1, @wiki_page.position
|
||||
assert_equal 2, @another_wiki_page.position
|
||||
get :move_up, :course_id => @course.id, :id => @another_wiki_page.id
|
||||
end
|
||||
|
||||
should redirect_to('the course page') { course_url(@course) }
|
||||
|
||||
should "move the page up" do
|
||||
@wiki_page.reload
|
||||
@another_wiki_page.reload
|
||||
assert_equal 2, @wiki_page.position
|
||||
assert_equal 1, @another_wiki_page.position
|
||||
end
|
||||
end
|
||||
|
||||
context "on get to :move_down" do
|
||||
setup do
|
||||
assert_equal 1, @wiki_page.position
|
||||
assert_equal 2, @another_wiki_page.position
|
||||
get :move_down, :course_id => @course.id, :id => @wiki_page.id
|
||||
end
|
||||
|
||||
should redirect_to('the course page') { course_url(@course) }
|
||||
|
||||
should "move the page up" do
|
||||
@wiki_page.reload
|
||||
@another_wiki_page.reload
|
||||
assert_equal 2, @wiki_page.position
|
||||
assert_equal 1, @another_wiki_page.position
|
||||
end
|
||||
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
|
||||
#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 < ActionController::TestCase
|
||||
# def setup
|
||||
# @course = Course.find(:first)
|
||||
#
|
||||
# @wiki_page = @course.wiki_pages.create(:title => 'test1', :content => 'content1',
|
||||
# :user_id => users(:bob).id, :description => 'test', :version => 1)
|
||||
# @wiki_page.save!
|
||||
# @wiki_page.title = 'new title'
|
||||
# @wiki_page.save!
|
||||
#
|
||||
# @another_wiki_page = @course.wiki_pages.create(:title => 'another', :content => 'another',
|
||||
# :description => 'test', :user_id => users(:bob).id, :version => 1)
|
||||
# @another_wiki_page.move_to_bottom
|
||||
# @another_wiki_page.save!
|
||||
# @wiki_page.reload
|
||||
#
|
||||
# LogEntry.delete_all
|
||||
# end
|
||||
#
|
||||
# context "An anonymous user" do
|
||||
#
|
||||
# should_request_login_on_post_to(:new, {:course_id => 1})
|
||||
# should_request_login_on_post_to(:create, {:course_id => 1})
|
||||
# should_request_login_on_post_to(:edit, {:course_id => 1, :id => 1})
|
||||
# should_request_login_on_post_to(:update, {:course_id => 1, :id => 1})
|
||||
# should_request_login_on_post_to(:destroy, {:course_id => 1, :id => 1})
|
||||
# should_request_login_on_post_to(:move_up, {:course_id => 1, :id => 1})
|
||||
# should_request_login_on_post_to(:move_down, {:course_id => 1, :id => 1})
|
||||
#
|
||||
# #context "on get to :index" do
|
||||
# # setup { get :index, :course_id => @course.id }
|
||||
# # should redirect_to('the course page') { course_url(@course) }
|
||||
# #end
|
||||
#
|
||||
# context "on get to :show" do
|
||||
# setup { get :show, :course_id => @course.id, :id => @wiki_page.id }
|
||||
#
|
||||
# should respond_with :success
|
||||
# should render_template 'show'
|
||||
#
|
||||
# should "show the wiki page" do
|
||||
# assert_select 'h1.title', @wiki_page.title
|
||||
# end
|
||||
#
|
||||
# should "show the selected version" do
|
||||
# @wiki_page.revert_to(1)
|
||||
# get :show, :course_id => @course.id, :id => @wiki_page.id, :version => 1
|
||||
# assert_select 'h1.title', @wiki_page.title
|
||||
# end
|
||||
# end
|
||||
#
|
||||
# context "on get to :versions" do
|
||||
# setup { get :versions, :course_id => @course.id, :id => @wiki_page.id }
|
||||
#
|
||||
# should respond_with :success
|
||||
# should render_template 'versions'
|
||||
#
|
||||
# should "show the wiki page versions" do
|
||||
# @wiki_page.versions.each do |v|
|
||||
# assert_select 'a[href=?]', course_wiki_instance_url(@course, @wiki_page, :version => v.version)
|
||||
# end
|
||||
# end
|
||||
# end
|
||||
#
|
||||
# context "on get to :preview" do
|
||||
# context "with valid markup" do
|
||||
# setup { get :preview, :text => "hello {$x$} <script>foo();</script> <i onclick='foo()'>x</i>" }
|
||||
#
|
||||
# should respond_with :success
|
||||
#
|
||||
# should "display latex formulas" do
|
||||
# assert_select 'img[class=tex_inline]'
|
||||
# end
|
||||
#
|
||||
# should "strip harmful tags" do
|
||||
# assert_select 'script', false
|
||||
# assert_select '*[onclick]', false
|
||||
# end
|
||||
# end
|
||||
#
|
||||
# context "with invalid markup" do
|
||||
# setup { get :preview, :text => "<a" }
|
||||
# should respond_with :bad_request
|
||||
# end
|
||||
# end
|
||||
#
|
||||
# context "on get to :diff" do
|
||||
# setup { get :diff, :course_id => @course.id, :id => @wiki_page.id, :from => 1, :to => 2 }
|
||||
# should respond_with :success
|
||||
# should assign_to :diff
|
||||
# end
|
||||
#
|
||||
# end
|
||||
#
|
||||
# context "An authenticated user" do
|
||||
# setup { login_as :bob }
|
||||
#
|
||||
# context "on get to :new" do
|
||||
# setup { get :new, :course_id => @course.id }
|
||||
# #should render_a_form
|
||||
# should respond_with :success
|
||||
# end
|
||||
#
|
||||
# context "on post to :create" do
|
||||
# setup do
|
||||
# assert_nil @course.wiki_pages.find_by_title('test2')
|
||||
# post :create, :course_id => @course.id, :wiki_page => { :title => 'test2', :content => 'test2' }
|
||||
# @wiki_page = @course.wiki_pages.find_by_title('test2')
|
||||
# end
|
||||
#
|
||||
# should set_the_flash.to(/created/i)
|
||||
# should redirect_to('the wiki page') { course_wiki_instance_url(@course, @wiki_page) }
|
||||
# should_create_log_entry {[ WikiCreateLogEntry, @wiki_page.id, users(:bob).id ]}
|
||||
#
|
||||
# should "create a new wiki page" do
|
||||
# assert @wiki_page
|
||||
# assert_equal @wiki_page.version, 1
|
||||
# assert_equal users(:bob).id, @wiki_page.user_id
|
||||
# end
|
||||
# end
|
||||
#
|
||||
# context "on get to :edit" do
|
||||
# setup { get :edit, :course_id => @course.id, :id => @wiki_page.id }
|
||||
#
|
||||
# #should render_a_form
|
||||
# should render_template 'edit'
|
||||
#
|
||||
# should "render a form with the correct fields" do
|
||||
# assert_select "input[name='wiki_page[title]'][value=?]", @wiki_page.title
|
||||
# assert_select "input[name='wiki_page[description]'][value=?]", ""
|
||||
# assert_select 'textarea', @wiki_page.content
|
||||
# end
|
||||
#
|
||||
# should "edit the selected version" do
|
||||
# @wiki_page.revert_to(1)
|
||||
# get :edit, :course_id => @course.id, :id => @wiki_page.id, :version => 1
|
||||
# assert_select "input[name='wiki_page[title]'][value=?]", @wiki_page.title
|
||||
# assert_select 'textarea', @wiki_page.content
|
||||
# end
|
||||
# end
|
||||
#
|
||||
# context "on post to :update" do
|
||||
# context "with unmodified data" do
|
||||
# setup do
|
||||
# post :update, :course_id => @course.id, :id => @wiki_page.id, :wiki_page => {
|
||||
# :title => @wiki_page.title, :content => @wiki_page.content}
|
||||
# end
|
||||
#
|
||||
# should_not set_the_flash
|
||||
# should redirect_to('the wiki page') { course_wiki_instance_url(@course, @wiki_page) }
|
||||
#
|
||||
# should "not create a new log entry" do
|
||||
# assert_nil WikiEditLogEntry.find(:first, :conditions => { :target_id => @wiki_page.id })
|
||||
# end
|
||||
# end
|
||||
#
|
||||
# context "with new data" do
|
||||
# setup do
|
||||
# post :update, :course_id => @course.id, :id => @wiki_page.id, :wiki_page => {
|
||||
# :user_id => 999, :course_id => 999, # not user definable
|
||||
# :title => 'brand new title', :content => 'brand new content'}
|
||||
# @wiki_page.reload
|
||||
# end
|
||||
#
|
||||
# should set_the_flash.to(/updated/i)
|
||||
# should redirect_to('the wiki page') { course_wiki_instance_url(@course, @wiki_page) }
|
||||
# should_create_log_entry {[ WikiEditLogEntry, @wiki_page.id, users(:bob).id ]}
|
||||
#
|
||||
# should "update the wiki page" do
|
||||
# assert_equal "brand new title", @wiki_page.title
|
||||
# assert_equal "brand new content", @wiki_page.content
|
||||
# assert_equal users(:bob).id, @wiki_page.user_id
|
||||
# assert_equal @course.id, @wiki_page.course_id
|
||||
# end
|
||||
# end
|
||||
# end
|
||||
#
|
||||
# context "on post to :destroy" do
|
||||
# setup { post :destroy, :course_id => @course.id, :id => @wiki_page.id }
|
||||
#
|
||||
# should set_the_flash.to(/removed/i)
|
||||
# should redirect_to('the course page') { course_url(@course) }
|
||||
# should_create_log_entry {[ WikiDeleteLogEntry, @wiki_page.id, users(:bob).id ]}
|
||||
#
|
||||
# should "delete the wiki page" do
|
||||
# @wiki_page = WikiPage.find_with_deleted(@wiki_page.id)
|
||||
# assert @wiki_page.deleted?
|
||||
# end
|
||||
# end
|
||||
#
|
||||
# context "on get to :move_up" do
|
||||
# setup do
|
||||
# assert_equal 1, @wiki_page.position
|
||||
# assert_equal 2, @another_wiki_page.position
|
||||
# get :move_up, :course_id => @course.id, :id => @another_wiki_page.id
|
||||
# end
|
||||
#
|
||||
# should redirect_to('the course page') { course_url(@course) }
|
||||
#
|
||||
# should "move the page up" do
|
||||
# @wiki_page.reload
|
||||
# @another_wiki_page.reload
|
||||
# assert_equal 2, @wiki_page.position
|
||||
# assert_equal 1, @another_wiki_page.position
|
||||
# end
|
||||
# end
|
||||
#
|
||||
# context "on get to :move_down" do
|
||||
# setup do
|
||||
# assert_equal 1, @wiki_page.position
|
||||
# assert_equal 2, @another_wiki_page.position
|
||||
# get :move_down, :course_id => @course.id, :id => @wiki_page.id
|
||||
# end
|
||||
#
|
||||
# should redirect_to('the course page') { course_url(@course) }
|
||||
#
|
||||
# should "move the page up" do
|
||||
# @wiki_page.reload
|
||||
# @another_wiki_page.reload
|
||||
# assert_equal 2, @wiki_page.position
|
||||
# assert_equal 1, @another_wiki_page.position
|
||||
# end
|
||||
# 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