Avatares
This commit is contained in:
@@ -20,9 +20,9 @@ class LogController < ApplicationController
|
|||||||
|
|
||||||
def index
|
def index
|
||||||
if @course
|
if @course
|
||||||
@log_entries = @course.log_entries.find(:all, :limit => 50) #.paginate(:page => params[:page], :per_page => 30)
|
@log_entries = @course.log_entries.paginate(:page => params[:page], :per_page => 30)
|
||||||
else
|
else
|
||||||
@log_entries = LogEntry.find(:all, :limit => 50, :order => 'created_at desc')
|
@log_entries = LogEntry.paginate(:page => params[:page], :per_page => 30)
|
||||||
end
|
end
|
||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
|
|||||||
@@ -21,11 +21,11 @@ class UsersController < ApplicationController
|
|||||||
before_filter :require_admin, :only => [ :edit, :update, :destroy ]
|
before_filter :require_admin, :only => [ :edit, :update, :destroy ]
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@users = User.find(:all, :order => 'name')
|
@users = User.paginate(:page => params[:page], :per_page => 20, :order => 'last_seen')
|
||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html
|
format.html
|
||||||
format.xml { render :xml => @users }
|
format.xml { render :xml => User.find(:all) }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -101,7 +101,7 @@ class UsersController < ApplicationController
|
|||||||
flash[:message] = 'Welcome back, {u}'[:login_success, @user.login]
|
flash[:message] = 'Welcome back, {u}'[:login_success, @user.login]
|
||||||
redirect_to_stored
|
redirect_to_stored
|
||||||
else
|
else
|
||||||
flash[:warning] = 'Login failed'
|
flash[:warning] = 'Login failed'[]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -116,11 +116,11 @@ class UsersController < ApplicationController
|
|||||||
@news = []
|
@news = []
|
||||||
@events = []
|
@events = []
|
||||||
|
|
||||||
if params[:format] == 'html'
|
if params[:secret]
|
||||||
|
@user = User.find_by_secret(params[:secret])
|
||||||
|
else
|
||||||
return require_login unless logged_in?
|
return require_login unless logged_in?
|
||||||
@user = @current_user
|
@user = @current_user
|
||||||
else
|
|
||||||
@user = User.find_by_secret(params[:secret])
|
|
||||||
end
|
end
|
||||||
|
|
||||||
unless @user.courses.empty?
|
unless @user.courses.empty?
|
||||||
@@ -163,19 +163,6 @@ class UsersController < ApplicationController
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# def forgot_password
|
|
||||||
# if request.post?
|
|
||||||
# u = User.find_by_email(params[:user][:email])
|
|
||||||
# if u and u.send_new_password
|
|
||||||
# flash[:message] = "Uma nova senha foi enviada para o seu email."
|
|
||||||
# redirect_to :action=>'login'
|
|
||||||
# else
|
|
||||||
# flash[:warning] = "Não foi possível gerar uma nova senha."
|
|
||||||
# end
|
|
||||||
# end
|
|
||||||
# end
|
|
||||||
|
|
||||||
#Funções do Fórum
|
|
||||||
protected
|
protected
|
||||||
def find_user
|
def find_user
|
||||||
params[:id] = User.find_by_login(params[:id]).id if params[:id] and !params[:id].is_numeric?
|
params[:id] = User.find_by_login(params[:id]).id if params[:id] and !params[:id].is_numeric?
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ module ApplicationHelper
|
|||||||
end
|
end
|
||||||
|
|
||||||
def gravatar_url_for(email, size=80)
|
def gravatar_url_for(email, size=80)
|
||||||
"http://www.gravatar.com/avatar.php?gravatar_id=#{Digest::MD5.hexdigest(email)}&size=#{size}&default=#{App.default_avatar}"
|
"http://www.gravatar.com/avatar.php?gravatar_id=#{Digest::MD5.hexdigest(email)}&size=#{size}&default=#{App.default_avatar}_#{size}.png"
|
||||||
end
|
end
|
||||||
|
|
||||||
def action_icon(action_name, description, options = {}, html_options = {})
|
def action_icon(action_name, description, options = {}, html_options = {})
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ class LogEntry < ActiveRecord::Base
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
require 'log_entry/attachment_log_entry.rb'
|
load 'log_entry/attachment_log_entry.rb'
|
||||||
require 'log_entry/event_log_entry.rb'
|
load 'log_entry/event_log_entry.rb'
|
||||||
require 'log_entry/news_log_entry.rb'
|
load 'log_entry/news_log_entry.rb'
|
||||||
require 'log_entry/wiki_log_entry.rb'
|
load 'log_entry/wiki_log_entry.rb'
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
-# cache(course_path(@course.id, :part => :right)) do
|
-# cache(course_path(@course.id, :part => :right)) do
|
||||||
= render :file => 'widgets/calendario'
|
= render :file => 'widgets/calendario'
|
||||||
= render :file => 'widgets/news'
|
= render :file => 'widgets/users'
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
= "Anexo " + link_to(h(entry.attachment.file_name), course_attachment_url(entry.course, entry.attachment))
|
= "criou " if entry.kind_of?(AttachmentCreateLogEntry)
|
||||||
|
= "editou " if entry.kind_of?(AttachmentEditLogEntry)
|
||||||
|
= "excluiu " if entry.kind_of?(AttachmentDeleteLogEntry)
|
||||||
|
= "restaurou " if entry.kind_of?(AttachmentRestoreLogEntry)
|
||||||
|
|
||||||
= "criado " if entry.kind_of?(AttachmentCreateLogEntry)
|
= "o anexo " + link_to(h(entry.attachment.file_name), course_attachment_url(entry.course, entry.attachment))
|
||||||
= "editado " if entry.kind_of?(AttachmentEditLogEntry)
|
|
||||||
= "excluído " if entry.kind_of?(AttachmentDeleteLogEntry)
|
|
||||||
= "restaurado " if entry.kind_of?(AttachmentRestoreLogEntry)
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
= "Evento " + link_to(h(entry.event.title), course_event_url(entry.course, entry.event, :version => entry.version))
|
= "criou " if entry.kind_of?(EventCreateLogEntry)
|
||||||
|
= "editou " if entry.kind_of?(EventEditLogEntry)
|
||||||
|
= "excluiu " if entry.kind_of?(EventDeleteLogEntry)
|
||||||
|
= "restaurou " if entry.kind_of?(EventRestoreLogEntry)
|
||||||
|
|
||||||
= "criado " if entry.kind_of?(EventCreateLogEntry)
|
= "o evento " + link_to(h(entry.event.title), course_event_url(entry.course, entry.event, :version => entry.version))
|
||||||
= "editado " if entry.kind_of?(EventEditLogEntry)
|
|
||||||
= "excluído " if entry.kind_of?(EventDeleteLogEntry)
|
|
||||||
= "restaurado " if entry.kind_of?(EventRestoreLogEntry)
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
= "Notícia " + link_to(h(entry.news.title), course_news_instance_url(entry.course, entry.news, :version => entry.version))
|
= "criou " if entry.kind_of?(NewsCreateLogEntry)
|
||||||
|
= "editou " if entry.kind_of?(NewsEditLogEntry)
|
||||||
|
= "excluiu " if entry.kind_of?(NewsDeleteLogEntry)
|
||||||
|
= "restaurou " if entry.kind_of?(NewsRestoreLogEntry)
|
||||||
|
|
||||||
= "criada " if entry.kind_of?(NewsCreateLogEntry)
|
= "a notícia " + link_to(h(entry.news.title), course_news_instance_url(entry.course, entry.news, :version => entry.version))
|
||||||
= "editada " if entry.kind_of?(NewsEditLogEntry)
|
|
||||||
= "excluída " if entry.kind_of?(NewsDeleteLogEntry)
|
|
||||||
= "restaurada " if entry.kind_of?(NewsRestoreLogEntry)
|
|
||||||
|
|||||||
@@ -1,17 +1,19 @@
|
|||||||
- if entry.version
|
= "criou " if entry.kind_of?(WikiCreateLogEntry)
|
||||||
= "Página " + link_to(h(entry.wiki_page.title), course_wiki_instance_url(entry.course, entry.wiki_page.id, :version => entry.version))
|
= "editou " if entry.kind_of?(WikiEditLogEntry)
|
||||||
- else
|
= "excluiu " if entry.kind_of?(WikiDeleteLogEntry)
|
||||||
= "Página " + link_to(h(entry.wiki_page.title), course_wiki_instance_url(entry.course, entry.wiki_page.id))
|
= "restaurou " if entry.kind_of?(WikiRestoreLogEntry)
|
||||||
|
|
||||||
|
- if entry.version
|
||||||
|
= "a página " + link_to(h(entry.wiki_page.title), course_wiki_instance_url(entry.course, entry.wiki_page.id, :version => entry.version))
|
||||||
|
- else
|
||||||
|
= "a 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)
|
|
||||||
= "editada " if entry.kind_of?(WikiEditLogEntry)
|
|
||||||
= "excluída " if entry.kind_of?(WikiDeleteLogEntry)
|
|
||||||
= "restaurada " if entry.kind_of?(WikiRestoreLogEntry)
|
|
||||||
|
|
||||||
- current_version = entry.wiki_page.versions.find_by_version(entry.version)
|
- current_version = entry.wiki_page.versions.find_by_version(entry.version)
|
||||||
- previous_version = current_version.previous
|
- previous_version = current_version.previous if current_version
|
||||||
|
|
||||||
- if entry.kind_of?(WikiEditLogEntry)
|
- if entry.kind_of?(WikiEditLogEntry)
|
||||||
|
- unless current_version.nil?
|
||||||
- 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>)"
|
||||||
|
|
||||||
|
|||||||
@@ -4,18 +4,20 @@
|
|||||||
-# if @course
|
-# if @course
|
||||||
=# auto_discovery_link_tag :rss, course_log_url(@course.id, :format => :rss)
|
=# auto_discovery_link_tag :rss, course_log_url(@course.id, :format => :rss)
|
||||||
|
|
||||||
|
- @log_entries_by_day = @log_entries.group_by { |l| l.created_at.beginning_of_day }
|
||||||
.box
|
.box
|
||||||
%table
|
%ul.log_entries
|
||||||
%tr
|
- @log_entries_by_day.each do |day, entries|
|
||||||
%th Data
|
%h3
|
||||||
%th Usuário
|
=tz(day).strftime("%d de %B de %Y")
|
||||||
- unless @course
|
- entries.each do |entry|
|
||||||
%th Disciplina
|
%li
|
||||||
%th Descrição
|
.date
|
||||||
- @log_entries.each do |entry|
|
= tz(entry.created_at).strftime("%H:%M")
|
||||||
%tr
|
%img.avatar{:src => gravatar_url_for(entry.user.email, 27)}
|
||||||
%td= tz(entry.created_at).strftime("%d/%m/%y %H:%M:%S")
|
= "Disciplina " + link_to(h(entry.course.full_name), course_url(entry.course))
|
||||||
%td= link_to truncate(h(entry.user.display_name), :length => 20), user_url(entry.user.id)
|
%br
|
||||||
- unless @course
|
=link_to truncate(h(entry.user.display_name), :length => 20), user_url(entry.user.id)
|
||||||
%td= link_to h(entry.course.short_name), course_url(entry.course)
|
= render(:partial => 'log/log_entry', :locals => { :entry => entry })
|
||||||
%td= render(:partial => 'log/log_entry', :locals => { :entry => entry })
|
|
||||||
|
= will_paginate @log_entries
|
||||||
|
|||||||
@@ -295,7 +295,7 @@ body {
|
|||||||
border-bottom: 0px solid #ccc;
|
border-bottom: 0px solid #ccc;
|
||||||
}
|
}
|
||||||
|
|
||||||
.widget_news li, .widget_events li, #shoutbox li, #shoutbox {
|
.widget_users li, .widget_news li, .widget_events li {
|
||||||
font-size: 11px;
|
font-size: 11px;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -666,6 +666,14 @@ form dl {
|
|||||||
margin: 5px 18px 0px 0px;
|
margin: 5px 18px 0px 0px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.user_list {
|
||||||
|
list-style: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.user_list li {
|
||||||
|
background-image: none;
|
||||||
|
}
|
||||||
|
|
||||||
.card h1 { margin-bottom: 0px; }
|
.card h1 { margin-bottom: 0px; }
|
||||||
.card p { margin-top: 0px; }
|
.card p { margin-top: 0px; }
|
||||||
|
|
||||||
@@ -827,7 +835,26 @@ form dt p {
|
|||||||
margin: 9px 0px;
|
margin: 9px 0px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.log_entries .date {
|
||||||
|
float: left;
|
||||||
|
width: 50px;
|
||||||
|
margin: 0px 15px 0px -90px;
|
||||||
|
}
|
||||||
|
|
||||||
xbody { background-image: url(<%= App.base_path %>/prototype/line.png); background-repeat: repeat; }
|
.log_entries .avatar {
|
||||||
xhtml * { background-color: transparent !important; }
|
float: left;
|
||||||
|
margin: 0px 0px 0px -40px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.log_entries * {
|
||||||
|
vertical-align: top;
|
||||||
|
background-image: none !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.log_entries li {
|
||||||
|
padding-left: 110px !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*body { background-image: url(<%= App.base_path %>/prototype/line.png); background-repeat: repeat; }
|
||||||
|
html * { background-color: transparent !important; }*/
|
||||||
|
|
||||||
|
|||||||
@@ -1 +1,3 @@
|
|||||||
%li= link_to h(user.name), user_path(user)
|
%li
|
||||||
|
%img.avatar{:src => gravatar_url_for(user.email, 27)}
|
||||||
|
= link_to h(user.display_name), user_url(user)
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
.dashboard
|
.dashboard
|
||||||
.box
|
.box
|
||||||
.cmd
|
.cmd
|
||||||
=link_to "rss", dashboard_url(:secret => @current_user.secret, :format => 'rss')
|
=link_to "rss", formatted_dashboard_url(:secret => @current_user.secret, :format => 'rss')
|
||||||
- last_time = nil
|
- last_time = nil
|
||||||
|
|
||||||
%h3 Notícias Recentes
|
%h3 Notícias Recentes
|
||||||
@@ -26,7 +26,7 @@
|
|||||||
|
|
||||||
.box
|
.box
|
||||||
.cmd
|
.cmd
|
||||||
=link_to "ical", dashboard_url(:secret => @current_user.secret, :format => 'ics')
|
=link_to "ical", formatted_dashboard_url(:secret => @current_user.secret, :format => 'ics')
|
||||||
- last_time = nil
|
- last_time = nil
|
||||||
|
|
||||||
%h3 Próximos Eventos
|
%h3 Próximos Eventos
|
||||||
|
|||||||
@@ -3,5 +3,6 @@
|
|||||||
%h1.title Usuários
|
%h1.title Usuários
|
||||||
|
|
||||||
.box
|
.box
|
||||||
%ul
|
%ul.user_list
|
||||||
= render :partial => @users
|
= render :partial => @users
|
||||||
|
= will_paginate @users
|
||||||
|
|||||||
@@ -3,7 +3,8 @@
|
|||||||
<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_url(@course) %></li>
|
<li><%= link_to "Participantes", course_events_url(@course) %></li>
|
||||||
|
<li><%= link_to "Notícias", 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>
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ App.language = "pt-br"
|
|||||||
App.title = "Wiki UFC"
|
App.title = "Wiki UFC"
|
||||||
App.webmaster_email = "webmaster@wikiufc.gelsol.org"
|
App.webmaster_email = "webmaster@wikiufc.gelsol.org"
|
||||||
|
|
||||||
App.default_host = "wikiufc.gelsol.org"
|
App.default_host = "localhost:3000"
|
||||||
App.base_path = ""
|
App.base_path = ""
|
||||||
|
|
||||||
App.current_period = "2009.2"
|
App.current_period = "2009.2"
|
||||||
@@ -16,7 +16,7 @@ App.max_upload_file_size = 5.megabytes
|
|||||||
|
|
||||||
# Tema
|
# Tema
|
||||||
App.default_color = 0
|
App.default_color = 0
|
||||||
App.default_avatar = "http://wikiufc.gelsol.org/images/avatar.png"
|
App.default_avatar = "http://#{App.default_host}#{App.default_path}/images/avatar"
|
||||||
App.color_schemes = [
|
App.color_schemes = [
|
||||||
# Default
|
# Default
|
||||||
[ "#037", "#069", "#455", "#778" ],
|
[ "#037", "#069", "#455", "#778" ],
|
||||||
|
|||||||
@@ -5,12 +5,18 @@
|
|||||||
# 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.3.2' unless defined? RAILS_GEM_VERSION
|
RAILS_GEM_VERSION = '2.3.4' 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')
|
||||||
|
|
||||||
Rails::Initializer.run do |config|
|
Rails::Initializer.run do |config|
|
||||||
|
|
||||||
|
config.to_prepare do
|
||||||
|
load "#{RAILS_ROOT}/app/models/message.rb"
|
||||||
|
load "#{RAILS_ROOT}/app/models/log_entry.rb"
|
||||||
|
end
|
||||||
|
|
||||||
# Settings in config/environments/* take precedence over those specified here.
|
# Settings in config/environments/* take precedence over those specified here.
|
||||||
# Application configuration should go into files in config/initializers
|
# Application configuration should go into files in config/initializers
|
||||||
# -- all .rb files in that directory are automatically loaded.
|
# -- all .rb files in that directory are automatically loaded.
|
||||||
|
|||||||
@@ -51,6 +51,6 @@ end
|
|||||||
|
|
||||||
# Carrega as classes Message e LogEntry. O lazy loading do Rails gera
|
# Carrega as classes Message e LogEntry. O lazy loading do Rails gera
|
||||||
# problemas se voce definir varias classes por arquivos.
|
# problemas se voce definir varias classes por arquivos.
|
||||||
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"
|
||||||
|
|
||||||
|
|||||||
@@ -57,7 +57,6 @@ ActionController::Routing::Routes.draw do |map|
|
|||||||
map.with_options :controller => 'log' do |log|
|
map.with_options :controller => 'log' do |log|
|
||||||
log.course_log 'courses/:course_id/log', :action => 'index', :format => 'html'
|
log.course_log 'courses/:course_id/log', :action => 'index', :format => 'html'
|
||||||
log.undo_course_log 'courses/:course_id/log/:id/undo', :action => 'undo', :format => 'html'
|
log.undo_course_log 'courses/:course_id/log/:id/undo', :action => 'undo', :format => 'html'
|
||||||
|
|
||||||
log.formatted_course_log 'courses/:course_id/log.:format', :action => 'index'
|
log.formatted_course_log 'courses/:course_id/log.:format', :action => 'index'
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -78,7 +77,7 @@ ActionController::Routing::Routes.draw do |map|
|
|||||||
end
|
end
|
||||||
|
|
||||||
# Pagina pessoal
|
# Pagina pessoal
|
||||||
map.dashboard '/dashboard', :controller => 'users', :action => 'dashboard', :format => 'html'
|
map.dashboard '/dashboard', :controller => 'users', :action => 'dashboard'
|
||||||
map.formatted_dashboard '/dashboard/:secret.:format', :controller => 'users', :action => 'dashboard'
|
map.formatted_dashboard '/dashboard/:secret.:format', :controller => 'users', :action => 'dashboard'
|
||||||
|
|
||||||
# Stylesheets
|
# Stylesheets
|
||||||
|
|||||||
@@ -39,7 +39,10 @@ recent_changes: Mudanças recentes
|
|||||||
log_about: Mudanças recentes em {disciplina}
|
log_about: Mudanças recentes em {disciplina}
|
||||||
|
|
||||||
undo: Desfazer
|
undo: Desfazer
|
||||||
|
login_failed: Não foi possível fazer login
|
||||||
login_required: É necessário fazer login para acessar esta área do site
|
login_required: É necessário fazer login para acessar esta área do site
|
||||||
|
login_success: Olá, {u}!
|
||||||
|
logout_success: Você fez logout
|
||||||
|
|
||||||
navigation: navegação
|
navigation: navegação
|
||||||
forums: fórums
|
forums: fórums
|
||||||
|
|||||||
@@ -46,8 +46,8 @@ module AuthenticationSystem
|
|||||||
end
|
end
|
||||||
|
|
||||||
def destroy_session
|
def destroy_session
|
||||||
session.delete
|
session.clear
|
||||||
cookies.delete :login_token
|
cookies.delete(:login_token)
|
||||||
end
|
end
|
||||||
|
|
||||||
def redirect_to_stored
|
def redirect_to_stored
|
||||||
|
|||||||
BIN
public/images/avatar_27.png
Normal file
BIN
public/images/avatar_27.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 502 B |
|
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 1.2 KiB |
@@ -29,6 +29,15 @@ class CoursesControllerTest < ActionController::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
context "An anonymous user" do
|
context "An anonymous user" do
|
||||||
|
|
||||||
|
should_request_login_on_post_to(:new, {})
|
||||||
|
should_request_login_on_post_to(:create, {})
|
||||||
|
should_request_login_on_post_to(:edit, {:id => 1})
|
||||||
|
should_request_login_on_post_to(:update, {:id => 1})
|
||||||
|
should_request_login_on_post_to(:destroy, {:id => 1})
|
||||||
|
should_request_login_on_post_to(:enroll, {:id => 1})
|
||||||
|
should_request_login_on_post_to(:unenroll, {:id => 1})
|
||||||
|
|
||||||
context "on get to :index" do
|
context "on get to :index" do
|
||||||
setup { get :index }
|
setup { get :index }
|
||||||
|
|
||||||
@@ -36,11 +45,37 @@ class CoursesControllerTest < ActionController::TestCase
|
|||||||
should_render_template 'index'
|
should_render_template 'index'
|
||||||
|
|
||||||
should "display the course list" do
|
should "display the course list" do
|
||||||
|
assert_select 'h1', "Disciplinas #{App.current_period}"
|
||||||
assert_select 'a[href=?]', course_url(@course)
|
assert_select 'a[href=?]', course_url(@course)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
should "choose display the selected period" do
|
||||||
|
get :index, :period => "1970.1"
|
||||||
|
assert_select 'h1', "Disciplinas 1970.1"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context "on get to :show" do
|
||||||
|
setup { get :show, :id => @course.id }
|
||||||
|
|
||||||
|
should_respond_with :success
|
||||||
|
should_render_template 'show'
|
||||||
|
|
||||||
|
should "display the course" do
|
||||||
|
assert_select 'a[href=?]', course_log_url(@course)
|
||||||
|
assert_select 'a[href=?]', course_news_url(@course)
|
||||||
|
assert_select 'a[href=?]', course_events_url(@course)
|
||||||
|
assert_select 'a[href=?]', new_course_event_url(@course)
|
||||||
|
assert_select 'a[href=?]', new_course_attachment_url(@course)
|
||||||
|
assert_select 'a[href=?]', new_course_wiki_instance_url(@course)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context "An authenticated user" do
|
||||||
|
setup { login_as :bob }
|
||||||
|
end
|
||||||
|
|
||||||
# REST - usuários autenticados
|
# REST - usuários autenticados
|
||||||
#context "A user" do
|
#context "A user" do
|
||||||
# #setup { login_as :bob }
|
# #setup { login_as :bob }
|
||||||
|
|||||||
@@ -22,12 +22,27 @@ class UsersController; def rescue_action(e) raise e end; end
|
|||||||
|
|
||||||
class UsersControllerTest < ActionController::TestCase
|
class UsersControllerTest < ActionController::TestCase
|
||||||
|
|
||||||
self.use_instantiated_fixtures = true
|
context "An authenticated user" do
|
||||||
|
setup { login_as :bob }
|
||||||
|
|
||||||
fixtures :users
|
context "on get to :dashboard" do
|
||||||
|
setup { get :dashboard }
|
||||||
|
|
||||||
def test_true
|
should_respond_with :success
|
||||||
assert true
|
should_render_template "dashboard"
|
||||||
|
end
|
||||||
|
|
||||||
|
context "on post to :logout" do
|
||||||
|
setup { get :logout }
|
||||||
|
|
||||||
|
should_respond_with :redirect
|
||||||
|
should_redirect_to('the main page') { index_url }
|
||||||
|
|
||||||
|
should "log out" do
|
||||||
|
assert_nil session[:user_id]
|
||||||
|
assert_nil cookies[:login_token]
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user