Fix remaining tests
This commit is contained in:
8
Gemfile
8
Gemfile
@@ -26,12 +26,6 @@ gem 'simplecov'
|
||||
|
||||
group :test do
|
||||
gem 'turn'
|
||||
#gem 'silencer'
|
||||
end
|
||||
|
||||
#group :development, :production do
|
||||
# gem 'brazilian-rails', '3.3.0', :path => './vendor/gems/brazilian-rails/brI18n/'
|
||||
#end
|
||||
|
||||
#group :development do
|
||||
# gem 'mongrel'
|
||||
#end
|
||||
|
||||
@@ -24,9 +24,9 @@ class WikiController < ApplicationController
|
||||
#after_filter :cache_sweep, :only => [ :create, :update, :destroy, :move_up,
|
||||
# :move_down, :undelete ]
|
||||
|
||||
before_filter :find_wiki, :except => [ :preview ]
|
||||
before_filter :require_login, :only => [ :new, :create, :edit, :update, :destroy,
|
||||
:move_up, :move_down ]
|
||||
before_filter :find_wiki, :except => [:preview]
|
||||
before_filter :require_login, :only => [:new, :create, :edit, :update, :destroy,
|
||||
:move_up, :move_down]
|
||||
|
||||
def index
|
||||
respond_to do |format|
|
||||
|
||||
@@ -32,7 +32,7 @@ module WikiHelper
|
||||
text << "\n"
|
||||
style = { '+' => 'add', '-' => 'del', ' ' => 'line' }
|
||||
|
||||
text.each do |line|
|
||||
text.each_line do |line|
|
||||
# Ignora o cabecalho
|
||||
next if line.match(/^---/)
|
||||
next if line.match(/^\+\+\+/)
|
||||
|
||||
@@ -22,6 +22,7 @@ require 'tempfile'
|
||||
class WikiPage < ActiveRecord::Base
|
||||
|
||||
attr_accessible :title, :front_page, :content, :description
|
||||
attr_writer :type
|
||||
|
||||
# Plugins
|
||||
acts_as_paranoid
|
||||
|
||||
@@ -8,8 +8,8 @@
|
||||
%dt
|
||||
%label{:for =>'wiki_page_content'}
|
||||
Conteúdo
|
||||
= markup_enabled_field
|
||||
%dd= preserve(text_area('wiki_page', 'content'))
|
||||
=markup_enabled_field
|
||||
%dd=text_area('wiki_page', 'content')
|
||||
|
||||
- unless @wiki_page.new_record?
|
||||
%dt
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
%td.narrow
|
||||
%input{:type => "radio", :name => "to", :value => entry.version, :onclick => %"history_to(#{entry.version})"}
|
||||
%td= link_to(tz(entry.updated_at).strftime("%d/%m/%y %H:%M:%S"), course_wiki_instance_url(@course, @wiki_page, :version => entry.version))
|
||||
%td= link_to truncate(h(User.find_with_deleted(entry.user_id).display_name), :length => 20), user_path(User.find_with_deleted(entry.user_id))
|
||||
%td= link_to truncate(h(User.with_deleted.find(entry.user_id).display_name), :length => 20), user_path(User.with_deleted.find(entry.user_id))
|
||||
%td
|
||||
= entry.description
|
||||
- if (entry.version > @wiki_page.versions.minimum(:version))
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
# You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
|
||||
# Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }
|
||||
Rails.backtrace_cleaner.add_silencer { |line| line =~ /\.rvm/ }
|
||||
|
||||
# You can also remove all the silencers if you're trying to debug a problem that might stem from framework code.
|
||||
# Rails.backtrace_cleaner.remove_silencers!
|
||||
|
||||
@@ -14,53 +14,52 @@
|
||||
# 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,36 +14,35 @@
|
||||
# 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,251 +14,258 @@
|
||||
# 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.first
|
||||
|
||||
@wiki_page = @course.wiki_pages.new(:title => 'test1',
|
||||
:content => 'content1', :description => 'test', :front_page => true)
|
||||
@wiki_page.user = users(:bob)
|
||||
@wiki_page.version = 1
|
||||
@wiki_page.save!
|
||||
|
||||
@wiki_page.title = 'new title'
|
||||
@wiki_page.save!
|
||||
|
||||
@another_wiki_page = @course.wiki_pages.new(:title => 'another',
|
||||
:content => 'another', :description => 'test', :front_page => true)
|
||||
@another_wiki_page.user = users(:bob)
|
||||
@another_wiki_page.version = 1
|
||||
@another_wiki_page.save!
|
||||
|
||||
@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 "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_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_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 => {
|
||||
:title => 'brand new title', :content => 'brand new content'}
|
||||
@wiki_page.reload
|
||||
end
|
||||
|
||||
should set_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_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.with_deleted.find(@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
|
||||
|
||||
7
vendor/gems/bluecloth/lib/bluecloth.rb
vendored
7
vendor/gems/bluecloth/lib/bluecloth.rb
vendored
@@ -1,4 +1,5 @@
|
||||
#!/usr/bin/ruby
|
||||
# #!/usr/bin/ruby
|
||||
# -*- encoding : utf-8 -*-
|
||||
#
|
||||
# Bluecloth is a Ruby implementation of Markdown, a text-to-HTML conversion
|
||||
# tool.
|
||||
@@ -1032,7 +1033,7 @@ class BlueCloth < String
|
||||
)? # title is optional
|
||||
\)
|
||||
)
|
||||
}xs #"
|
||||
}x #"
|
||||
|
||||
|
||||
# Reference-style images
|
||||
@@ -1043,7 +1044,7 @@ class BlueCloth < String
|
||||
(?:\n[ ]*)? # One optional newline + spaces
|
||||
\[ (.*?) \] # id = $3
|
||||
)
|
||||
}xs
|
||||
}x
|
||||
|
||||
### Turn image markup into image tags.
|
||||
def transform_images( str, rs )
|
||||
|
||||
Reference in New Issue
Block a user