Initial import
This commit is contained in:
17
test/fixtures/attachments.yml
vendored
Normal file
17
test/fixtures/attachments.yml
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
# Engenharia de Software 2007.1
|
||||
# Copyright (C) 2007, Adriano, Alinson, Andre, Rafael e Bustamante
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
|
||||
one:
|
||||
id: 1
|
||||
two:
|
||||
id: 2
|
||||
19
test/fixtures/courses.yml
vendored
Normal file
19
test/fixtures/courses.yml
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
# Engenharia de Software 2007.1
|
||||
# Copyright (C) 2007, Adriano, Alinson, Andre, Rafael e Bustamante
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
|
||||
course_1:
|
||||
id: 1
|
||||
short_name: course1
|
||||
full_name: Firt Course
|
||||
description: Description goes here
|
||||
|
||||
23
test/fixtures/events.yml
vendored
Normal file
23
test/fixtures/events.yml
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
# Engenharia de Software 2007.1
|
||||
# Copyright (C) 2007, Adriano, Alinson, Andre, Rafael e Bustamante
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
|
||||
event1:
|
||||
id: 1
|
||||
course_id: 1
|
||||
created_by: 1
|
||||
title: Event 1
|
||||
date: <%= Date.today %>
|
||||
time: <%= Time.now %>
|
||||
description: A random test event
|
||||
#two:
|
||||
# id: 2
|
||||
7
test/fixtures/log_entries.yml
vendored
Normal file
7
test/fixtures/log_entries.yml
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
|
||||
|
||||
# one:
|
||||
# column: value
|
||||
#
|
||||
# two:
|
||||
# column: value
|
||||
23
test/fixtures/messages.yml
vendored
Normal file
23
test/fixtures/messages.yml
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
# Engenharia de Software 2007.1
|
||||
# Copyright (C) 2007, Adriano, Alinson, Andre, Rafael e Bustamante
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
|
||||
news_message:
|
||||
id: 1
|
||||
title: test
|
||||
body: test
|
||||
timestamp: <%= Time.now %>
|
||||
receiver_id: 1
|
||||
sender_id: 1
|
||||
type: News
|
||||
#two:
|
||||
# id: 2
|
||||
3
test/fixtures/notifications/forgot_password
vendored
Normal file
3
test/fixtures/notifications/forgot_password
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
Notifications#forgot_password
|
||||
|
||||
Find me in app/views/notifications/forgot_password.rhtml
|
||||
46
test/fixtures/users.yml
vendored
Normal file
46
test/fixtures/users.yml
vendored
Normal file
@@ -0,0 +1,46 @@
|
||||
# Engenharia de Software 2007.1
|
||||
# Copyright (C) 2007, Adriano, Alinson, Andre, Rafael e Bustamante
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
|
||||
bob:
|
||||
id: 1000001
|
||||
login: bob
|
||||
salt: 1000
|
||||
name: bob
|
||||
email: bob@mcbob.com
|
||||
hashed_password: 77a0d943cdbace52716a9ef9fae12e45e2788d39 # test
|
||||
display_name: bob
|
||||
last_seen: <%= Time.now %>
|
||||
admin: true
|
||||
|
||||
|
||||
existingbob:
|
||||
id: 1000002
|
||||
salt: 1000
|
||||
name: existingbob
|
||||
login: existingbob
|
||||
email: exbob@mcbob.com
|
||||
hashed_password: 77a0d943cdbace52716a9ef9fae12e45e2788d39 # test
|
||||
display_name: existingbob
|
||||
last_seen: <%= Time.now %>
|
||||
admin: false
|
||||
|
||||
longbob:
|
||||
id: 1000003
|
||||
salt: 1000
|
||||
name: longbob
|
||||
login: longbob
|
||||
email: lbob@mcbob.com
|
||||
hashed_password: 00728d3362c26746ec25963f71be022b152237a9 # longtest
|
||||
display_name: longbob
|
||||
last_seen: <%= Time.now %>
|
||||
admin: false
|
||||
108
test/functional/attachments_controller_test.rb
Normal file
108
test/functional/attachments_controller_test.rb
Normal file
@@ -0,0 +1,108 @@
|
||||
# Engenharia de Software 2007.1
|
||||
# Copyright (C) 2007, Adriano, Alinson, Andre, Rafael e Bustamante
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
|
||||
require File.dirname(__FILE__) + '/../test_helper'
|
||||
require 'attachments_controller'
|
||||
|
||||
# Re-raise errors caught by the controller.
|
||||
class AttachmentsController; def rescue_action(e) raise e end; end
|
||||
|
||||
class AttachmentsControllerTest < Test::Unit::TestCase
|
||||
fixtures :attachments
|
||||
|
||||
def setup
|
||||
@controller = AttachmentsController.new
|
||||
@request = ActionController::TestRequest.new
|
||||
@response = ActionController::TestResponse.new
|
||||
end
|
||||
|
||||
def test_truth
|
||||
assert true
|
||||
end
|
||||
|
||||
#
|
||||
# def test_index
|
||||
# get :index
|
||||
# assert_response :success
|
||||
# assert_template 'list'
|
||||
# end
|
||||
#
|
||||
# def test_list
|
||||
# get :list
|
||||
#
|
||||
# assert_response :success
|
||||
# assert_template 'list'
|
||||
#
|
||||
# assert_not_nil assigns(:attachments)
|
||||
# end
|
||||
#
|
||||
# def test_show
|
||||
# get :show, :id => @first_id
|
||||
#
|
||||
# assert_response :success
|
||||
# assert_template 'show'
|
||||
#
|
||||
# assert_not_nil assigns(:attachment)
|
||||
# assert assigns(:attachment).valid?
|
||||
# end
|
||||
#
|
||||
# def test_new
|
||||
# get :new
|
||||
#
|
||||
# assert_response :success
|
||||
# assert_template 'new'
|
||||
#
|
||||
# assert_not_nil assigns(:attachment)
|
||||
# end
|
||||
#
|
||||
# def test_create
|
||||
# num_attachments = Attachment.count
|
||||
#
|
||||
# post :create, :attachment => {}
|
||||
#
|
||||
# assert_response :redirect
|
||||
# assert_redirected_to :action => 'list'
|
||||
#
|
||||
# assert_equal num_attachments + 1, Attachment.count
|
||||
# end
|
||||
#
|
||||
# def test_edit
|
||||
# get :edit, :id => @first_id
|
||||
#
|
||||
# assert_response :success
|
||||
# assert_template 'edit'
|
||||
#
|
||||
# assert_not_nil assigns(:attachment)
|
||||
# assert assigns(:attachment).valid?
|
||||
# end
|
||||
#
|
||||
# def test_update
|
||||
# post :update, :id => @first_id
|
||||
# assert_response :redirect
|
||||
# assert_redirected_to :action => 'show', :id => @first_id
|
||||
# end
|
||||
#
|
||||
# def test_destroy
|
||||
# assert_nothing_raised {
|
||||
# Attachment.find(@first_id)
|
||||
# }
|
||||
#
|
||||
# post :destroy, :id => @first_id
|
||||
# assert_response :redirect
|
||||
# assert_redirected_to :action => 'list'
|
||||
#
|
||||
# assert_raise(ActiveRecord::RecordNotFound) {
|
||||
# Attachment.find(@first_id)
|
||||
# }
|
||||
# end
|
||||
end
|
||||
50
test/functional/courses_controller_test.rb
Normal file
50
test/functional/courses_controller_test.rb
Normal file
@@ -0,0 +1,50 @@
|
||||
# Engenharia de Software 2007.1
|
||||
# Copyright (C) 2007, Adriano, Alinson, Andre, Rafael e Bustamante
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
|
||||
require File.dirname(__FILE__) + '/../test_helper'
|
||||
require 'courses_controller'
|
||||
|
||||
# Re-raise errors caught by the controller.
|
||||
class CoursesController; def rescue_action(e) raise e end; end
|
||||
|
||||
class CoursesControllerTest < Test::Unit::TestCase
|
||||
|
||||
def setup
|
||||
@controller = CoursesController.new
|
||||
@request = ActionController::TestRequest.new
|
||||
@response = ActionController::TestResponse.new
|
||||
@course = Course.find(:first)
|
||||
end
|
||||
|
||||
# REST - usuários autenticados
|
||||
context "A user" do
|
||||
setup { login_as :bob }
|
||||
should_be_restful do |resource|
|
||||
resource.create.params = { :short_name => 'test', :full_name => 'test', :description => 'test' }
|
||||
resource.update.params = { :short_name => 'test', :full_name => 'test', :description => 'test' }
|
||||
end
|
||||
end
|
||||
|
||||
# REST - usuários quaisquer
|
||||
context "A stranger" do
|
||||
setup { logout }
|
||||
should_be_restful do |resource|
|
||||
resource.create.params = { :short_name => 'test', :full_name => 'test', :description => 'test' }
|
||||
resource.update.params = { :short_name => 'test', :full_name => 'test', :description => 'test' }
|
||||
resource.denied.actions = [ :new, :edit, :create, :update, :destroy ]
|
||||
resource.denied.redirect = "'/login'"
|
||||
resource.denied.flash = /must be logged in/i
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
58
test/functional/events_controller_test.rb
Normal file
58
test/functional/events_controller_test.rb
Normal file
@@ -0,0 +1,58 @@
|
||||
# Engenharia de Software 2007.1
|
||||
# Copyright (C) 2007, Adriano, Alinson, Andre, Rafael e Bustamante
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
|
||||
require File.dirname(__FILE__) + '/../test_helper'
|
||||
require 'events_controller'
|
||||
|
||||
# Re-raise errors caught by the controller.
|
||||
class EventsController; def rescue_action(e) raise e end; end
|
||||
|
||||
class EventsControllerTest < Test::Unit::TestCase
|
||||
|
||||
def setup
|
||||
@controller = EventsController.new
|
||||
@request = ActionController::TestRequest.new
|
||||
@response = ActionController::TestResponse.new
|
||||
@course = Course.find(:first)
|
||||
@event = @course.events.find(:first)
|
||||
end
|
||||
|
||||
# REST - usuários autenticados
|
||||
context "A user" do
|
||||
setup { login_as :bob }
|
||||
should_be_restful do |resource|
|
||||
resource.parent = [ :course ]
|
||||
resource.create.params = { :title => 'test', :date => Date.today, :time => Time.now, :description => 'test', :created_by => 1 }
|
||||
resource.update.params = { :title => 'test', :date => Date.today, :time => Time.now, :description => 'test', :created_by => 1 }
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
# REST - usuários quaisquer
|
||||
context "A stranger" do
|
||||
setup { logout }
|
||||
should_be_restful do |resource|
|
||||
resource.parent = [ :course ]
|
||||
resource.create.params = { :title => 'test', :date => Date.today, :time => Time.now, :description => 'test', :created_by => 1 }
|
||||
resource.update.params = { :title => 'test', :date => Date.today, :time => Time.now, :description => 'test', :created_by => 1 }
|
||||
resource.denied.actions = [ :new, :edit, :create, :update, :destroy ]
|
||||
resource.denied.redirect = "'/login'"
|
||||
resource.denied.flash = /must be logged in/i
|
||||
end
|
||||
end
|
||||
|
||||
def test_should_accept_icalendar_on_index
|
||||
get :index, :format => 'ics', :course_id => 1
|
||||
assert_formatted_response :ics
|
||||
end
|
||||
end
|
||||
8
test/functional/log_controller_test.rb
Normal file
8
test/functional/log_controller_test.rb
Normal file
@@ -0,0 +1,8 @@
|
||||
require File.dirname(__FILE__) + '/../test_helper'
|
||||
|
||||
class LogControllerTest < ActionController::TestCase
|
||||
# Replace this with your real tests.
|
||||
def test_truth
|
||||
assert true
|
||||
end
|
||||
end
|
||||
49
test/functional/news_controller_test.rb
Normal file
49
test/functional/news_controller_test.rb
Normal file
@@ -0,0 +1,49 @@
|
||||
require File.dirname(__FILE__) + '/../test_helper'
|
||||
require 'news_controller'
|
||||
|
||||
# Re-raise errors caught by the controller.
|
||||
class NewsController; def rescue_action(e) raise e end; end
|
||||
|
||||
class NewsControllerTest < Test::Unit::TestCase
|
||||
def setup
|
||||
@controller = NewsController.new
|
||||
@request = ActionController::TestRequest.new
|
||||
@response = ActionController::TestResponse.new
|
||||
|
||||
@course = Course.find(:first)
|
||||
@news = @course.news.find(:first)
|
||||
end
|
||||
|
||||
# REST - usuários autenticados
|
||||
context "A user" do
|
||||
setup { login_as :bob }
|
||||
should_be_restful do |resource|
|
||||
resource.klass = News
|
||||
resource.object = 'news'
|
||||
resource.parent = [ :course ]
|
||||
resource.create.params = { :title => 'test', :body => 'test', :receiver_id => 1 }
|
||||
resource.update.params = { :title => 'test', :body => 'test', :receiver_id => 1 }
|
||||
resource.destroy.redirect = "course_news_index_url(@course)"
|
||||
end
|
||||
end
|
||||
|
||||
# REST - usuários quaisquer
|
||||
context "A stranger" do
|
||||
setup { logout }
|
||||
should_be_restful do |resource|
|
||||
resource.klass = News
|
||||
resource.object = 'news'
|
||||
resource.parent = [ :course ]
|
||||
resource.create.params = { :title => 'test', :body => 'test', :receiver_id => 1 }
|
||||
resource.update.params = { :title => 'test', :body => 'test', :receiver_id => 1 }
|
||||
resource.denied.actions = [ :new, :edit, :create, :update, :destroy ]
|
||||
resource.denied.redirect = "'/login'"
|
||||
resource.denied.flash = /must be logged in/i
|
||||
end
|
||||
end
|
||||
|
||||
def test_should_accept_rss_on_index
|
||||
get :index, :format => 'rss', :course_id => 1
|
||||
assert_formatted_response :rss
|
||||
end
|
||||
end
|
||||
33
test/functional/stylesheets_controller_test.rb
Normal file
33
test/functional/stylesheets_controller_test.rb
Normal file
@@ -0,0 +1,33 @@
|
||||
# Engenharia de Software 2007.1
|
||||
# Copyright (C) 2007, Adriano, Alinson, Andre, Rafael e Bustamante
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
|
||||
require File.dirname(__FILE__) + '/../test_helper'
|
||||
require 'stylesheets_controller'
|
||||
|
||||
# Re-raise errors caught by the controller.
|
||||
class StylesheetsController; def rescue_action(e) raise e end; end
|
||||
|
||||
class StylesheetsControllerTest < Test::Unit::TestCase
|
||||
|
||||
def setup
|
||||
@controller = StylesheetsController.new
|
||||
@request = ActionController::TestRequest.new
|
||||
@response = ActionController::TestResponse.new
|
||||
end
|
||||
|
||||
# Replace this with your real tests.
|
||||
def test_truth
|
||||
assert true
|
||||
end
|
||||
|
||||
end
|
||||
30
test/functional/user_controller_test.rb
Normal file
30
test/functional/user_controller_test.rb
Normal file
@@ -0,0 +1,30 @@
|
||||
# Engenharia de Software 2007.1
|
||||
# Copyright (C) 2007, Adriano, Alinson, Andre, Rafael e Bustamante
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
|
||||
require File.dirname(__FILE__) + '/../test_helper'
|
||||
require 'users_controller'
|
||||
|
||||
# Re-raise errors caught by the controller.
|
||||
class UsersController; def rescue_action(e) raise e end; end
|
||||
|
||||
class UsersControllerTest < Test::Unit::TestCase
|
||||
|
||||
self.use_instantiated_fixtures = true
|
||||
|
||||
fixtures :users
|
||||
|
||||
def test_true
|
||||
assert true
|
||||
end
|
||||
|
||||
end
|
||||
76
test/functional/wiki_controller_test.rb
Normal file
76
test/functional/wiki_controller_test.rb
Normal file
@@ -0,0 +1,76 @@
|
||||
|
||||
# Engenharia de Software 2007.1
|
||||
# Copyright (C) 2007, Adriano, Alinson, Andre, Rafael e Bustamante
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
|
||||
require File.dirname(__FILE__) + '/../test_helper'
|
||||
require 'wiki_controller'
|
||||
|
||||
# Re-raise errors caught by the controller.
|
||||
class WikiController; def rescue_action(e) raise e end; end
|
||||
|
||||
class WikiControllerTest < Test::Unit::TestCase
|
||||
def setup
|
||||
@controller = WikiController.new
|
||||
@request = ActionController::TestRequest.new
|
||||
@response = ActionController::TestResponse.new
|
||||
@course = Course.find(:first)
|
||||
@wiki_page = @course.wiki_pages.create(:title => 'test1', :content => 'test1', :description => 'test', :version => 1)
|
||||
@wiki_page.user = users(:bob)
|
||||
@wiki_page.save!
|
||||
end
|
||||
|
||||
# REST - usuários autenticados
|
||||
context "A user" do
|
||||
setup { login_as :bob }
|
||||
should_be_restful do |resource|
|
||||
resource.klass = WikiPage
|
||||
resource.parent = [ :course ]
|
||||
resource.create.params = { :title => 'test2', :description => 'test', :content => 'test2', :course_id => 1 }
|
||||
resource.update.params = { :title => 'test3', :description => 'test', :content => 'test3', :course_id => 1 }
|
||||
resource.actions = [ :show, :new, :edit, :update, :create, :destroy ]
|
||||
resource.destroy.redirect = "course_url(@course)"
|
||||
resource.create.redirect = "course_wiki_url(@course, @wiki_page)"
|
||||
resource.update.redirect = "course_wiki_url(@course, @wiki_page)"
|
||||
end
|
||||
end
|
||||
|
||||
# REST - usuários quaisquer
|
||||
context "A stranger" do
|
||||
setup { logout }
|
||||
should_be_restful do |resource|
|
||||
resource.klass = WikiPage
|
||||
resource.parent = [ :course ]
|
||||
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.actions = [ :show, :new, :edit, :update, :create, :destroy ]
|
||||
resource.denied.actions = [ :new, :edit, :create, :update, :destroy ]
|
||||
resource.denied.redirect = "'/login'"
|
||||
resource.denied.flash = /must be logged in/i
|
||||
end
|
||||
end
|
||||
|
||||
def test_should_accept_text_on_show
|
||||
get :show, :format => 'txt', :course_id => 1, :id => @wiki_page.id
|
||||
assert_formatted_response :text
|
||||
end
|
||||
|
||||
def test_should_accept_html_on_versions
|
||||
get :versions, :course_id => 1, :id => @wiki_page.id
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
def test_should_accept_xml_on_versions
|
||||
get :versions, :format => 'xml', :course_id => 1, :id => @wiki_page.id
|
||||
assert_formatted_response :xml, :versions
|
||||
end
|
||||
end
|
||||
71
test/test_helper.rb
Normal file
71
test/test_helper.rb
Normal file
@@ -0,0 +1,71 @@
|
||||
ENV["RAILS_ENV"] = "test"
|
||||
require File.expand_path(File.dirname(__FILE__) + "/../config/environment")
|
||||
require 'test_help'
|
||||
require 'redgreen'
|
||||
require 'quietbacktrace'
|
||||
|
||||
class Test::Unit::TestCase
|
||||
|
||||
self.new_backtrace_silencer :shoulda do |line|
|
||||
line.include? 'vendor/plugins/shoulda'
|
||||
end
|
||||
self.backtrace_silencers << :shoulda
|
||||
|
||||
# Transactional fixtures accelerate your tests by wrapping each test method
|
||||
# in a transaction that's rolled back on completion. This ensures that the
|
||||
# test database remains unchanged so your fixtures don't have to be reloaded
|
||||
# between every test method. Fewer database queries means faster tests.
|
||||
#
|
||||
# Read Mike Clark's excellent walkthrough at
|
||||
# http://clarkware.com/cgi/blosxom/2005/10/24#Rails10FastTesting
|
||||
#
|
||||
# Every Active Record database supports transactions except MyISAM tables
|
||||
# in MySQL. Turn off transactional fixtures in this case; however, if you
|
||||
# don't care one way or the other, switching from MyISAM to InnoDB tables
|
||||
# is recommended.
|
||||
#
|
||||
# The only drawback to using transactional fixtures is when you actually
|
||||
# need to test transactions. Since your test is bracketed by a transaction,
|
||||
# any transactions started in your code will be automatically rolled back.
|
||||
self.use_transactional_fixtures = true
|
||||
|
||||
# Instantiated fixtures are slow, but give you @david where otherwise you
|
||||
# would need people(:david). If you don't want to migrate your existing
|
||||
# test cases which use the @david style and don't mind the speed hit (each
|
||||
# instantiated fixtures translates to a database query per test method),
|
||||
# then set this back to true.
|
||||
self.use_instantiated_fixtures = false
|
||||
|
||||
# Setup all fixtures in test/fixtures/*.(yml|csv) for all tests in alphabetical order.
|
||||
#
|
||||
# Note: You'll currently still have to declare fixtures explicitly in integration tests
|
||||
# -- they do not yet inherit this setting
|
||||
fixtures :all
|
||||
|
||||
# Add more helper methods to be used by all tests here...
|
||||
def login_as(user)
|
||||
@request.session[:user_id] = users(user).id
|
||||
@request.env["HTTP_AUTHORIZATION"] = user ? "Basic #{Base64.encode64("#{users(user).login}:test")}" : nil
|
||||
end
|
||||
|
||||
def logout
|
||||
@request.session[:user_id] = nil
|
||||
@request.env["HTTP_AUTHORIZATION"] = nil
|
||||
end
|
||||
|
||||
def assert_formatted_response(type, element=nil)
|
||||
assert_response :success
|
||||
snippet = "Body: #{@response.body.first(100).chomp}..."
|
||||
case type
|
||||
when :rss
|
||||
assert_equal Mime::RSS, @response.content_type, snippet
|
||||
assert_select "channel", 1, snippet
|
||||
when :ics
|
||||
assert_equal Mime::ICS, @response.content_type, snippet
|
||||
when :text
|
||||
assert_equal Mime::TEXT, @response.content_type, snippet
|
||||
when :xml
|
||||
assert_select element.to_s.dasherize, 1, snippet
|
||||
end
|
||||
end
|
||||
end
|
||||
51
test/unit/attachment_test.rb
Normal file
51
test/unit/attachment_test.rb
Normal file
@@ -0,0 +1,51 @@
|
||||
# Engenharia de Software 2007.1
|
||||
# Copyright (C) 2007, Adriano, Alinson, Andre, Rafael e Bustamante
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
|
||||
require File.dirname(__FILE__) + '/../test_helper'
|
||||
|
||||
class AttachmentTest < Test::Unit::TestCase
|
||||
fixtures :attachments
|
||||
|
||||
def setup
|
||||
# Cria um pseudo-arquivo, com conteudo qualquer
|
||||
@test_file = StringIO.new
|
||||
@test_file.puts("temp" * 10)
|
||||
@test_file.rewind
|
||||
end
|
||||
|
||||
def test_create_and_destroy_attachment
|
||||
# Cria o anexo
|
||||
att = Attachment.new(:file_name => 'test_file', :content_type => 'text/plain',
|
||||
:description => 'A test file', :course_id => 1)
|
||||
att.file = @test_file
|
||||
|
||||
# Verifica gravacao no bando de dados
|
||||
assert att.save
|
||||
|
||||
# Verifica se o arquivo foi criado no sistema de arquivos
|
||||
file_path = "#{RAILS_ROOT}/public/upload/1/#{att.id}"
|
||||
assert_equal @test_file.size, att.size
|
||||
assert File.exists?(file_path)
|
||||
|
||||
# Verifica se o conteudo do arquivo gerado eh igual ao conteudo do
|
||||
# arquivo original
|
||||
@test_file.rewind
|
||||
assert_equal @test_file.read, File.open(file_path, "r").read
|
||||
|
||||
# Deleta o anexo
|
||||
#att.destroy
|
||||
|
||||
# Verifica se o arquivo foi excluido
|
||||
#assert !File.exists?(file_path)
|
||||
end
|
||||
end
|
||||
114
test/unit/course_test.rb
Normal file
114
test/unit/course_test.rb
Normal file
@@ -0,0 +1,114 @@
|
||||
# Engenharia de Software 2007.1
|
||||
# Copyright (C) 2007, Adriano, Alinson, Andre, Rafael e Bustamante
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
|
||||
require File.dirname(__FILE__) + '/../test_helper'
|
||||
|
||||
class CourseTest < Test::Unit::TestCase
|
||||
|
||||
fixtures :courses
|
||||
|
||||
def test_crud
|
||||
# Create
|
||||
old_count = Course.count
|
||||
|
||||
c = Course.new
|
||||
c.short_name = 'teste'
|
||||
c.full_name = 'teste'
|
||||
c.description = 'teste'
|
||||
|
||||
assert c.save
|
||||
assert_equal old_count + 1, Course.count
|
||||
|
||||
# Retrieve
|
||||
c2 = Course.find(c.id)
|
||||
assert_equal c2.description, c.description
|
||||
assert_equal c2.full_name, c.full_name
|
||||
assert_equal c2.short_name, c.short_name
|
||||
|
||||
# Update
|
||||
assert c.update_attributes(:short_name => 'teste29')
|
||||
assert_equal c.short_name, 'teste2'
|
||||
|
||||
# Delete
|
||||
id = c.id
|
||||
assert c.destroy
|
||||
assert_raises(ActiveRecord::RecordNotFound) { Course.find(id) }
|
||||
assert_equal old_count, Course.count
|
||||
end
|
||||
|
||||
|
||||
def test_validates_presence
|
||||
required_fields = [:short_name, :full_name, :description]
|
||||
required_fields.each do |attr|
|
||||
c = courses(:course_1).clone
|
||||
c.short_name = 'new_test'
|
||||
c.send("#{attr}=", "")
|
||||
|
||||
assert !c.valid?, attr
|
||||
assert_equal 1, c.errors.count, attr
|
||||
assert_not_nil c.errors[attr], attr
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def test_validates_uniqueness_of_short_name
|
||||
c = courses(:course_1).clone
|
||||
assert !c.save
|
||||
assert_not_nil c.errors[:short_name]
|
||||
end
|
||||
|
||||
|
||||
def test_associations
|
||||
associations = [:attachments, :wiki_pages, :shoutbox_messages, :news, :events]
|
||||
c = courses(:course_1)
|
||||
associations.each do |a|
|
||||
assert_nothing_raised {
|
||||
c.send("#{a}").find(:all)
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def test_orphaned_records
|
||||
# Escolhe um curso qualquer
|
||||
course = courses(:course_1)
|
||||
|
||||
# Cria alguns objetos associados ao curso
|
||||
attachment = Attachment.create(:file_name => 'test', :content_type => 'text/plain',
|
||||
:last_modified => Time.now, :description => 'test', :size => 1.megabyte,
|
||||
:course_id => course.id)
|
||||
|
||||
wiki_page = WikiPage.create(:title => 'teste', :course_id => course.id)
|
||||
|
||||
shoutbox_message = Message.create(:title => 'test', :body => 'test body',
|
||||
:timestamp => Time.now, :type => "CourseShoutboxMessage",
|
||||
:sender_id => 0, :receiver_id => course.id)
|
||||
|
||||
news_message = Message.create(:title => 'test', :body => 'test body',
|
||||
:timestamp => Time.now, :type => "News",
|
||||
:sender_id => 0, :receiver_id => course.id)
|
||||
|
||||
event = Event.create(:title => 'test', :date => Time.now, :time => Time.now,
|
||||
:created_by => 0, :course_id => course.id, :description => 'test')
|
||||
|
||||
# Deleta o curso
|
||||
course.destroy
|
||||
|
||||
# Ve o que aconteceu com os objetos
|
||||
assert_raises(ActiveRecord::RecordNotFound) { Attachment.find(attachment.id) }
|
||||
assert_raises(ActiveRecord::RecordNotFound) { WikiPage.find(wiki_page.id) }
|
||||
assert_raises(ActiveRecord::RecordNotFound) { CourseShoutboxMessage.find(shoutbox_message.id) }
|
||||
assert_raises(ActiveRecord::RecordNotFound) { News.find(news_message.id) }
|
||||
assert_raises(ActiveRecord::RecordNotFound) { Event.find(event.id) }
|
||||
end
|
||||
end
|
||||
23
test/unit/event_test.rb
Normal file
23
test/unit/event_test.rb
Normal file
@@ -0,0 +1,23 @@
|
||||
# Engenharia de Software 2007.1
|
||||
# Copyright (C) 2007, Adriano, Alinson, Andre, Rafael e Bustamante
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
|
||||
require File.dirname(__FILE__) + '/../test_helper'
|
||||
|
||||
class EventTest < Test::Unit::TestCase
|
||||
fixtures :events
|
||||
|
||||
# Replace this with your real tests.
|
||||
def test_truth
|
||||
assert true
|
||||
end
|
||||
end
|
||||
8
test/unit/log_entry_test.rb
Normal file
8
test/unit/log_entry_test.rb
Normal file
@@ -0,0 +1,8 @@
|
||||
require File.dirname(__FILE__) + '/../test_helper'
|
||||
|
||||
class LogEntryTest < ActiveSupport::TestCase
|
||||
# Replace this with your real tests.
|
||||
def test_truth
|
||||
assert true
|
||||
end
|
||||
end
|
||||
23
test/unit/message_test.rb
Normal file
23
test/unit/message_test.rb
Normal file
@@ -0,0 +1,23 @@
|
||||
# Engenharia de Software 2007.1
|
||||
# Copyright (C) 2007, Adriano, Alinson, Andre, Rafael e Bustamante
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
|
||||
require File.dirname(__FILE__) + '/../test_helper'
|
||||
|
||||
class MessageTest < Test::Unit::TestCase
|
||||
fixtures :messages
|
||||
|
||||
# Replace this with your real tests.
|
||||
def test_truth
|
||||
assert true
|
||||
end
|
||||
end
|
||||
48
test/unit/notifications_test.rb
Normal file
48
test/unit/notifications_test.rb
Normal file
@@ -0,0 +1,48 @@
|
||||
# Engenharia de Software 2007.1
|
||||
# Copyright (C) 2007, Adriano, Alinson, Andre, Rafael e Bustamante
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
|
||||
require File.dirname(__FILE__) + '/../test_helper'
|
||||
|
||||
class NotificationsTest < Test::Unit::TestCase
|
||||
FIXTURES_PATH = File.dirname(__FILE__) + '/../fixtures'
|
||||
CHARSET = "utf-8"
|
||||
|
||||
include ActionMailer::Quoting
|
||||
|
||||
def setup
|
||||
ActionMailer::Base.delivery_method = :test
|
||||
ActionMailer::Base.perform_deliveries = true
|
||||
ActionMailer::Base.deliveries = []
|
||||
|
||||
@expected = TMail::Mail.new
|
||||
@expected.set_content_type "text", "plain", { "charset" => CHARSET }
|
||||
@expected.mime_version = '1.0'
|
||||
end
|
||||
|
||||
def test_forgot_password
|
||||
@expected.subject = 'Notifications#forgot_password'
|
||||
@expected.body = read_fixture('forgot_password')
|
||||
@expected.date = Time.now
|
||||
|
||||
#assert_equal @expected.encoded, Notifications.create_forgot_password(@expected.date).encoded
|
||||
end
|
||||
|
||||
private
|
||||
def read_fixture(action)
|
||||
IO.readlines("#{FIXTURES_PATH}/notifications/#{action}")
|
||||
end
|
||||
|
||||
def encode(subject)
|
||||
quoted_printable(subject, CHARSET)
|
||||
end
|
||||
end
|
||||
234
test/unit/user_test.rb
Normal file
234
test/unit/user_test.rb
Normal file
@@ -0,0 +1,234 @@
|
||||
# Engenharia de Software 2007.1
|
||||
# Copyright (C) 2007, Adriano, Alinson, Andre, Rafael e Bustamante
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
|
||||
require File.dirname(__FILE__) + '/../test_helper'
|
||||
|
||||
class UserTest < Test::Unit::TestCase
|
||||
|
||||
fixtures :users
|
||||
|
||||
def test_login
|
||||
assert_equal users(:bob), User.find_by_login_and_pass("bob", "test")
|
||||
assert_nil User.find_by_login_and_pass("wrong_bob", "test")
|
||||
assert_nil User.find_by_login_and_pass("bob", "wrongpass")
|
||||
assert_nil User.find_by_login_and_pass("wrong_bob", "wrongpass")
|
||||
end
|
||||
|
||||
|
||||
def test_change_password
|
||||
user = users(:longbob)
|
||||
|
||||
# Check success
|
||||
assert_equal user, User.find_by_login_and_pass("longbob", "longtest")
|
||||
|
||||
# Change password
|
||||
user.password = user.password_confirmation = "nonbobpasswd"
|
||||
assert user.save, user.errors.full_messages
|
||||
|
||||
# New password works
|
||||
assert_equal user, User.find_by_login_and_pass("longbob", "nonbobpasswd")
|
||||
|
||||
# Old pasword doesn't work anymore
|
||||
assert_nil User.find_by_login_and_pass("longbob", "longtest")
|
||||
|
||||
# Change back again
|
||||
user.password = user.password_confirmation = "longtest"
|
||||
|
||||
assert user.save
|
||||
assert_equal user, User.find_by_login_and_pass("longbob", "longtest")
|
||||
assert_nil User.find_by_login_and_pass("longbob", "nonbobpasswd")
|
||||
end
|
||||
|
||||
|
||||
def test_keep_old_password
|
||||
# Dont change the password
|
||||
user = users(:longbob)
|
||||
user.name = "brand new bob"
|
||||
|
||||
assert user.save
|
||||
assert_equal user, User.find_by_login_and_pass("longbob", "longtest")
|
||||
assert_nil User.find_by_login_and_pass("longbob", "")
|
||||
|
||||
# Set a blank password
|
||||
user.password = user.password_confirmation = ""
|
||||
|
||||
assert user.save
|
||||
assert_equal user, User.find_by_login_and_pass("longbob", "longtest")
|
||||
assert_nil User.find_by_login_and_pass("longbob", "")
|
||||
end
|
||||
|
||||
|
||||
def test_validate_password_confirmation
|
||||
u = users(:longbob)
|
||||
|
||||
# No confirmation
|
||||
u.password = "hello"
|
||||
assert !u.valid?
|
||||
assert u.errors.invalid?('password_confirmation')
|
||||
|
||||
# Wrong confirmation
|
||||
u.password_confirmation = "wrong hello"
|
||||
assert !u.valid?
|
||||
assert u.errors.invalid?('password_confirmation')
|
||||
|
||||
# Valid confirmation
|
||||
u.password = u.password_confirmation = "hello world"
|
||||
assert u.valid?
|
||||
end
|
||||
|
||||
|
||||
def test_validate_password
|
||||
u = users(:bob)
|
||||
u.login = "anotherbob"
|
||||
u.email = "anotherbob@bob.com"
|
||||
|
||||
# Too short
|
||||
u.password = u.password_confirmation = "tiny"
|
||||
assert !u.valid?
|
||||
assert u.errors.invalid?('password')
|
||||
|
||||
# Too long
|
||||
u.password = u.password_confirmation = "huge" * 50
|
||||
assert !u.valid?
|
||||
assert u.errors.invalid?('password')
|
||||
|
||||
# Empty
|
||||
newbob = User.new(:login => 'newbob', :email => 'bob@bob.com', :name => 'bob')
|
||||
newbob.password = newbob.password_confirmation = ""
|
||||
assert !newbob.valid?
|
||||
assert newbob.errors.invalid?('password')
|
||||
|
||||
# OK
|
||||
u.password = u.password_confirmation = "bobs_secure_password"
|
||||
assert u.save, u.errors.full_messages
|
||||
assert u.errors.empty?
|
||||
end
|
||||
|
||||
|
||||
def test_validate_login
|
||||
u = users(:bob)
|
||||
u.password = u.password_confirmation = "bobs_secure_password"
|
||||
u.email = "okbob@mcbob.com"
|
||||
|
||||
# Too short
|
||||
u.login = "x"
|
||||
assert !u.valid?
|
||||
assert u.errors.invalid?('login')
|
||||
assert_equal 1, u.errors.count, u.errors.full_messages
|
||||
|
||||
# Too long
|
||||
u.login = "hugebob" * 50
|
||||
assert !u.valid?
|
||||
assert u.errors.invalid?('login')
|
||||
assert_equal 1, u.errors.count, u.errors.full_messages
|
||||
|
||||
# Empty
|
||||
u.login = ""
|
||||
assert !u.valid?
|
||||
assert u.errors.invalid?('login')
|
||||
assert_equal 2, u.errors.count, u.errors.full_messages
|
||||
|
||||
# OK
|
||||
u.login = "okbob"
|
||||
assert u.valid?
|
||||
assert u.errors.empty?
|
||||
end
|
||||
|
||||
|
||||
def test_validate_email
|
||||
u = users(:longbob)
|
||||
|
||||
# No email
|
||||
u.email = nil
|
||||
assert !u.valid?
|
||||
assert u.errors.invalid?('email')
|
||||
assert_equal 2, u.errors.count, u.errors.full_messages
|
||||
|
||||
# Invalid email
|
||||
u.email='notavalidemail'
|
||||
assert !u.valid?
|
||||
assert u.errors.invalid?('email')
|
||||
assert_equal 1, u.errors.count, u.errors.full_messages
|
||||
|
||||
# OK
|
||||
u.email="validbob@mcbob.com"
|
||||
assert u.valid?
|
||||
assert u.errors.empty?
|
||||
end
|
||||
|
||||
def test_signup
|
||||
u = User.new
|
||||
u.last_seen = Time.now
|
||||
u.login = "new bob"
|
||||
u.display_name = "new bob"
|
||||
u.name = u.email = "new@email.com"
|
||||
u.password = u.password_confirmation = "new password"
|
||||
|
||||
assert u.save, u.errors.full_messages
|
||||
assert_equal u, User.find_by_login_and_pass(u.login, u.password)
|
||||
|
||||
assert_not_nil u.salt
|
||||
assert_equal 10, u.salt.length
|
||||
end
|
||||
|
||||
# def test_send_new_password
|
||||
# #check user find_by_login_and_passs
|
||||
# assert_equal @bob, User.find_by_login_and_pass("bob", "test")
|
||||
#
|
||||
# #send new password
|
||||
# sent = @bob.send_new_password
|
||||
# assert_not_nil sent
|
||||
#
|
||||
# #old password no longer workd
|
||||
# assert_nil User.find_by_login_and_pass("bob", "test")
|
||||
#
|
||||
# #email sent...
|
||||
# assert_equal "Your password is ...", sent.subject
|
||||
#
|
||||
# #... to bob
|
||||
# assert_equal @bob.email, sent.to[0]
|
||||
# #assert_match Regexp.new("Your username is bob."), sent.body
|
||||
#
|
||||
# #can find_by_login_and_pass with the new password
|
||||
# #new_pass = $1 if Regexp.new("Your new password is (\\w+).") =~ sent.body
|
||||
# #assert_not_nil new_pass
|
||||
# #assert_equal @bob, User.find_by_login_and_pass("bob", new_pass)
|
||||
# end
|
||||
|
||||
def test_generate_random_pass
|
||||
new_pass = User.random_string(10)
|
||||
assert_not_nil new_pass
|
||||
assert_equal 10, new_pass.length
|
||||
end
|
||||
|
||||
|
||||
def test_sha1
|
||||
u = users(:bob)
|
||||
u.password = u.password_confirmation = "bobs_secure_password"
|
||||
|
||||
assert u.save
|
||||
assert_equal 'b1d27036d59f9499d403f90e0bcf43281adaa844', u.hashed_password
|
||||
assert_equal 'b1d27036d59f9499d403f90e0bcf43281adaa844', User.encrypt("bobs_secure_password", u.salt)
|
||||
end
|
||||
|
||||
|
||||
def test_protected_attributes
|
||||
u = users(:bob)
|
||||
u.update_attributes(:id => 999999, :salt => "I-want-to-set-my-salt", :login => "verybadbob")
|
||||
|
||||
assert u.save
|
||||
assert_not_equal 999999, u.id
|
||||
assert_not_equal "I-want-to-set-my-salt", u.salt
|
||||
assert_equal "verybadbob", u.login
|
||||
end
|
||||
end
|
||||
33
test/unit/wiki_page_test.rb
Normal file
33
test/unit/wiki_page_test.rb
Normal file
@@ -0,0 +1,33 @@
|
||||
# Engenharia de Software 2007.1
|
||||
# Copyright (C) 2007, Adriano, Alinson, Andre, Rafael e Bustamante
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
|
||||
require File.dirname(__FILE__) + '/../test_helper'
|
||||
|
||||
class WikiPageTest < Test::Unit::TestCase
|
||||
|
||||
def test_should_create_new_version_when_editing
|
||||
wp = WikiPage.create(:content => 'test', :title => 'test', :version => 1, :course_id => 1)
|
||||
assert !wp.save_version?
|
||||
|
||||
wp.content = 'new content'
|
||||
assert wp.save_version?
|
||||
end
|
||||
|
||||
def test_should_not_create_new_version_when_reordering
|
||||
wp = WikiPage.create(:content => 'test', :title => 'test', :version => 1, :course_id => 1)
|
||||
assert !wp.save_version?
|
||||
|
||||
wp.move_higher
|
||||
assert !wp.save_version?
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user