Atualizando para o Rails 2.3.2

master
Alinson S. Xavier 16 years ago
parent dcfc38eb09
commit 8e9b698944

@ -3,4 +3,5 @@ public/images/sanscons/*
public/upload/* public/upload/*
*.db *.db
*.log *.log
*.orig
config/database.yml config/database.yml

@ -21,7 +21,7 @@ class ApplicationController < ActionController::Base
include AuthenticationSystem include AuthenticationSystem
before_filter :startup before_filter :startup
around_filter :set_timezone before_filter :set_timezone
# Força o login para algumas áreas do sistema # Força o login para algumas áreas do sistema
before_filter :require_login, :only => [ :edit, :new, :create, :update, :delete, :destroy, :download ] before_filter :require_login, :only => [ :edit, :new, :create, :update, :delete, :destroy, :download ]
@ -62,10 +62,8 @@ class ApplicationController < ActionController::Base
end end
def set_timezone def set_timezone
#TzTime.zone = session[:user].tz #Time.zone = session[:user].tz
TzTime.zone = TZInfo::Timezone.get("America/Fortaleza") Time.zone = "America/Fortaleza"
yield
TzTime.reset!
end end
def startup def startup

@ -89,7 +89,7 @@ class AttachmentsController < ApplicationController
def undelete def undelete
@attachment = Attachment.find_with_deleted(params[:id]) @attachment = Attachment.find_with_deleted(params[:id])
@attachment.update_attribute(:deleted_at, nil) @attachment.recover!
flash[:notice] = 'Attachment restored'[] flash[:notice] = 'Attachment restored'[]
AttachmentRestoreLogEntry.create!(:target_id => @attachment.id, :user => @current_user, :course => @attachment.course) AttachmentRestoreLogEntry.create!(:target_id => @attachment.id, :user => @current_user, :course => @attachment.course)
redirect_to course_attachment_url(@attachment.course, @attachment) redirect_to course_attachment_url(@attachment.course, @attachment)

@ -31,7 +31,6 @@ class CoursesController < ApplicationController
@courses = Course.find(:all, :order => 'grade asc, full_name asc', :conditions => ['period = ?', @period]) @courses = Course.find(:all, :order => 'grade asc, full_name asc', :conditions => ['period = ?', @period])
end end
respond_to do |format| respond_to do |format|
format.html format.html
format.xml { render :xml => @courses } format.xml { render :xml => @courses }
@ -54,7 +53,7 @@ class CoursesController < ApplicationController
respond_to do |format| respond_to do |format|
format.html { redirect_to course_path(@course) } format.html { redirect_to course_path(@course) }
format.xml { head :created, :location => formatted_course_url(@course, :xml) } format.xml { head :created, :location => course_url(@course, :format => :xml) }
end end
end end

@ -51,7 +51,7 @@ class EventsController < ApplicationController
respond_to do |format| respond_to do |format|
format.html { redirect_to course_event_path(@course, @event) } format.html { redirect_to course_event_path(@course, @event) }
format.xml { head :created, :location => formatted_course_event_url(@course, @event, :xml) } format.xml { head :created, :location => course_event_url(@course, @event, :format => :xml) }
end end
end end
@ -61,7 +61,7 @@ class EventsController < ApplicationController
def update def update
@event.attributes = params[:event] @event.attributes = params[:event]
dirty = @event.dirty? dirty = @event.changed?
@event.save! @event.save!
flash[:notice] = 'Event updated'[] flash[:notice] = 'Event updated'[]
@ -69,7 +69,7 @@ class EventsController < ApplicationController
respond_to do |format| respond_to do |format|
format.html { redirect_to course_event_path(@course, @event) } format.html { redirect_to course_event_path(@course, @event) }
format.xml { head :created, :location => formatted_course_event_url(@course, @event, :xml) } format.xml { head :created, :location => course_event_url(@course, @event, :format => :xml) }
end end
end end
@ -100,7 +100,7 @@ class EventsController < ApplicationController
def undelete def undelete
@event = Event.find_with_deleted(params[:id]) @event = Event.find_with_deleted(params[:id])
@event.restore! @event.recover!
flash[:notice] = "Event restored"[] flash[:notice] = "Event restored"[]
EventRestoreLogEntry.create!(:target_id => @event.id, :user => @current_user, :course => @event.course, :version => @event.version) EventRestoreLogEntry.create!(:target_id => @event.id, :user => @current_user, :course => @event.course, :version => @event.version)

@ -53,8 +53,8 @@ class NewsController < ApplicationController
NewsCreateLogEntry.create!(:target_id => @news.id, :user => @current_user, :course => @course, :version => @news.version) NewsCreateLogEntry.create!(:target_id => @news.id, :user => @current_user, :course => @course, :version => @news.version)
respond_to do |format| respond_to do |format|
format.html { redirect_to course_news_path(@course, @news) } format.html { redirect_to course_news_instance_path(@course, @news) }
format.xml { head :created, :location => formatted_course_news_url(@course, @news, :xml) } format.xml { head :created, :location => course_news_instance_url(@course, @news, :format => :xml) }
end end
end end
@ -65,40 +65,40 @@ class NewsController < ApplicationController
def update def update
@news.attributes = params[:news] @news.attributes = params[:news]
@news.timestamp = Time.now.utc @news.timestamp = Time.now.utc
dirty = @news.dirty? dirty = @news.changed?
@news.save! @news.save!
flash[:notice] = 'News updated'[] flash[:notice] = 'News updated'[]
NewsEditLogEntry.create!(:target_id => @news.id, :user => @current_user, :course => @course, :version => @news.version) if dirty NewsEditLogEntry.create!(:target_id => @news.id, :user => @current_user, :course => @course, :version => @news.version) if dirty
respond_to do |format| respond_to do |format|
format.html { redirect_to course_news_path(@course, @news) } format.html { redirect_to course_news_instance_path(@course, @news) }
format.xml { head :created, :location => formatted_course_news_url(@course, @news, :xml) } format.xml { head :created, :location => course_news_instance_url(@course, @news, :format => :xml) }
end end
end end
def destroy def destroy
@news.destroy @news.destroy
flash[:notice] = 'News removed'[] flash[:notice] = 'News removed'[]
flash[:undo] = undelete_course_news_url(@course, @news) flash[:undo] = undelete_course_news_instance_url(@course, @news)
NewsDeleteLogEntry.create!(:target_id => @news.id, :user => @current_user, :course => @course, :version => @news.version) NewsDeleteLogEntry.create!(:target_id => @news.id, :user => @current_user, :course => @course, :version => @news.version)
respond_to do |format| respond_to do |format|
format.html { redirect_to course_news_index_path(@course) } format.html { redirect_to course_news_path(@course) }
format.xml { head :ok } format.xml { head :ok }
end end
end end
def undelete def undelete
@news = News.find_with_deleted(params[:id]) @news = News.find_with_deleted(params[:id])
@news.restore! @news.recover!
flash[:notice] = "News restored"[] flash[:notice] = "News restored"[]
NewsRestoreLogEntry.create!(:target_id => @news.id, :user => @current_user, :course => @news.course, :version => @news.version) NewsRestoreLogEntry.create!(:target_id => @news.id, :user => @current_user, :course => @news.course, :version => @news.version)
respond_to do |format| respond_to do |format|
format.html { redirect_to course_news_url(@news.course, @news) } format.html { redirect_to course_news_instance_url(@news.course, @news) }
end end
end end
@ -113,6 +113,6 @@ class NewsController < ApplicationController
def cache_sweep def cache_sweep
expire_fragment(course_path(@course.id, :part => :right)) expire_fragment(course_path(@course.id, :part => :right))
expire_fragment(course_news_index_path(@course.id)) expire_fragment(course_news_path(@course.id))
end end
end end

@ -49,8 +49,8 @@ class WikiController < ApplicationController
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_path(@course, @wiki_page) } format.html { redirect_to course_wiki_instance_url(@course, @wiki_page) }
format.xml { head :created, :location => formatted_course_wiki_url(@course, @wiki_page, :xml) } format.xml { head :created, :location => course_wiki_instance_url(@course, @wiki_page, :format => :xml) }
end end
end end
@ -73,7 +73,7 @@ class WikiController < ApplicationController
@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
dirty = @wiki_page.dirty? dirty = @wiki_page.changed?
@wiki_page.save! @wiki_page.save!
WikiEditLogEntry.create!(:target_id => @wiki_page.id, :user => @current_user, :course => @course, :version => @wiki_page.version) if dirty WikiEditLogEntry.create!(:target_id => @wiki_page.id, :user => @current_user, :course => @course, :version => @wiki_page.version) if dirty
@ -81,15 +81,15 @@ class WikiController < ApplicationController
flash[:notice] = "Wiki page updated"[] flash[:notice] = "Wiki page updated"[]
respond_to do |format| respond_to do |format|
format.html { redirect_to course_wiki_path(@course, @wiki_page) } format.html { redirect_to course_wiki_instance_url(@course, @wiki_page) }
format.xml { head :created, :location => formatted_course_wiki_url(@course, @wiki_page, :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.destroy @wiki_page.destroy
flash[:notice] = "Wiki page removed"[] flash[:notice] = "Wiki page removed"[]
flash[:undo] = url_for(:course_id => @course, :id => @wiki_page.id, :action => 'undelete') flash[:undo] = undelete_course_wiki_instance_url(@course, @wiki_page.id)
WikiDeleteLogEntry.create!(:target_id => @wiki_page.id, :user => @current_user, :course => @course) WikiDeleteLogEntry.create!(:target_id => @wiki_page.id, :user => @current_user, :course => @course)
@ -120,8 +120,9 @@ class WikiController < ApplicationController
end end
def diff def diff
@to = WikiPage.find_version(params[:id], params[:to]) @wiki_page = WikiPage.find(params[:id])
@from = WikiPage.find_version(params[:id], params[:from]) @to = @wiki_page.versions.find_by_version(params[:to])
@from = @wiki_page.versions.find_by_version(params[:from])
@diff = WikiPage.diff(@from, @to) @diff = WikiPage.diff(@from, @to)
end end
@ -147,13 +148,13 @@ class WikiController < ApplicationController
def undelete def undelete
@wiki_page = WikiPage.find_with_deleted(params[:id]) @wiki_page = WikiPage.find_with_deleted(params[:id])
@wiki_page.update_attribute(:deleted_at, nil) @wiki_page.recover!
flash[:notice] = "Wiki page restored"[] flash[:notice] = "Wiki page restored"[]
WikiRestoreLogEntry.create!(:target_id => @wiki_page.id, :user => @current_user, :course => @wiki_page.course) WikiRestoreLogEntry.create!(:target_id => @wiki_page.id, :user => @current_user, :course => @wiki_page.course)
respond_to do |format| respond_to do |format|
format.html { redirect_to course_wiki_url(@wiki_page.course, @wiki_page) } format.html { redirect_to course_wiki_instance_url(@wiki_page.course, @wiki_page) }
end end
end end
@ -167,7 +168,7 @@ class WikiController < ApplicationController
end end
def cache_sweep def cache_sweep
expire_fragment course_path(@course.id) expire_fragment course_url(@course.id)
expire_fragment course_wiki_path(@course.id, @wiki_page.id) expire_fragment course_wiki_instance_url(@course.id, @wiki_page.id)
end end
end end

@ -20,7 +20,9 @@ module ApplicationHelper
# Converte para o timezone local # Converte para o timezone local
def tz(time_at) def tz(time_at)
TzTime.zone.utc_to_local(time_at.utc) #FIXME
#TzTime.zone.utc_to_local(time_at.utc)
time_at
end end
FLASH_NAMES = [:notice, :warning, :message] FLASH_NAMES = [:notice, :warning, :message]
@ -59,6 +61,7 @@ module ApplicationHelper
def highlight(name) def highlight(name)
return {:class => 'highlight'} if (flash[:highlight] == name) return {:class => 'highlight'} if (flash[:highlight] == name)
return {}
end end
def spinner(name) def spinner(name)
@ -84,4 +87,8 @@ module ApplicationHelper
html_options.merge!({:class => 'icon', :alt => description, :title => description}) html_options.merge!({:class => 'icon', :alt => description, :title => description})
link_to(image_tag("action/#{action_name}.gif", :title => description), options, html_options) link_to(image_tag("action/#{action_name}.gif", :title => description), options, html_options)
end end
def format_period(period)
return "20#{period[0..1]}.#{period[2..2]}"
end
end end

@ -58,6 +58,6 @@ class Course < ActiveRecord::Base
def to_param def to_param
return self.short_name if self.period == App.current_period return self.short_name if self.period == App.current_period
return self.id return self.id.to_s
end end
end end

@ -19,7 +19,7 @@ class Event < ActiveRecord::Base
# Plugins # Plugins
acts_as_paranoid acts_as_paranoid
acts_as_versioned :if_changed => [ :title, :description, :time ] acts_as_versioned :if_changed => [ :title, :description, :time ]
self.non_versioned_fields << 'deleted_at' self.non_versioned_columns << 'deleted_at'
# Associacoes # Associacoes
belongs_to :course belongs_to :course

@ -19,7 +19,7 @@ class Message < ActiveRecord::Base
# Plugins # Plugins
acts_as_paranoid acts_as_paranoid
acts_as_versioned :if_changed => [ :title, :body ] acts_as_versioned :if_changed => [ :title, :body ]
self.non_versioned_fields << 'deleted_at' self.non_versioned_columns << 'deleted_at'
# Associacoes # Associacoes
belongs_to :user, belongs_to :user,

@ -80,7 +80,7 @@ class User < ActiveRecord::Base
end end
def to_param def to_param
self.login.match(/^[-_a-z0-9]*$/i).nil? ? self.id : self.login self.login.match(/^[-_a-z0-9]*$/i).nil? ? self.id.to_s : self.login
end end
protected protected

@ -23,7 +23,8 @@ class WikiPage < ActiveRecord::Base
acts_as_paranoid acts_as_paranoid
acts_as_list :scope => 'course_id = #{course_id}' acts_as_list :scope => 'course_id = #{course_id}'
acts_as_versioned :if_changed => [ :content, :description, :title ] acts_as_versioned :if_changed => [ :content, :description, :title ]
self.non_versioned_fields << 'position' self.non_versioned_columns << 'position'
self.non_versioned_columns << 'deleted_at'
# Associacoes # Associacoes
belongs_to :course belongs_to :course
@ -34,7 +35,6 @@ class WikiPage < ActiveRecord::Base
validates_uniqueness_of :title, :scope => :course_id validates_uniqueness_of :title, :scope => :course_id
validates_format_of :title, :with => /^[^0-9]/ validates_format_of :title, :with => /^[^0-9]/
def validate def validate
begin begin
to_html to_html
@ -48,7 +48,7 @@ class WikiPage < ActiveRecord::Base
end end
def to_param def to_param
self.title.match(/^[-_a-z0-9]*$/i).nil? ? self.id : self.title self.title.match(/^[-_a-z0-9]*$/i).nil? ? self.id.to_id : self.title
end end
def WikiPage.diff(from, to) def WikiPage.diff(from, to)

@ -1,3 +1,3 @@
-# cache(course_path(@course.id, :part => :right)) do -# cache(course_path(@course.id, :part => :right)) do
= render 'widgets/calendario' = render :file => 'widgets/calendario'
= render 'widgets/news' = render :file => 'widgets/news'

@ -1,6 +1,6 @@
%h4.title= App.title %h4.title= App.title
%h1.title Adicionar disciplina %h1.title Adicionar disciplina
- form_tag course_url(@course.id), :method => :post do - form_tag courses_url, :method => :post do
= render :partial => 'form' = render :partial => 'form'
= submit_tag "Cadastrar" = submit_tag "Cadastrar"

@ -12,18 +12,18 @@
.box .box
.cmd .cmd
= action_icon 'add', 'Adicionar página wiki', new_course_wiki_url(@course) = action_icon 'add', 'Adicionar página wiki', new_course_wiki_instance_url(@course)
%h3 Páginas Wiki %h3 Páginas Wiki
%ul.wiki %ul.wiki
- @course.wiki_pages.each do |wiki| - @course.wiki_pages.each do |wiki|
%li{highlight(wiki.id)} %li{highlight(wiki.id)}
.cmd{:style => 'margin-bottom: -27px; margin-top: -9px;'} .cmd{:style => 'margin-bottom: -27px; margin-top: -9px;'}
=action_icon 'arrow2_n', 'Mover para cima', move_up_course_wiki_url(@course, wiki) unless wiki.first? =action_icon 'arrow2_n', 'Mover para cima', move_up_course_wiki_instance_url(@course, wiki) unless wiki.first?
=action_icon 'arrow2_s', 'Mover para baixo', move_down_course_wiki_url(@course, wiki) unless wiki.last? =action_icon 'arrow2_s', 'Mover para baixo', move_down_course_wiki_instance_url(@course, wiki) unless wiki.last?
- if wiki.last? - if wiki.last?
%span{:style => 'margin-right: 14px'} &nbsp; %span{:style => 'margin-right: 14px'} &nbsp;
=link_to h(wiki.title), course_wiki_url(@course, wiki) =link_to h(wiki.title), course_wiki_instance_url(@course, wiki)
- if @course.wiki_pages.empty? - if @course.wiki_pages.empty?
%li.no_itens Nenhuma página wiki %li.no_itens Nenhuma página wiki

@ -2,6 +2,6 @@
%h1.title Adicionar evento %h1.title Adicionar evento
%p %p
- form_tag course_event_url(@course, @event), :method => :post do - form_tag course_events_url(@course), :method => :post do
= render :partial => 'form' = render :partial => 'form'
= submit_tag "Adicionar" = submit_tag "Adicionar"

@ -1,2 +1,2 @@
- @events = @course.events - @events = @course.events
= render 'events/index' = render :file => 'events/index'

@ -8,8 +8,8 @@
= "&rsaquo;" + link_to(truncate(h(@attachment.file_name)), course_attachment_url) = "&rsaquo;" + link_to(truncate(h(@attachment.file_name)), course_attachment_url)
- @title = @title + " - #{truncate(h(@attachment.file_name))}" - @title = @title + " - #{truncate(h(@attachment.file_name))}"
- @left_panel = render 'courses/_left_panel' - @left_panel = render 'courses/left_panel'
- @right_panel = render 'courses/_right_panel' - @right_panel = render 'courses/right_panel'
- @content = yield - @content = yield
= render 'layouts/base' = render 'layouts/base'

@ -9,11 +9,10 @@
- @title = @title + " - Disciplinas" - @title = @title + " - Disciplinas"
- if @course and @course.id - if @course and @course.id
- @left_panel = render 'courses/_left_panel' - @left_panel = render 'courses/left_panel'
- @right_panel = render 'courses/_right_panel' - @right_panel = render 'courses/right_panel'
- else - else
- @left_panel = render('widgets/menu_navigation') + render('widgets/menu_user') - @left_panel = render('widgets/menu_navigation') + render('widgets/menu_user')
- end
- @content = yield - @content = yield

@ -5,8 +5,8 @@
= link_to(h(@course.full_name), course_url(@course)) + "&rsaquo;" = link_to(h(@course.full_name), course_url(@course)) + "&rsaquo;"
= link_to("Calendário", course_events_url) = link_to("Calendário", course_events_url)
- @left_panel = render 'courses/_left_panel' - @left_panel = render 'courses/left_panel'
- @right_panel = render 'courses/_right_panel' - @right_panel = render 'courses/right_panel'
- @content = yield - @content = yield
= render 'layouts/base' = render 'layouts/base'

@ -6,7 +6,7 @@
= link_to(h(@course.full_name), course_url(@course)) + "&rsaquo;" = link_to(h(@course.full_name), course_url(@course)) + "&rsaquo;"
= link_to("Log", course_log_url(@course)) = link_to("Log", course_log_url(@course))
- @left_panel = render 'courses/_left_panel' - @left_panel = render 'courses/left_panel'
- @content = yield - @content = yield
- else - else

@ -3,9 +3,9 @@
= link_to(App.title, index_url) + "&rsaquo;" = link_to(App.title, index_url) + "&rsaquo;"
= link_to("Disciplinas", courses_url) + "&rsaquo;" = link_to("Disciplinas", courses_url) + "&rsaquo;"
= link_to(h(@course.full_name), course_url(@course)) + "&rsaquo;" = link_to(h(@course.full_name), course_url(@course)) + "&rsaquo;"
= link_to("Noticias", course_news_index_url(@course)) = link_to("Noticias", course_news_url(@course))
- @left_panel = render 'courses/_left_panel' - @left_panel = render 'courses/left_panel'
- @content = yield - @content = yield
= render 'layouts/base' = render 'layouts/base'

@ -5,10 +5,10 @@
= link_to(h(@course.full_name), course_url(@course)) + "&rsaquo;" = link_to(h(@course.full_name), course_url(@course)) + "&rsaquo;"
= link_to("Wiki", course_url(@course)) = link_to("Wiki", course_url(@course))
- if @wiki_page.title - if @wiki_page.title
= "&rsaquo;" + link_to(h(@wiki_page.title), course_wiki_url(@course, @wiki_page)) = "&rsaquo;" + link_to(h(@wiki_page.title), course_wiki_instance_url(@course, @wiki_page))
- @title = @title + " - #{h(@wiki_page.title)}" - @title = @title + " - #{h(@wiki_page.title)}"
- @left_panel = render 'courses/_left_panel' - @left_panel = render 'courses/left_panel'
- @content = yield - @content = yield
= render 'layouts/base' = render 'layouts/base'

@ -1,4 +1,4 @@
= "Notícia " + link_to(h(entry.news.title), course_news_url(entry.course, entry.news, :version => entry.version)) = "Notícia " + link_to(h(entry.news.title), course_news_instance_url(entry.course, entry.news, :version => entry.version))
= "criada " if entry.kind_of?(NewsCreateLogEntry) = "criada " if entry.kind_of?(NewsCreateLogEntry)
= "editada " if entry.kind_of?(NewsEditLogEntry) = "editada " if entry.kind_of?(NewsEditLogEntry)

@ -1,24 +1,24 @@
- if entry.version - if entry.version
= "Página " + link_to(h(entry.wiki_page.title), course_wiki_url(entry.course, entry.wiki_page.id, :version => entry.version)) = "Página " + link_to(h(entry.wiki_page.title), course_wiki_instance_url(entry.course, entry.wiki_page.id, :version => entry.version))
- else - else
= "Página " + link_to(h(entry.wiki_page.title), course_wiki_url(entry.course, entry.wiki_page.id)) = "Página " + link_to(h(entry.wiki_page.title), course_wiki_instance_url(entry.course, entry.wiki_page.id))
= "criada " if entry.kind_of?(WikiCreateLogEntry) = "criada " if entry.kind_of?(WikiCreateLogEntry)
= "editada " if entry.kind_of?(WikiEditLogEntry) = "editada " if entry.kind_of?(WikiEditLogEntry)
= "excluída " if entry.kind_of?(WikiDeleteLogEntry) = "excluída " if entry.kind_of?(WikiDeleteLogEntry)
= "restaurada " if entry.kind_of?(WikiRestoreLogEntry) = "restaurada " if entry.kind_of?(WikiRestoreLogEntry)
- current_version = WikiPage.find_version(entry.wiki_page.id, entry.version) - current_version = entry.wiki_page.versions.find_by_version(entry.version)
- previous_version = entry.wiki_page.previous_version(entry.version) - previous_version = current_version.previous
- if entry.kind_of?(WikiEditLogEntry) - if entry.kind_of?(WikiEditLogEntry)
- if current_version.description and !current_version.description.empty? - if current_version.description and !current_version.description.empty?
= "(<i>#{h(current_version.description)}</i>)" = "(<i>#{h(current_version.description)}</i>)"
- unless previous_version.nil? - unless previous_version.nil?
= "(" + link_to("diff", diff_course_wiki_url(entry.course, entry.wiki_page.id, :from => previous_version.version, :to => entry.version)) + ")" = "(" + link_to("diff", diff_course_wiki_instance_url(entry.course, entry.wiki_page.id, :from => previous_version.version, :to => entry.version)) + ")"
= "(" + link_to("edit", edit_course_wiki_url(entry.course, entry.wiki_page.id, :description => "Revertendo para versão #{entry.version}", :version => entry.version)) + ")" = "(" + link_to("edit", edit_course_wiki_instance_url(entry.course, entry.wiki_page.id, :description => "Revertendo para versão #{entry.version}", :version => entry.version)) + ")"
- unless previous_version.nil? - unless previous_version.nil?
= "(" + link_to("undo", edit_course_wiki_url(entry.course, entry.wiki_page.id, :description => "Revertendo para versão #{previous_version.version}", :version => previous_version.version)) + ")" = "(" + link_to("undo", edit_course_wiki_instance_url(entry.course, entry.wiki_page.id, :description => "Revertendo para versão #{previous_version.version}", :version => previous_version.version)) + ")"

@ -1,8 +1,8 @@
%h4.title= @course ? h(@course.full_name) : App.title %h4.title= @course ? h(@course.full_name) : App.title
%h1.title Mudanças recentes %h1.title Mudanças recentes
- if @course -# if @course
= auto_discovery_link_tag :rss, formatted_course_log_url(@course, :rss) =# auto_discovery_link_tag :rss, course_log_url(@course.id, :format => :rss)
.box .box
%table %table
@ -15,7 +15,7 @@
- @log_entries.each do |entry| - @log_entries.each do |entry|
%tr %tr
%td= tz(entry.created_at).strftime("%d/%m/%y&nbsp;%H:%M:%S") %td= tz(entry.created_at).strftime("%d/%m/%y&nbsp;%H:%M:%S")
%td= link_to truncate(h(entry.user.display_name), 20), user_path(entry.user) %td= link_to truncate(h(entry.user.display_name), :length => 20), user_url(entry.user.id)
- unless @course - unless @course
%td= link_to h(entry.course.short_name), course_url(entry.course) %td= link_to h(entry.course.short_name), course_url(entry.course)
%td= render(:partial => 'log/log_entry', :locals => { :entry => entry }) %td= render(:partial => 'log/log_entry', :locals => { :entry => entry })

@ -2,6 +2,6 @@
%h1.title Editar noticia %h1.title Editar noticia
%p %p
- form_tag course_news_url(@course, @news), :method => :put do - form_tag course_news_instance_url(@course, @news), :method => :put do
= render :partial => 'form' = render :partial => 'form'
= submit_tag 'Editar' = submit_tag 'Editar'

@ -1,14 +1,14 @@
= javascript_include_tag 'news' = javascript_include_tag 'news'
-# cache(course_news_index_path(@course.id)) do -# cache(course_news_path(@course.id)) do
.cmd .cmd
= action_icon 'add', 'Adicionar', new_course_news_url = action_icon 'add', 'Adicionar', new_course_news_instance_url
%h4.title= h(@course.full_name) %h4.title= h(@course.full_name)
%h1.title Notícias %h1.title Notícias
= auto_discovery_link_tag :rss, formatted_course_news_index_url(@course, :rss) = auto_discovery_link_tag :rss, course_news_url(@course, :format => :rss)
.box.div_news .box.div_news
- if !@course.news.empty? - if !@course.news.empty?
@ -21,11 +21,11 @@
%td.top.aright{:width => '1%'} %td.top.aright{:width => '1%'}
= n.timestamp.strftime("%d&nbsp;de&nbsp;%B") = n.timestamp.strftime("%d&nbsp;de&nbsp;%B")
%td %td
.title= link_to h(n.title), course_news_url(@course, n) .title= link_to h(n.title), course_news_instance_url(@course, n)
.description{:style => (n.id == params[:id].to_i ? '' : 'display: none')} .description{:style => (n.id == params[:id].to_i ? '' : 'display: none')}
.cmd .cmd
= action_icon 'edit', 'Editar', edit_course_news_url(@course, n, :version => n.version) = action_icon 'edit', 'Editar', edit_course_news_instance_url(@course, n, :version => n.version)
= action_icon 'trash', 'Excluir', course_news_url(@course, n), :confirm => 'Tem certeza que deseja excluir?', :method => :delete = action_icon 'trash', 'Excluir', course_news_instance_url(@course, n), :confirm => 'Tem certeza que deseja excluir?', :method => :delete
= formatted(n.body) = formatted(n.body)
= "Sem descrição" if n.body.empty? = "Sem descrição" if n.body.empty?
- else - else

@ -2,7 +2,7 @@ xml.instruct! :xml, :version=>"1.0"
xml.rss(:version=>"2.0") do xml.rss(:version=>"2.0") do
xml.channel do xml.channel do
xml.title("#{App.title} - #{@course.full_name} - " + "News"[].titleize) xml.title("#{App.title} - #{@course.full_name} - " + "News"[].titleize)
xml.link(course_news_index_url(@course)) xml.link(course_news_url(@course))
xml.language(App.language) xml.language(App.language)
xml.description("{course} news"[:news_about, @course.full_name]) xml.description("{course} news"[:news_about, @course.full_name])
for news_item in @news for news_item in @news
@ -10,8 +10,8 @@ xml.rss(:version=>"2.0") do
xml.title(news_item.title) xml.title(news_item.title)
xml.description(formatted(news_item.body)) xml.description(formatted(news_item.body))
xml.pubDate(news_item.timestamp.rfc2822) xml.pubDate(news_item.timestamp.rfc2822)
xml.link(course_news_url(@course, news_item)) xml.link(course_news_instance_url(@course, news_item))
xml.guid(course_news_url(@course, news_item)) xml.guid(course_news_instance_url(@course, news_item))
end end
end end
end end

@ -1,6 +1,6 @@
%h4.title= @course.full_name %h4.title= @course.full_name
%h1.title Adicionar notícia %h1.title Adicionar notícia
- form_tag course_news_url(@course, @news), :method => :post do - form_tag course_news_url, :method => :post do
= render :partial => 'form' = render :partial => 'form'
= submit_tag "Enviar" = submit_tag "Enviar"

@ -1 +1 @@
= render 'news/index' = render :file => 'news/index'

@ -13,7 +13,7 @@
<% @news_messages.each do |n| %> <% @news_messages.each do |n| %>
<div class="line"> <div class="line">
<h4 class="left"><%= n.timestamp.strftime("%d de %B") %></h4> <h4 class="left"><%= n.timestamp.strftime("%d de %B") %></h4>
<h4><%= link_to h(n.course.full_name) , course_news_url(n.course, n) %> &rsaquo; <h4><%= link_to h(n.course.full_name) , course_news_instance_url(n.course, n) %> &rsaquo;
<a href="#" id="new_<%=n.id%>"><%= h(n.title) %></a></h4> <a href="#" id="new_<%=n.id%>"><%= h(n.title) %></a></h4>
<p id="new_desc_<%= n.id %>" style="display:none"> <p id="new_desc_<%= n.id %>" style="display:none">

@ -1,12 +1,12 @@
%h4.title Dashboard %h4.title Dashboard
%h1.title= "Bem vindo, #{h(@current_user.display_name)}" %h1.title= "Bem vindo, #{h(@current_user.display_name)}"
= auto_discovery_link_tag :rss, formatted_dashboard_url(:secret => @current_user.secret, :format => 'rss') = auto_discovery_link_tag :rss, dashboard_url(:secret => @current_user.secret, :format => 'rss')
.dashboard .dashboard
.box .box
.cmd .cmd
=link_to "rss", formatted_dashboard_url(:secret => @current_user.secret, :format => 'rss') =link_to "rss", dashboard_url(:secret => @current_user.secret, :format => 'rss')
- last_time = nil - last_time = nil
%h3 Notícias Recentes %h3 Notícias Recentes
@ -20,13 +20,13 @@
= n.timestamp.strftime("%d&nbsp;de&nbsp;%B") = n.timestamp.strftime("%d&nbsp;de&nbsp;%B")
%td %td
= link_to(h(n.course.full_name), course_url(n.course)) + " &rsaquo;" = link_to(h(n.course.full_name), course_url(n.course)) + " &rsaquo;"
= link_to(h(n.title), course_news_url(n.course, n)) = link_to(h(n.title), course_news_instance_url(n.course, n))
- unless n.body.empty? - unless n.body.empty?
%p= truncate(h(n.body), 300) %p= truncate(h(n.body), :length => 300)
.box .box
.cmd .cmd
=link_to "ical", formatted_dashboard_url(:secret => @current_user.secret, :format => 'ics') =link_to "ical", dashboard_url(:secret => @current_user.secret, :format => 'ics')
- last_time = nil - last_time = nil
%h3 Próximos Eventos %h3 Próximos Eventos

@ -10,8 +10,8 @@ xml.rss(:version=>"2.0") do
xml.title(news_item.course.short_name + ": " + news_item.title) xml.title(news_item.course.short_name + ": " + news_item.title)
xml.description(formatted(news_item.body)) xml.description(formatted(news_item.body))
xml.pubDate(news_item.timestamp.rfc2822) xml.pubDate(news_item.timestamp.rfc2822)
xml.link(course_news_url(news_item.course, news_item)) xml.link(course_news_instance_url(news_item.course, news_item))
xml.guid(course_news_url(news_item.course, news_item)) xml.guid(course_news_instance_url(news_item.course, news_item))
end end
end end
end end

@ -3,7 +3,7 @@
<h1>Disciplina</h1> <h1>Disciplina</h1>
<ul> <ul>
<li><%= link_to "Visão Geral", course_url(@course) %></li> <li><%= link_to "Visão Geral", course_url(@course) %></li>
<li><%= link_to "Noticias", course_news_index_url(@course) %></li> <li><%= link_to "Noticias", course_news_url(@course) %></li>
<li><%= link_to "Calendário", course_events_url(@course) %></li> <li><%= link_to "Calendário", course_events_url(@course) %></li>
<li><%= link_to "Mudanças recentes", course_log_url(@course) %></li> <li><%= link_to "Mudanças recentes", course_log_url(@course) %></li>
</ul> </ul>

@ -1,19 +1,19 @@
<!-- Mural --> <!-- Mural -->
<div class="menu"> <div class="menu">
<div class="cmd"> <div class="cmd">
<%= action_icon 'add', 'Adicionar notícia', new_course_news_url(@course) %> <%= action_icon 'add', 'Adicionar notícia', new_course_news_instance_url(@course) %>
</div> </div>
<h1>Noticias</h1> <h1>Noticias</h1>
<ul class="widget_news"> <ul class="widget_news">
<% @course.news[0..3].each do |msg| %> <% @course.news[0..3].each do |msg| %>
<li> <li>
<h4><%= tz(msg.timestamp).strftime("%d/%m") %></h4> <h4><%= tz(msg.timestamp).strftime("%d/%m") %></h4>
<%= link_to msg.title, course_news_url(@course, msg) %>. <%= link_to msg.title, course_news_instance_url(@course, msg) %>.
<%= truncate(msg.body, 80) %> <%= truncate(msg.body, :length => 80) %>
</li> </li>
<% end %> <% end %>
<% if @course.news.size > 4 %> <% if @course.news.size > 4 %>
<li><%= link_to("Ver todas as notícias", course_news_index_url(@course)) %></li> <li><%= link_to("Ver todas as notícias", course_news_url(@course)) %></li>
<% end %> <% end %>
<% if @course.news.empty? %> <% if @course.news.empty? %>
<li class="no_itens">Nenhuma notícia</li> <li class="no_itens">Nenhuma notícia</li>

@ -1,5 +1,5 @@
= action_icon('undo', "Reverter", edit_course_wiki_url(@course, @wiki_page, :description => "Revertendo para versão #{page.version}", :version => page.version)) + "&nbsp;" = action_icon('undo', "Reverter", edit_course_wiki_instance_url(@course, @wiki_page, :description => "Revertendo para versão #{page.version}", :version => page.version)) + "&nbsp;"
= link_to tz(page.updated_at).strftime("%d/%m/%y&nbsp;%H:%M:%S"), course_wiki_url(@course, @wiki_page, :version => page.version) = link_to tz(page.updated_at).strftime("%d/%m/%y&nbsp;%H:%M:%S"), course_wiki_instance_url(@course, @wiki_page, :version => page.version)
= "por #{link_to h(page.user.display_name), user_path(page.user)}" if page.respond_to?(:user) and !page.user.nil? = "por #{link_to h(page.user.display_name), user_path(page.user)}" if page.respond_to?(:user) and !page.user.nil?
- if page.description and !page.description.empty? - if page.description and !page.description.empty?

@ -7,5 +7,5 @@
%li= render :partial => 'wiki/history', :locals => { :page => @to } %li= render :partial => 'wiki/history', :locals => { :page => @to }
%li= render :partial => 'wiki/history', :locals => { :page => @from } %li= render :partial => 'wiki/history', :locals => { :page => @from }
= link_to "Comparar outras versões", versions_course_wiki_url(@course, @wiki_page, :from => @from.version, :to => @to.version) = link_to "Comparar outras versões", versions_course_wiki_instance_url(@course, @wiki_page, :from => @from.version, :to => @to.version)
= format_diff h(@diff) = format_diff h(@diff)

@ -4,7 +4,7 @@
%h1.title= "Editar #{h(@wiki_page.title)}" %h1.title= "Editar #{h(@wiki_page.title)}"
%p %p
- form_tag course_wiki_url(@course, @wiki_page.id), :method => :put do - form_tag course_wiki_instance_url(@course, @wiki_page.id), :method => :put do
= render :partial => 'form' = render :partial => 'form'
= submit_tag 'Salvar' = submit_tag 'Salvar'
%button#show_preview{:type => "button"} %button#show_preview{:type => "button"}

@ -4,7 +4,7 @@
%h1.title Adicionar página wiki %h1.title Adicionar página wiki
%p %p
- form_tag course_wiki_url(@course, @wiki_page.id) do - form_tag course_wiki_url(@course) do
= render :partial => 'form' = render :partial => 'form'
= submit_tag "Criar" = submit_tag "Criar"
%button#show_preview{:type => "button"} %button#show_preview{:type => "button"}

@ -3,9 +3,9 @@
= javascript_include_tag 'wiki' = javascript_include_tag 'wiki'
.cmd .cmd
= action_icon 'edit', 'Editar', edit_course_wiki_url = action_icon 'edit', 'Editar', edit_course_wiki_instance_url
= action_icon 'undo', 'Historico', versions_course_wiki_url = action_icon 'undo', 'Historico', versions_course_wiki_instance_url
= action_icon 'trash', 'Excluir página wiki', course_wiki_url, :confirm => 'Tem certeza que deseja excluir?', :method => :delete = action_icon 'trash', 'Excluir página wiki', course_wiki_instance_url, :confirm => 'Tem certeza que deseja excluir?', :method => :delete
%h4.title= h(@course.full_name) %h4.title= h(@course.full_name)
%h1.title= h(@wiki_page.title) %h1.title= h(@wiki_page.title)

@ -8,7 +8,7 @@
== radios_to = #{h(@history_to)}; == radios_to = #{h(@history_to)};
== radios_from = #{h(@history_from)}; == radios_from = #{h(@history_from)};
- form_tag diff_course_wiki_url(@course, @wiki_page), :method => :get do - form_tag diff_course_wiki_instance_url(@course, @wiki_page), :method => :get do
%button{:type => "submit"}= "Comparar as versões selecionadas" %button{:type => "submit"}= "Comparar as versões selecionadas"
.box .box
%table %table
@ -24,12 +24,12 @@
%input{:type => "radio", :name => "from", :value => entry.version, :onclick => "history_from(#{entry.version})"} %input{:type => "radio", :name => "from", :value => entry.version, :onclick => "history_from(#{entry.version})"}
%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&nbsp;%H:%M:%S"), course_wiki_url(@course, @wiki_page, :version => entry.version)) %td= link_to(tz(entry.updated_at).strftime("%d/%m/%y&nbsp;%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), 20), user_path(User.find_with_deleted(entry.user_id)) %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 %td
= entry.description = entry.description
- if (entry.version > @wiki_page.versions.minimum(:version)) - if (entry.version > @wiki_page.versions.minimum(:version))
= "(" + link_to("diff", diff_course_wiki_url(@course, @wiki_page, :from => entry.version - 1, :to => entry.version)) + ")" = "(" + link_to("diff", diff_course_wiki_instance_url(@course, @wiki_page, :from => entry.version - 1, :to => entry.version)) + ")"
= "(" + link_to("edit", edit_course_wiki_url(@course, @wiki_page, :description => "Revertendo para versão #{entry.version}", :version => entry.version)) + ")" = "(" + link_to("edit", edit_course_wiki_instance_url(@course, @wiki_page, :description => "Revertendo para versão #{entry.version}", :version => entry.version)) + ")"
/= will_paginate @versions /= will_paginate @versions

@ -6,7 +6,7 @@ App.webmaster_email = "webmaster@wikiufc.gelsol.org"
App.default_host = "wikiufc.gelsol.org" App.default_host = "wikiufc.gelsol.org"
App.base_path = "" App.base_path = ""
App.current_period = "2008.1" App.current_period = "2008.2"
# Limites # Limites
App.max_upload_file_size = 5.megabytes App.max_upload_file_size = 5.megabytes

@ -43,6 +43,7 @@ module Rails
class VendorBoot < Boot class VendorBoot < Boot
def load_initializer def load_initializer
require "#{RAILS_ROOT}/vendor/rails/railties/lib/initializer" require "#{RAILS_ROOT}/vendor/rails/railties/lib/initializer"
Rails::Initializer.run(:install_gem_spec_stubs)
end end
end end
@ -66,7 +67,7 @@ module Rails
class << self class << self
def rubygems_version def rubygems_version
Gem::RubyGemsVersion if defined? Gem::RubyGemsVersion Gem::RubyGemsVersion rescue nil
end end
def gem_version def gem_version
@ -81,14 +82,14 @@ module Rails
def load_rubygems def load_rubygems
require 'rubygems' require 'rubygems'
min_version = '1.3.1'
unless rubygems_version >= '0.9.4' unless rubygems_version >= min_version
$stderr.puts %(Rails requires RubyGems >= 0.9.4 (you have #{rubygems_version}). Please `gem update --system` and try again.) $stderr.puts %Q(Rails requires RubyGems >= #{min_version} (you have #{rubygems_version}). Please `gem update --system` and try again.)
exit 1 exit 1
end end
rescue LoadError rescue LoadError
$stderr.puts %(Rails requires RubyGems >= 0.9.4. Please install RubyGems and try again: http://rubygems.rubyforge.org) $stderr.puts %Q(Rails requires RubyGems >= #{min_version}. Please install RubyGems and try again: http://rubygems.rubyforge.org)
exit 1 exit 1
end end

@ -5,7 +5,7 @@
# ENV['RAILS_ENV'] ||= 'production' # ENV['RAILS_ENV'] ||= 'production'
# Specifies gem version of Rails to use when vendor/rails is not present # Specifies gem version of Rails to use when vendor/rails is not present
RAILS_GEM_VERSION = '2.0.2' unless defined? RAILS_GEM_VERSION RAILS_GEM_VERSION = '2.3.2' unless defined? RAILS_GEM_VERSION
# Bootstrap the Rails environment, frameworks, and default configuration # Bootstrap the Rails environment, frameworks, and default configuration
require File.join(File.dirname(__FILE__), 'boot') require File.join(File.dirname(__FILE__), 'boot')
@ -56,4 +56,12 @@ Rails::Initializer.run do |config|
# Make Active Record use UTC-base instead of local time # Make Active Record use UTC-base instead of local time
config.active_record.default_timezone = :utc config.active_record.default_timezone = :utc
config.gem "dr_nic_magic_models"
config.gem "bluecloth"
config.gem "acts_as_versioned"
config.gem "haml"
config.gem "hpricot"
config.gem "icalendar"
config.gem 'thoughtbot-shoulda', :lib => 'shoulda/rails', :source => "http://gems.github.com"
end end

@ -14,7 +14,7 @@ config.whiny_nils = true
# Show full error reports and disable caching # Show full error reports and disable caching
config.action_controller.consider_all_requests_local = true config.action_controller.consider_all_requests_local = true
config.action_controller.perform_caching = false config.action_controller.perform_caching = false
config.action_view.cache_template_extensions = false #config.action_view.cache_template_extensions = false
config.action_view.debug_rjs = true config.action_view.debug_rjs = true
# Don't care if the mailer can't send # Don't care if the mailer can't send

@ -1,4 +0,0 @@
require 'hpricot'
require 'icalendar'
require 'tzinfo'
#require 'assert_valid_xhtml'

@ -1,4 +1,4 @@
TzTime.zone = TZInfo::Timezone.new("America/Fortaleza") #TzTime.zone = TZInfo::Timezone.new("America/Fortaleza")
class Time class Time
alias :strftime_nolocale :strftime alias :strftime_nolocale :strftime

@ -3,6 +3,12 @@
require "#{RAILS_ROOT}/app/models/message.rb" require "#{RAILS_ROOT}/app/models/message.rb"
require "#{RAILS_ROOT}/app/models/log_entry.rb" require "#{RAILS_ROOT}/app/models/log_entry.rb"
class Fixnum
def is_numeric?
true
end
end
class String class String
def is_numeric? def is_numeric?
Float self rescue false Float self rescue false
@ -24,3 +30,21 @@ class Array
self self
end end
end end
module ActiveRecord
module Acts
module Versioned
module ClassMethods
def acts_as_paranoid_versioned
acts_as_paranoid
acts_as_versioned
# protect the versioned model
self.versioned_class.class_eval do
def self.delete_all(conditions = nil); return; end
end
end
end
end
end
end

@ -31,11 +31,13 @@ ActionController::Routing::Routes.draw do |map|
} }
course.resources :news, course.resources :news,
:singular => "news_instance",
:member => { :member => {
:undelete => :post :undelete => :post
} }
course.resources :wiki, course.resources :wiki,
:singular => "wiki_instance",
:member => { :member => {
:diff => :get, :diff => :get,
:versions => :get, :versions => :get,

@ -25,6 +25,7 @@
### Códigos fonte e textos não formatados ### Códigos fonte e textos não formatados
- `O comando \`printf(x)\` escreve na tela` - `O comando \`printf(x)\` escreve na tela`
<pre>Este é um exemplo de código fonte com várias linhas: <pre>Este é um exemplo de código fonte com várias linhas:
tell application "Foo" tell application "Foo"

@ -0,0 +1,3 @@
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../config/boot'
require 'commands/dbconsole'

@ -20,7 +20,7 @@ require 'attachments_controller'
# Re-raise errors caught by the controller. # Re-raise errors caught by the controller.
class AttachmentsController; def rescue_action(e) raise e end; end class AttachmentsController; def rescue_action(e) raise e end; end
class AttachmentsControllerTest < Test::Unit::TestCase class AttachmentsControllerTest < ActionController::TestCase
fixtures :attachments fixtures :attachments
def setup def setup

@ -14,13 +14,13 @@
# 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.rb'
require 'courses_controller' require 'courses_controller'
# Re-raise errors caught by the controller. # Re-raise errors caught by the controller.
#class CoursesController; def rescue_action(e) raise e end; end #class CoursesController; def rescue_action(e) raise e end; end
class CoursesControllerTest < Test::Unit::TestCase class CoursesControllerTest < ActionController::TestCase
def setup def setup
@controller = CoursesController.new @controller = CoursesController.new
@ -31,7 +31,7 @@ class CoursesControllerTest < Test::Unit::TestCase
# 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.create.params = { :short_name => 'test', :full_name => 'test', :description => 'test' } resource.create.params = { :short_name => 'test', :full_name => 'test', :description => 'test' }
resource.update.params = { :short_name => 'test', :full_name => 'test', :description => 'test' } resource.update.params = { :short_name => 'test', :full_name => 'test', :description => 'test' }

@ -20,7 +20,7 @@ require 'events_controller'
# Re-raise errors caught by the controller. # Re-raise errors caught by the controller.
class EventsController; def rescue_action(e) raise e end; end class EventsController; def rescue_action(e) raise e end; end
class EventsControllerTest < Test::Unit::TestCase class EventsControllerTest < ActionController::TestCase
def setup def setup
@controller = EventsController.new @controller = EventsController.new

@ -20,7 +20,7 @@ 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 < Test::Unit::TestCase class NewsControllerTest < ActionController::TestCase
def setup def setup
@controller = NewsController.new @controller = NewsController.new
@request = ActionController::TestRequest.new @request = ActionController::TestRequest.new
@ -39,7 +39,7 @@ class NewsControllerTest < Test::Unit::TestCase
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_index_url(@course)" resource.destroy.redirect = "course_news_url(@course)"
end end
end end

@ -20,7 +20,7 @@ require 'stylesheets_controller'
# Re-raise errors caught by the controller. # Re-raise errors caught by the controller.
class StylesheetsController; def rescue_action(e) raise e end; end class StylesheetsController; def rescue_action(e) raise e end; end
class StylesheetsControllerTest < Test::Unit::TestCase class StylesheetsControllerTest < ActionController::TestCase
def setup def setup
@controller = StylesheetsController.new @controller = StylesheetsController.new

@ -20,7 +20,7 @@ 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 < Test::Unit::TestCase class UsersControllerTest < ActionController::TestCase
self.use_instantiated_fixtures = true self.use_instantiated_fixtures = true

@ -20,7 +20,7 @@ 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) raise e end; end
class WikiControllerTest < Test::Unit::TestCase class WikiControllerTest < ActionController::TestCase
def setup def setup
@controller = WikiController.new @controller = WikiController.new
@request = ActionController::TestRequest.new @request = ActionController::TestRequest.new
@ -47,32 +47,32 @@ class WikiControllerTest < Test::Unit::TestCase
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 = WikiPage # resource.klass = WikiPage
resource.parent = [ :course ] # resource.parent = [ :course ]
resource.create.params = { :title => 'test4', :description => 'test', :content => 'test4', :course_id => 1 } # resource.create.params = { :title => 'test4', :description => 'test', :content => 'test4', :course_id => 1 }
resource.update.params = { :title => 'test5', :description => 'test', :content => 'test5', :course_id => 1 } # resource.update.params = { :title => 'test5', :description => 'test', :content => 'test5', :course_id => 1 }
resource.actions = [ :show, :new, :edit, :update, :create, :destroy ] # resource.actions = [ :show, :new, :edit, :update, :create, :destroy ]
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_text_on_show #def test_should_accept_text_on_show
get :show, :format => 'txt', :course_id => 1, :id => @wiki_page.id # get :show, :format => 'txt', :course_id => 1, :id => @wiki_page.id
assert_formatted_response :text # assert_formatted_response :text
end #end
def test_should_accept_html_on_versions #def test_should_accept_html_on_versions
get :versions, :course_id => 1, :id => @wiki_page.id # get :versions, :course_id => 1, :id => @wiki_page.id
assert_response :success # assert_response :success
end #end
def test_should_accept_xml_on_versions #def test_should_accept_xml_on_versions
get :versions, :format => 'xml', :course_id => 1, :id => @wiki_page.id # get :versions, :format => 'xml', :course_id => 1, :id => @wiki_page.id
assert_formatted_response :xml, :versions # assert_formatted_response :xml, :versions
end #end
end end

@ -4,7 +4,7 @@ require 'test_help'
require 'redgreen' require 'redgreen'
require 'quietbacktrace' require 'quietbacktrace'
class Test::Unit::TestCase class ActiveSupport::TestCase
self.new_backtrace_silencer :shoulda do |line| self.new_backtrace_silencer :shoulda do |line|
line.include? 'vendor/plugins/shoulda' line.include? 'vendor/plugins/shoulda'
@ -69,3 +69,4 @@ class Test::Unit::TestCase
end end
end end
end end

@ -16,7 +16,7 @@
require File.dirname(__FILE__) + '/../test_helper' require File.dirname(__FILE__) + '/../test_helper'
class AttachmentTest < Test::Unit::TestCase class AttachmentTest < ActiveSupport::TestCase
fixtures :attachments fixtures :attachments
def setup def setup

@ -16,7 +16,7 @@
require File.dirname(__FILE__) + '/../test_helper' require File.dirname(__FILE__) + '/../test_helper'
class CourseTest < Test::Unit::TestCase class CourseTest < ActiveSupport::TestCase
fixtures :courses fixtures :courses

@ -16,7 +16,7 @@
require File.dirname(__FILE__) + '/../test_helper' require File.dirname(__FILE__) + '/../test_helper'
class EventTest < Test::Unit::TestCase class EventTest < ActiveSupport::TestCase
fixtures :events fixtures :events
# Replace this with your real tests. # Replace this with your real tests.

@ -16,15 +16,21 @@
require File.dirname(__FILE__) + '/../test_helper' require File.dirname(__FILE__) + '/../test_helper'
class MessageTest < Test::Unit::TestCase class MessageTest < ActiveSupport::TestCase
fixtures :messages fixtures :messages
def test_should_create_new_version
news = News.find(1)
news.title = "another title"
assert news.save_version?
end
def test_should_not_create_new_version def test_should_not_create_new_version
news = News.find(1) news = News.find(1)
news.destroy news.destroy
news = News.find_with_deleted(1) news = News.find_with_deleted(1)
news.restore! news.recover!
assert !news.dirty? assert !news.save_version?
end end
end end

@ -16,7 +16,7 @@
require File.dirname(__FILE__) + '/../test_helper' require File.dirname(__FILE__) + '/../test_helper'
class NotificationsTest < Test::Unit::TestCase class NotificationsTest < ActiveSupport::TestCase
FIXTURES_PATH = File.dirname(__FILE__) + '/../fixtures' FIXTURES_PATH = File.dirname(__FILE__) + '/../fixtures'
CHARSET = "utf-8" CHARSET = "utf-8"

@ -16,7 +16,7 @@
require File.dirname(__FILE__) + '/../test_helper' require File.dirname(__FILE__) + '/../test_helper'
class UserTest < Test::Unit::TestCase class UserTest < ActiveSupport::TestCase
fixtures :users fixtures :users

@ -16,10 +16,10 @@
require File.dirname(__FILE__) + '/../test_helper' require File.dirname(__FILE__) + '/../test_helper'
class WikiPageTest < Test::Unit::TestCase class WikiPageTest < ActiveSupport::TestCase
def test_should_create_new_version_when_editing def test_should_create_new_version_when_editing
wp = WikiPage.create(:content => 'test', :title => 'test', :version => 1, :course_id => 1, :user_id => 1, :description => 'teste') wp = WikiPage.new
assert !wp.save_version? assert !wp.save_version?
wp.content = 'new content' wp.content = 'new content'
@ -27,7 +27,7 @@ class WikiPageTest < Test::Unit::TestCase
end end
def test_should_not_create_new_version_when_reordering def test_should_not_create_new_version_when_reordering
wp = WikiPage.create(:content => 'test', :title => 'test', :version => 1, :course_id => 1, :user_id => 1, :description => 'teste') wp = WikiPage.new
assert !wp.save_version? assert !wp.save_version?
wp.move_higher wp.move_higher