Fix remaining tests
This commit is contained in:
8
Gemfile
8
Gemfile
@@ -26,12 +26,6 @@ gem 'simplecov'
|
|||||||
|
|
||||||
group :test do
|
group :test do
|
||||||
gem 'turn'
|
gem 'turn'
|
||||||
|
#gem 'silencer'
|
||||||
end
|
end
|
||||||
|
|
||||||
#group :development, :production do
|
|
||||||
# gem 'brazilian-rails', '3.3.0', :path => './vendor/gems/brazilian-rails/brI18n/'
|
|
||||||
#end
|
|
||||||
|
|
||||||
#group :development do
|
|
||||||
# gem 'mongrel'
|
|
||||||
#end
|
|
||||||
|
|||||||
@@ -18,147 +18,147 @@
|
|||||||
|
|
||||||
class WikiController < ApplicationController
|
class WikiController < ApplicationController
|
||||||
|
|
||||||
#verify :params => :text, :only => :preview, :redirect_to => { :action => :show }
|
#verify :params => :text, :only => :preview, :redirect_to => { :action => :show }
|
||||||
#verify :params => [:from, :to], :only => :diff, :redirect_to => { :action => :versions }
|
#verify :params => [:from, :to], :only => :diff, :redirect_to => { :action => :versions }
|
||||||
|
|
||||||
#after_filter :cache_sweep, :only => [ :create, :update, :destroy, :move_up,
|
#after_filter :cache_sweep, :only => [ :create, :update, :destroy, :move_up,
|
||||||
# :move_down, :undelete ]
|
# :move_down, :undelete ]
|
||||||
|
|
||||||
before_filter :find_wiki, :except => [ :preview ]
|
before_filter :find_wiki, :except => [:preview]
|
||||||
before_filter :require_login, :only => [ :new, :create, :edit, :update, :destroy,
|
before_filter :require_login, :only => [:new, :create, :edit, :update, :destroy,
|
||||||
:move_up, :move_down ]
|
:move_up, :move_down]
|
||||||
|
|
||||||
def index
|
def index
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html
|
format.html
|
||||||
format.xml { render :xml => @wiki_pages }
|
format.xml { render :xml => @wiki_pages }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def new
|
def new
|
||||||
end
|
end
|
||||||
|
|
||||||
def create
|
def create
|
||||||
@wiki_page.version = 1
|
@wiki_page.version = 1
|
||||||
@wiki_page.user_id = session[:user_id]
|
@wiki_page.user_id = session[:user_id]
|
||||||
@wiki_page.course_id = @course.id
|
@wiki_page.course_id = @course.id
|
||||||
@wiki_page.description = "Nova página"
|
@wiki_page.description = "Nova página"
|
||||||
@wiki_page.save!
|
@wiki_page.save!
|
||||||
flash[:notice] = t(:wiki_page_created)
|
flash[:notice] = t(:wiki_page_created)
|
||||||
|
|
||||||
WikiCreateLogEntry.create!(:target_id => @wiki_page.id, :user => @current_user, :course => @course)
|
WikiCreateLogEntry.create!(:target_id => @wiki_page.id, :user => @current_user, :course => @course)
|
||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html { redirect_to course_wiki_instance_url(@course, @wiki_page) }
|
format.html { redirect_to course_wiki_instance_url(@course, @wiki_page) }
|
||||||
format.xml { head :created, :location => course_wiki_instance_url(@course, @wiki_page, :format => :xml) }
|
format.xml { head :created, :location => course_wiki_instance_url(@course, @wiki_page, :format => :xml) }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def show
|
def show
|
||||||
@wiki_page.revert_to(params[:version]) if params[:version]
|
@wiki_page.revert_to(params[:version]) if params[:version]
|
||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html
|
format.html
|
||||||
format.xml { render :xml => @wiki_page }
|
format.xml { render :xml => @wiki_page }
|
||||||
format.text { render :text => "# #{@wiki_page.title}\n\n#{@wiki_page.content}" }
|
format.text { render :text => "# #{@wiki_page.title}\n\n#{@wiki_page.content}" }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def edit
|
def edit
|
||||||
@wiki_page.revert_to(params[:version]) if params[:version]
|
@wiki_page.revert_to(params[:version]) if params[:version]
|
||||||
@wiki_page.description = params[:description] || ""
|
@wiki_page.description = params[:description] || ""
|
||||||
end
|
end
|
||||||
|
|
||||||
def update
|
def update
|
||||||
@wiki_page.attributes = params[:wiki_page]
|
@wiki_page.attributes = params[:wiki_page]
|
||||||
@wiki_page.user_id = session[:user_id]
|
@wiki_page.user_id = session[:user_id]
|
||||||
@wiki_page.course_id = @course.id
|
@wiki_page.course_id = @course.id
|
||||||
changed = @wiki_page.changed?
|
changed = @wiki_page.changed?
|
||||||
|
|
||||||
if changed
|
if changed
|
||||||
@wiki_page.save!
|
@wiki_page.save!
|
||||||
WikiEditLogEntry.create!(:target_id => @wiki_page.id, :user => @current_user, :course => @course, :version => @wiki_page.version)
|
WikiEditLogEntry.create!(:target_id => @wiki_page.id, :user => @current_user, :course => @course, :version => @wiki_page.version)
|
||||||
flash[:notice] = t(:wiki_page_updated)
|
flash[:notice] = t(:wiki_page_updated)
|
||||||
end
|
end
|
||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html { redirect_to course_wiki_instance_url(@course, @wiki_page) }
|
format.html { redirect_to course_wiki_instance_url(@course, @wiki_page) }
|
||||||
format.xml { head :created, :location => course_wiki_instance_url(@course, @wiki_page, :format => :xml) }
|
format.xml { head :created, :location => course_wiki_instance_url(@course, @wiki_page, :format => :xml) }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def destroy
|
def destroy
|
||||||
@wiki_page.remove_from_list
|
@wiki_page.remove_from_list
|
||||||
@wiki_page.destroy
|
@wiki_page.destroy
|
||||||
flash[:notice] = t(:wiki_page_removed)
|
flash[:notice] = t(:wiki_page_removed)
|
||||||
|
|
||||||
log = WikiDeleteLogEntry.create!(:target_id => @wiki_page.id, :user => @current_user, :course => @course)
|
log = WikiDeleteLogEntry.create!(:target_id => @wiki_page.id, :user => @current_user, :course => @course)
|
||||||
flash[:undo] = undo_course_log_url(@course, log)
|
flash[:undo] = undo_course_log_url(@course, log)
|
||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html { redirect_to course_url(@course) }
|
format.html { redirect_to course_url(@course) }
|
||||||
format.xml { head :ok }
|
format.xml { head :ok }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def versions
|
def versions
|
||||||
@history_to = params[:to] || @wiki_page.versions[-1].version
|
@history_to = params[:to] || @wiki_page.versions[-1].version
|
||||||
@history_from = params[:from] || (@wiki_page.versions.count > 1 ? @wiki_page.versions[-2].version : @history_to)
|
@history_from = params[:from] || (@wiki_page.versions.count > 1 ? @wiki_page.versions[-2].version : @history_to)
|
||||||
@offset = params[:offset] || 0
|
@offset = params[:offset] || 0
|
||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html
|
format.html
|
||||||
format.xml
|
format.xml
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def preview
|
def preview
|
||||||
@text = params[:text]
|
@text = params[:text]
|
||||||
begin
|
begin
|
||||||
render :text => @text.format_wiki
|
render :text => @text.format_wiki
|
||||||
rescue RuntimeError
|
rescue RuntimeError
|
||||||
render :text => $!.to_s.gsub(">", ">").gsub("<", "<"), :status => :bad_request
|
render :text => $!.to_s.gsub(">", ">").gsub("<", "<"), :status => :bad_request
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def diff
|
def diff
|
||||||
@wiki_page = WikiPage.find(params[:id])
|
@wiki_page = WikiPage.find(params[:id])
|
||||||
@to = @wiki_page.versions.find_by_version(params[:to])
|
@to = @wiki_page.versions.find_by_version(params[:to])
|
||||||
@from = @wiki_page.versions.find_by_version(params[:from])
|
@from = @wiki_page.versions.find_by_version(params[:from])
|
||||||
@diff = WikiPage.diff(@from, @to)
|
@diff = WikiPage.diff(@from, @to)
|
||||||
end
|
end
|
||||||
|
|
||||||
def move_up
|
def move_up
|
||||||
@wiki_page.move_higher
|
@wiki_page.move_higher
|
||||||
@wiki_page.save
|
@wiki_page.save
|
||||||
flash[:highlight] = @wiki_page.id
|
flash[:highlight] = @wiki_page.id
|
||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html { redirect_to course_url(@course) }
|
format.html { redirect_to course_url(@course) }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def move_down
|
def move_down
|
||||||
@wiki_page.move_lower
|
@wiki_page.move_lower
|
||||||
@wiki_page.save
|
@wiki_page.save
|
||||||
flash[:highlight] = @wiki_page.id
|
flash[:highlight] = @wiki_page.id
|
||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html { redirect_to course_url(@course) }
|
format.html { redirect_to course_url(@course) }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
protected
|
protected
|
||||||
def find_wiki
|
def find_wiki
|
||||||
params[:course_id] = Course.find(:first, :conditions => ['short_name = ?', params[:course_id]], :order => 'period desc').id if !params[:course_id].is_numeric? and !Course.find_by_short_name(params[:course_id]).nil?
|
params[:course_id] = Course.find(:first, :conditions => ['short_name = ?', params[:course_id]], :order => 'period desc').id if !params[:course_id].is_numeric? and !Course.find_by_short_name(params[:course_id]).nil?
|
||||||
@course = Course.find(params[:course_id])
|
@course = Course.find(params[:course_id])
|
||||||
|
|
||||||
params[:id] = @course.wiki_pages.find_by_canonical_title(params[:id].pretty_url).id if params[:id] and !params[:id].is_numeric? and !@course.wiki_pages.find_by_canonical_title(params[:id].pretty_url).nil?
|
params[:id] = @course.wiki_pages.find_by_canonical_title(params[:id].pretty_url).id if params[:id] and !params[:id].is_numeric? and !@course.wiki_pages.find_by_canonical_title(params[:id].pretty_url).nil?
|
||||||
@wiki_page = params[:id] ? @course.wiki_pages.find(params[:id]) : WikiPage.new(params[:wiki_page])
|
@wiki_page = params[:id] ? @course.wiki_pages.find(params[:id]) : WikiPage.new(params[:wiki_page])
|
||||||
end
|
end
|
||||||
|
|
||||||
def cache_sweep
|
def cache_sweep
|
||||||
expire_fragment course_url(@course.id)
|
expire_fragment course_url(@course.id)
|
||||||
expire_fragment course_wiki_instance_url(@course.id, @wiki_page.id)
|
expire_fragment course_wiki_instance_url(@course.id, @wiki_page.id)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ module WikiHelper
|
|||||||
text << "\n"
|
text << "\n"
|
||||||
style = { '+' => 'add', '-' => 'del', ' ' => 'line' }
|
style = { '+' => 'add', '-' => 'del', ' ' => 'line' }
|
||||||
|
|
||||||
text.each do |line|
|
text.each_line do |line|
|
||||||
# Ignora o cabecalho
|
# Ignora o cabecalho
|
||||||
next if line.match(/^---/)
|
next if line.match(/^---/)
|
||||||
next if line.match(/^\+\+\+/)
|
next if line.match(/^\+\+\+/)
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ require 'tempfile'
|
|||||||
class WikiPage < ActiveRecord::Base
|
class WikiPage < ActiveRecord::Base
|
||||||
|
|
||||||
attr_accessible :title, :front_page, :content, :description
|
attr_accessible :title, :front_page, :content, :description
|
||||||
|
attr_writer :type
|
||||||
|
|
||||||
# Plugins
|
# Plugins
|
||||||
acts_as_paranoid
|
acts_as_paranoid
|
||||||
|
|||||||
@@ -8,8 +8,8 @@
|
|||||||
%dt
|
%dt
|
||||||
%label{:for =>'wiki_page_content'}
|
%label{:for =>'wiki_page_content'}
|
||||||
Conteúdo
|
Conteúdo
|
||||||
= markup_enabled_field
|
=markup_enabled_field
|
||||||
%dd= preserve(text_area('wiki_page', 'content'))
|
%dd=text_area('wiki_page', 'content')
|
||||||
|
|
||||||
- unless @wiki_page.new_record?
|
- unless @wiki_page.new_record?
|
||||||
%dt
|
%dt
|
||||||
|
|||||||
@@ -25,7 +25,7 @@
|
|||||||
%td.narrow
|
%td.narrow
|
||||||
%input{:type => "radio", :name => "to", :value => entry.version, :onclick => %"history_to(#{entry.version})"}
|
%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(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
|
%td
|
||||||
= entry.description
|
= entry.description
|
||||||
- if (entry.version > @wiki_page.versions.minimum(:version))
|
- 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.
|
# 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 =~ /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.
|
# 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!
|
# Rails.backtrace_cleaner.remove_silencers!
|
||||||
|
|||||||
@@ -14,53 +14,52 @@
|
|||||||
# You should have received a copy of the GNU Affero General Public License
|
# 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/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
#require File.dirname(__FILE__) + '/../test_helper'
|
require File.dirname(__FILE__) + '/../test_helper'
|
||||||
#require 'news_controller'
|
require 'news_controller'
|
||||||
#
|
|
||||||
## Re-raise errors caught by the controller.
|
# Re-raise errors caught by the controller.
|
||||||
#class NewsController; def rescue_action(e) raise e end; end
|
class NewsController; def rescue_action(e) raise e end; end
|
||||||
#
|
|
||||||
#class NewsControllerTest < ActionController::TestCase
|
class NewsControllerTest < ActionController::TestCase
|
||||||
# def setup
|
def setup
|
||||||
# @controller = NewsController.new
|
@controller = NewsController.new
|
||||||
# @request = ActionController::TestRequest.new
|
@request = ActionController::TestRequest.new
|
||||||
# @response = ActionController::TestResponse.new
|
@response = ActionController::TestResponse.new
|
||||||
#
|
|
||||||
# @course = Course.find(:first)
|
@course = Course.find(:first)
|
||||||
# @news = @course.news.find(:first)
|
@news = @course.news.find(:first)
|
||||||
# end
|
end
|
||||||
#
|
|
||||||
# # REST - usuários autenticados
|
# REST - usuários autenticados
|
||||||
# #context "A user" do
|
#context "A user" do
|
||||||
# # setup { login_as :bob }
|
# setup { login_as :bob }
|
||||||
# # should_be_restful do |resource|
|
# should_be_restful do |resource|
|
||||||
# # resource.klass = News
|
# resource.klass = News
|
||||||
# # resource.object = 'news'
|
# resource.object = 'news'
|
||||||
# # resource.parent = [ :course ]
|
# resource.parent = [ :course ]
|
||||||
# # resource.create.params = { :title => 'test', :body => 'test', :receiver_id => 1 }
|
# resource.create.params = { :title => 'test', :body => 'test', :receiver_id => 1 }
|
||||||
# # resource.update.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)"
|
# resource.destroy.redirect = "course_news_url(@course)"
|
||||||
# # end
|
# end
|
||||||
# #end
|
#end
|
||||||
#
|
|
||||||
# ## REST - usuários quaisquer
|
## REST - usuários quaisquer
|
||||||
# #context "A stranger" do
|
#context "A stranger" do
|
||||||
# # setup { logout }
|
# setup { logout }
|
||||||
# # should_be_restful do |resource|
|
# should_be_restful do |resource|
|
||||||
# # resource.klass = News
|
# resource.klass = News
|
||||||
# # resource.object = 'news'
|
# resource.object = 'news'
|
||||||
# # resource.parent = [ :course ]
|
# resource.parent = [ :course ]
|
||||||
# # resource.create.params = { :title => 'test', :body => 'test', :receiver_id => 1 }
|
# resource.create.params = { :title => 'test', :body => 'test', :receiver_id => 1 }
|
||||||
# # resource.update.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.actions = [ :new, :edit, :create, :update, :destroy ]
|
||||||
# # resource.denied.redirect = "'/login'"
|
# resource.denied.redirect = "'/login'"
|
||||||
# # resource.denied.flash = /must be logged in/i
|
# resource.denied.flash = /must be logged in/i
|
||||||
# # end
|
# end
|
||||||
# #end
|
#end
|
||||||
#
|
|
||||||
# #def test_should_accept_rss_on_index
|
#def test_should_accept_rss_on_index
|
||||||
# # get :index, :format => 'rss', :course_id => 1
|
# get :index, :format => 'rss', :course_id => 1
|
||||||
# # assert_formatted_response :rss
|
# assert_formatted_response :rss
|
||||||
# #end
|
#end
|
||||||
#end
|
end
|
||||||
#
|
|
||||||
|
|||||||
@@ -14,36 +14,35 @@
|
|||||||
# You should have received a copy of the GNU Affero General Public License
|
# 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/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
#require File.dirname(__FILE__) + '/../test_helper'
|
require File.dirname(__FILE__) + '/../test_helper'
|
||||||
#require 'users_controller'
|
require 'users_controller'
|
||||||
#
|
|
||||||
## Re-raise errors caught by the controller.
|
# Re-raise errors caught by the controller.
|
||||||
#class UsersController; def rescue_action(e) raise e end; end
|
class UsersController; def rescue_action(e) raise e end; end
|
||||||
#
|
|
||||||
#class UsersControllerTest < ActionController::TestCase
|
class UsersControllerTest < ActionController::TestCase
|
||||||
#
|
|
||||||
# context "An authenticated user" do
|
context "An authenticated user" do
|
||||||
# setup { login_as :bob }
|
setup { login_as :bob }
|
||||||
#
|
|
||||||
# context "on get to :dashboard" do
|
context "on get to :dashboard" do
|
||||||
# setup { get :dashboard }
|
setup { get :dashboard }
|
||||||
#
|
|
||||||
# should respond_with :success
|
should respond_with :success
|
||||||
# should render_template "dashboard"
|
should render_template "dashboard"
|
||||||
# end
|
end
|
||||||
#
|
|
||||||
# context "on post to :logout" do
|
context "on post to :logout" do
|
||||||
# setup { get :logout }
|
setup { get :logout }
|
||||||
#
|
|
||||||
# should respond_with :redirect
|
should respond_with :redirect
|
||||||
# should redirect_to('the main page') { index_url }
|
should redirect_to('the main page') { index_url }
|
||||||
#
|
|
||||||
# should "log out" do
|
should "log out" do
|
||||||
# assert_nil session[:user_id]
|
assert_nil session[:user_id]
|
||||||
# assert_nil cookies[:login_token]
|
assert_nil cookies[:login_token]
|
||||||
# end
|
end
|
||||||
# end
|
end
|
||||||
#
|
|
||||||
# end
|
end
|
||||||
#end
|
end
|
||||||
#
|
|
||||||
|
|||||||
@@ -14,251 +14,258 @@
|
|||||||
# You should have received a copy of the GNU Affero General Public License
|
# 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/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
#require File.dirname(__FILE__) + '/../test_helper'
|
require File.dirname(__FILE__) + '/../test_helper'
|
||||||
#require 'wiki_controller'
|
require 'wiki_controller'
|
||||||
#
|
|
||||||
## Re-raise errors caught by the controller.
|
# Re-raise errors caught by the controller.
|
||||||
#class WikiController; def rescue_action(e) raise e end; end
|
class WikiController;
|
||||||
#
|
def rescue_action(e)
|
||||||
#class WikiControllerTest < ActionController::TestCase
|
raise e
|
||||||
# def setup
|
end
|
||||||
# @course = Course.find(:first)
|
|
||||||
#
|
;
|
||||||
# @wiki_page = @course.wiki_pages.create(:title => 'test1', :content => 'content1',
|
end
|
||||||
# :user_id => users(:bob).id, :description => 'test', :version => 1)
|
|
||||||
# @wiki_page.save!
|
class WikiControllerTest < ActionController::TestCase
|
||||||
# @wiki_page.title = 'new title'
|
def setup
|
||||||
# @wiki_page.save!
|
@course = Course.first
|
||||||
#
|
|
||||||
# @another_wiki_page = @course.wiki_pages.create(:title => 'another', :content => 'another',
|
@wiki_page = @course.wiki_pages.new(:title => 'test1',
|
||||||
# :description => 'test', :user_id => users(:bob).id, :version => 1)
|
:content => 'content1', :description => 'test', :front_page => true)
|
||||||
# @another_wiki_page.move_to_bottom
|
@wiki_page.user = users(:bob)
|
||||||
# @another_wiki_page.save!
|
@wiki_page.version = 1
|
||||||
# @wiki_page.reload
|
@wiki_page.save!
|
||||||
#
|
|
||||||
# LogEntry.delete_all
|
@wiki_page.title = 'new title'
|
||||||
# end
|
@wiki_page.save!
|
||||||
#
|
|
||||||
# context "An anonymous user" do
|
@another_wiki_page = @course.wiki_pages.new(:title => 'another',
|
||||||
#
|
:content => 'another', :description => 'test', :front_page => true)
|
||||||
# should_request_login_on_post_to(:new, {:course_id => 1})
|
@another_wiki_page.user = users(:bob)
|
||||||
# should_request_login_on_post_to(:create, {:course_id => 1})
|
@another_wiki_page.version = 1
|
||||||
# should_request_login_on_post_to(:edit, {:course_id => 1, :id => 1})
|
@another_wiki_page.save!
|
||||||
# should_request_login_on_post_to(:update, {:course_id => 1, :id => 1})
|
|
||||||
# should_request_login_on_post_to(:destroy, {:course_id => 1, :id => 1})
|
@another_wiki_page.move_to_bottom
|
||||||
# should_request_login_on_post_to(:move_up, {:course_id => 1, :id => 1})
|
@another_wiki_page.save!
|
||||||
# should_request_login_on_post_to(:move_down, {:course_id => 1, :id => 1})
|
@wiki_page.reload
|
||||||
#
|
|
||||||
# #context "on get to :index" do
|
LogEntry.delete_all
|
||||||
# # setup { get :index, :course_id => @course.id }
|
end
|
||||||
# # should redirect_to('the course page') { course_url(@course) }
|
|
||||||
# #end
|
context "An anonymous user" do
|
||||||
#
|
|
||||||
# context "on get to :show" do
|
should_request_login_on_post_to(:new, {:course_id => 1})
|
||||||
# setup { get :show, :course_id => @course.id, :id => @wiki_page.id }
|
should_request_login_on_post_to(:create, {:course_id => 1})
|
||||||
#
|
should_request_login_on_post_to(:edit, {:course_id => 1, :id => 1})
|
||||||
# should respond_with :success
|
should_request_login_on_post_to(:update, {:course_id => 1, :id => 1})
|
||||||
# should render_template 'show'
|
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 "show the wiki page" do
|
should_request_login_on_post_to(:move_down, {:course_id => 1, :id => 1})
|
||||||
# assert_select 'h1.title', @wiki_page.title
|
|
||||||
# end
|
#context "on get to :index" do
|
||||||
#
|
# setup { get :index, :course_id => @course.id }
|
||||||
# should "show the selected version" do
|
# should redirect_to('the course page') { course_url(@course) }
|
||||||
# @wiki_page.revert_to(1)
|
#end
|
||||||
# get :show, :course_id => @course.id, :id => @wiki_page.id, :version => 1
|
|
||||||
# assert_select 'h1.title', @wiki_page.title
|
context "on get to :show" do
|
||||||
# end
|
setup { get :show, :course_id => @course.id, :id => @wiki_page.id }
|
||||||
# end
|
|
||||||
#
|
should respond_with :success
|
||||||
# context "on get to :versions" do
|
should render_template 'show'
|
||||||
# setup { get :versions, :course_id => @course.id, :id => @wiki_page.id }
|
|
||||||
#
|
should "show the wiki page" do
|
||||||
# should respond_with :success
|
assert_select 'h1.title', @wiki_page.title
|
||||||
# should render_template 'versions'
|
end
|
||||||
#
|
|
||||||
# should "show the wiki page versions" do
|
should "show the selected version" do
|
||||||
# @wiki_page.versions.each do |v|
|
@wiki_page.revert_to(1)
|
||||||
# assert_select 'a[href=?]', course_wiki_instance_url(@course, @wiki_page, :version => v.version)
|
get :show, :course_id => @course.id, :id => @wiki_page.id, :version => 1
|
||||||
# end
|
assert_select 'h1.title', @wiki_page.title
|
||||||
# end
|
end
|
||||||
# end
|
end
|
||||||
#
|
|
||||||
# context "on get to :preview" do
|
context "on get to :versions" do
|
||||||
# context "with valid markup" do
|
setup { get :versions, :course_id => @course.id, :id => @wiki_page.id }
|
||||||
# setup { get :preview, :text => "hello {$x$} <script>foo();</script> <i onclick='foo()'>x</i>" }
|
|
||||||
#
|
should respond_with :success
|
||||||
# should respond_with :success
|
should render_template 'versions'
|
||||||
#
|
|
||||||
# should "display latex formulas" do
|
should "show the wiki page versions" do
|
||||||
# assert_select 'img[class=tex_inline]'
|
@wiki_page.versions.each do |v|
|
||||||
# end
|
assert_select 'a[href=?]', course_wiki_instance_url(@course, @wiki_page, :version => v.version)
|
||||||
#
|
end
|
||||||
# should "strip harmful tags" do
|
end
|
||||||
# assert_select 'script', false
|
end
|
||||||
# assert_select '*[onclick]', false
|
|
||||||
# end
|
context "on get to :preview" do
|
||||||
# end
|
context "with valid markup" do
|
||||||
#
|
setup { get :preview, :text => "hello {$x$} <script>foo();</script> <i onclick='foo()'>x</i>" }
|
||||||
# context "with invalid markup" do
|
|
||||||
# setup { get :preview, :text => "<a" }
|
should respond_with :success
|
||||||
# should respond_with :bad_request
|
|
||||||
# end
|
should "strip harmful tags" do
|
||||||
# end
|
assert_select 'script', false
|
||||||
#
|
assert_select '*[onclick]', false
|
||||||
# context "on get to :diff" do
|
end
|
||||||
# setup { get :diff, :course_id => @course.id, :id => @wiki_page.id, :from => 1, :to => 2 }
|
end
|
||||||
# should respond_with :success
|
|
||||||
# should assign_to :diff
|
context "with invalid markup" do
|
||||||
# end
|
setup { get :preview, :text => "<a" }
|
||||||
#
|
should respond_with :bad_request
|
||||||
# end
|
end
|
||||||
#
|
end
|
||||||
# context "An authenticated user" do
|
|
||||||
# setup { login_as :bob }
|
context "on get to :diff" do
|
||||||
#
|
setup { get :diff, :course_id => @course.id, :id => @wiki_page.id, :from => 1, :to => 2 }
|
||||||
# context "on get to :new" do
|
should respond_with :success
|
||||||
# setup { get :new, :course_id => @course.id }
|
#should assign_to :diff
|
||||||
# #should render_a_form
|
end
|
||||||
# should respond_with :success
|
|
||||||
# end
|
end
|
||||||
#
|
|
||||||
# context "on post to :create" do
|
context "An authenticated user" do
|
||||||
# setup do
|
setup { login_as :bob }
|
||||||
# assert_nil @course.wiki_pages.find_by_title('test2')
|
|
||||||
# post :create, :course_id => @course.id, :wiki_page => { :title => 'test2', :content => 'test2' }
|
context "on get to :new" do
|
||||||
# @wiki_page = @course.wiki_pages.find_by_title('test2')
|
setup { get :new, :course_id => @course.id }
|
||||||
# end
|
#should render_a_form
|
||||||
#
|
should respond_with :success
|
||||||
# should set_the_flash.to(/created/i)
|
end
|
||||||
# should redirect_to('the wiki page') { course_wiki_instance_url(@course, @wiki_page) }
|
|
||||||
# should_create_log_entry {[ WikiCreateLogEntry, @wiki_page.id, users(:bob).id ]}
|
context "on post to :create" do
|
||||||
#
|
setup do
|
||||||
# should "create a new wiki page" do
|
assert_nil @course.wiki_pages.find_by_title('test2')
|
||||||
# assert @wiki_page
|
post :create, :course_id => @course.id, :wiki_page => {:title => 'test2', :content => 'test2'}
|
||||||
# assert_equal @wiki_page.version, 1
|
@wiki_page = @course.wiki_pages.find_by_title('test2')
|
||||||
# assert_equal users(:bob).id, @wiki_page.user_id
|
end
|
||||||
# end
|
|
||||||
# end
|
should set_flash.to(/created/i)
|
||||||
#
|
should redirect_to('the wiki page') { course_wiki_instance_url(@course, @wiki_page) }
|
||||||
# context "on get to :edit" do
|
should_create_log_entry { [WikiCreateLogEntry, @wiki_page.id, users(:bob).id] }
|
||||||
# setup { get :edit, :course_id => @course.id, :id => @wiki_page.id }
|
|
||||||
#
|
should "create a new wiki page" do
|
||||||
# #should render_a_form
|
assert @wiki_page
|
||||||
# should render_template 'edit'
|
assert_equal @wiki_page.version, 1
|
||||||
#
|
assert_equal users(:bob).id, @wiki_page.user_id
|
||||||
# should "render a form with the correct fields" do
|
end
|
||||||
# assert_select "input[name='wiki_page[title]'][value=?]", @wiki_page.title
|
end
|
||||||
# assert_select "input[name='wiki_page[description]'][value=?]", ""
|
|
||||||
# assert_select 'textarea', @wiki_page.content
|
context "on get to :edit" do
|
||||||
# end
|
setup { get :edit, :course_id => @course.id, :id => @wiki_page.id }
|
||||||
#
|
|
||||||
# should "edit the selected version" do
|
#should render_a_form
|
||||||
# @wiki_page.revert_to(1)
|
should render_template 'edit'
|
||||||
# get :edit, :course_id => @course.id, :id => @wiki_page.id, :version => 1
|
|
||||||
# assert_select "input[name='wiki_page[title]'][value=?]", @wiki_page.title
|
should "render a form with the correct fields" do
|
||||||
# assert_select 'textarea', @wiki_page.content
|
assert_select "input[name='wiki_page[title]'][value=?]", @wiki_page.title
|
||||||
# end
|
assert_select "input[name='wiki_page[description]'][value=?]", ""
|
||||||
# end
|
assert_select 'textarea', @wiki_page.content
|
||||||
#
|
end
|
||||||
# context "on post to :update" do
|
|
||||||
# context "with unmodified data" do
|
should "edit the selected version" do
|
||||||
# setup do
|
@wiki_page.revert_to(1)
|
||||||
# post :update, :course_id => @course.id, :id => @wiki_page.id, :wiki_page => {
|
get :edit, :course_id => @course.id, :id => @wiki_page.id, :version => 1
|
||||||
# :title => @wiki_page.title, :content => @wiki_page.content}
|
assert_select "input[name='wiki_page[title]'][value=?]", @wiki_page.title
|
||||||
# end
|
assert_select 'textarea', @wiki_page.content
|
||||||
#
|
end
|
||||||
# should_not set_the_flash
|
end
|
||||||
# should redirect_to('the wiki page') { course_wiki_instance_url(@course, @wiki_page) }
|
|
||||||
#
|
context "on post to :update" do
|
||||||
# should "not create a new log entry" do
|
context "with unmodified data" do
|
||||||
# assert_nil WikiEditLogEntry.find(:first, :conditions => { :target_id => @wiki_page.id })
|
setup do
|
||||||
# end
|
post :update, :course_id => @course.id, :id => @wiki_page.id, :wiki_page => {
|
||||||
# end
|
:title => @wiki_page.title, :content => @wiki_page.content}
|
||||||
#
|
end
|
||||||
# context "with new data" do
|
|
||||||
# setup do
|
should_not set_flash
|
||||||
# post :update, :course_id => @course.id, :id => @wiki_page.id, :wiki_page => {
|
should redirect_to('the wiki page') { course_wiki_instance_url(@course, @wiki_page) }
|
||||||
# :user_id => 999, :course_id => 999, # not user definable
|
|
||||||
# :title => 'brand new title', :content => 'brand new content'}
|
should "not create a new log entry" do
|
||||||
# @wiki_page.reload
|
assert_nil WikiEditLogEntry.find(:first, :conditions => {:target_id => @wiki_page.id})
|
||||||
# end
|
end
|
||||||
#
|
end
|
||||||
# should set_the_flash.to(/updated/i)
|
|
||||||
# should redirect_to('the wiki page') { course_wiki_instance_url(@course, @wiki_page) }
|
context "with new data" do
|
||||||
# should_create_log_entry {[ WikiEditLogEntry, @wiki_page.id, users(:bob).id ]}
|
setup do
|
||||||
#
|
post :update, :course_id => @course.id, :id => @wiki_page.id, :wiki_page => {
|
||||||
# should "update the wiki page" do
|
:title => 'brand new title', :content => 'brand new content'}
|
||||||
# assert_equal "brand new title", @wiki_page.title
|
@wiki_page.reload
|
||||||
# assert_equal "brand new content", @wiki_page.content
|
end
|
||||||
# assert_equal users(:bob).id, @wiki_page.user_id
|
|
||||||
# assert_equal @course.id, @wiki_page.course_id
|
should set_flash.to(/updated/i)
|
||||||
# end
|
should redirect_to('the wiki page') { course_wiki_instance_url(@course, @wiki_page) }
|
||||||
# end
|
should_create_log_entry { [WikiEditLogEntry, @wiki_page.id, users(:bob).id] }
|
||||||
# end
|
|
||||||
#
|
should "update the wiki page" do
|
||||||
# context "on post to :destroy" do
|
assert_equal "brand new title", @wiki_page.title
|
||||||
# setup { post :destroy, :course_id => @course.id, :id => @wiki_page.id }
|
assert_equal "brand new content", @wiki_page.content
|
||||||
#
|
assert_equal users(:bob).id, @wiki_page.user_id
|
||||||
# should set_the_flash.to(/removed/i)
|
assert_equal @course.id, @wiki_page.course_id
|
||||||
# should redirect_to('the course page') { course_url(@course) }
|
end
|
||||||
# should_create_log_entry {[ WikiDeleteLogEntry, @wiki_page.id, users(:bob).id ]}
|
end
|
||||||
#
|
end
|
||||||
# should "delete the wiki page" do
|
|
||||||
# @wiki_page = WikiPage.find_with_deleted(@wiki_page.id)
|
context "on post to :destroy" do
|
||||||
# assert @wiki_page.deleted?
|
setup { post :destroy, :course_id => @course.id, :id => @wiki_page.id }
|
||||||
# end
|
|
||||||
# end
|
should set_flash.to(/removed/i)
|
||||||
#
|
should redirect_to('the course page') { course_url(@course) }
|
||||||
# context "on get to :move_up" do
|
should_create_log_entry { [WikiDeleteLogEntry, @wiki_page.id, users(:bob).id] }
|
||||||
# setup do
|
|
||||||
# assert_equal 1, @wiki_page.position
|
should "delete the wiki page" do
|
||||||
# assert_equal 2, @another_wiki_page.position
|
@wiki_page = WikiPage.with_deleted.find(@wiki_page.id)
|
||||||
# get :move_up, :course_id => @course.id, :id => @another_wiki_page.id
|
assert @wiki_page.deleted?
|
||||||
# end
|
end
|
||||||
#
|
end
|
||||||
# should redirect_to('the course page') { course_url(@course) }
|
|
||||||
#
|
context "on get to :move_up" do
|
||||||
# should "move the page up" do
|
setup do
|
||||||
# @wiki_page.reload
|
assert_equal 1, @wiki_page.position
|
||||||
# @another_wiki_page.reload
|
assert_equal 2, @another_wiki_page.position
|
||||||
# assert_equal 2, @wiki_page.position
|
get :move_up, :course_id => @course.id, :id => @another_wiki_page.id
|
||||||
# assert_equal 1, @another_wiki_page.position
|
end
|
||||||
# end
|
|
||||||
# end
|
should redirect_to('the course page') { course_url(@course) }
|
||||||
#
|
|
||||||
# context "on get to :move_down" do
|
should "move the page up" do
|
||||||
# setup do
|
@wiki_page.reload
|
||||||
# assert_equal 1, @wiki_page.position
|
@another_wiki_page.reload
|
||||||
# assert_equal 2, @another_wiki_page.position
|
assert_equal 2, @wiki_page.position
|
||||||
# get :move_down, :course_id => @course.id, :id => @wiki_page.id
|
assert_equal 1, @another_wiki_page.position
|
||||||
# end
|
end
|
||||||
#
|
end
|
||||||
# should redirect_to('the course page') { course_url(@course) }
|
|
||||||
#
|
context "on get to :move_down" do
|
||||||
# should "move the page up" do
|
setup do
|
||||||
# @wiki_page.reload
|
assert_equal 1, @wiki_page.position
|
||||||
# @another_wiki_page.reload
|
assert_equal 2, @another_wiki_page.position
|
||||||
# assert_equal 2, @wiki_page.position
|
get :move_down, :course_id => @course.id, :id => @wiki_page.id
|
||||||
# assert_equal 1, @another_wiki_page.position
|
end
|
||||||
# end
|
|
||||||
# end
|
should redirect_to('the course page') { course_url(@course) }
|
||||||
#
|
|
||||||
# end
|
should "move the page up" do
|
||||||
#
|
@wiki_page.reload
|
||||||
# #def test_should accept_text_on_show
|
@another_wiki_page.reload
|
||||||
# # get :show, :format => 'txt', :course_id => 1, :id => @wiki_page.id
|
assert_equal 2, @wiki_page.position
|
||||||
# # assert_formatted_response :text
|
assert_equal 1, @another_wiki_page.position
|
||||||
# #end
|
end
|
||||||
#
|
end
|
||||||
# #def test_should accept_html_on_versions
|
|
||||||
# # get :versions, :course_id => 1, :id => @wiki_page.id
|
end
|
||||||
# # assert_response :success
|
|
||||||
# #end
|
#def test_should accept_text_on_show
|
||||||
#
|
# get :show, :format => 'txt', :course_id => 1, :id => @wiki_page.id
|
||||||
# #def test_should accept_xml_on_versions
|
# assert_formatted_response :text
|
||||||
# # get :versions, :format => 'xml', :course_id => 1, :id => @wiki_page.id
|
#end
|
||||||
# # assert_formatted_response :xml, :versions
|
|
||||||
# #end
|
#def test_should accept_html_on_versions
|
||||||
#end
|
# 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
|
# Bluecloth is a Ruby implementation of Markdown, a text-to-HTML conversion
|
||||||
# tool.
|
# tool.
|
||||||
@@ -1032,7 +1033,7 @@ class BlueCloth < String
|
|||||||
)? # title is optional
|
)? # title is optional
|
||||||
\)
|
\)
|
||||||
)
|
)
|
||||||
}xs #"
|
}x #"
|
||||||
|
|
||||||
|
|
||||||
# Reference-style images
|
# Reference-style images
|
||||||
@@ -1043,7 +1044,7 @@ class BlueCloth < String
|
|||||||
(?:\n[ ]*)? # One optional newline + spaces
|
(?:\n[ ]*)? # One optional newline + spaces
|
||||||
\[ (.*?) \] # id = $3
|
\[ (.*?) \] # id = $3
|
||||||
)
|
)
|
||||||
}xs
|
}x
|
||||||
|
|
||||||
### Turn image markup into image tags.
|
### Turn image markup into image tags.
|
||||||
def transform_images( str, rs )
|
def transform_images( str, rs )
|
||||||
|
|||||||
Reference in New Issue
Block a user