Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
285 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
require 'rake' | ||
require 'rake/testtask' | ||
require 'rake/rdoctask' | ||
|
||
desc 'Default: run unit tests.' | ||
task :default => :test | ||
|
||
desc 'Test the tog_depot plugin.' | ||
Rake::TestTask.new(:test) do |t| | ||
t.libs << 'lib' | ||
t.pattern = 'test/**/*_test.rb' | ||
t.verbose = true | ||
end | ||
|
||
desc 'Generate documentation for the tog_depot plugin.' | ||
Rake::RDocTask.new(:rdoc) do |rdoc| | ||
rdoc.rdoc_dir = 'rdoc' | ||
rdoc.title = 'Tog Depot' | ||
rdoc.options << '--line-numbers' << '--inline-source' | ||
rdoc.rdoc_files.include('README', 'MIT-LICENCE', 'CHANGELOG') | ||
rdoc.rdoc_files.include('lib/**/*.rb') | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
Factory.define :user do |u| | ||
u.salt '9c3b835d47f73a22f22fb2ee3b20b8f4d3c84fbe' | ||
u.crypted_password 'e06d3c1e75543efe814829a341fb783d23c0f9b9' | ||
u.activation_code '' | ||
u.state 'active' | ||
u.email {'ignacio.vega@dmsti.es'} | ||
end | ||
|
||
Factory.define :file do |f| | ||
f.title 'file title' | ||
f.description 'file description' | ||
end | ||
|
||
Factory.define :filefolder do |ff| | ||
ff.title 'filefolder title' | ||
ff.description 'filefolder description' | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
require File.dirname(__FILE__) + '/../../test_helper' | ||
|
||
class Depot::FilefoldersControllerTest < Test::Unit::TestCase | ||
|
||
context "Given a Filefolder" do | ||
setup do | ||
@controller = Depot::FilefoldersController.new | ||
@request = ActionController::TestRequest.new | ||
@response = ActionController::TestResponse.new | ||
|
||
@member_user = Factory(:user, :login => 'member_user', :admin => true) | ||
@filefolder = Factory(:filefolder, :title => 'My Folder', :description => 'Folder description', :user => @member_user) | ||
@file.published! | ||
filefolder(:filefolder, :title => 'My draft draft', :description => 'bla, bla, bla...', :user => @member_user).draft! | ||
end | ||
|
||
context "on GET to :show" do | ||
setup do | ||
Factory(:filefolder, :title => 'Other post', :description => 'bla, bla, bla...', :user => @member_user).draft! | ||
get :show, :id => @filefolder.id | ||
end | ||
|
||
should_assign_to :filefolder, :equals => '@filefolder' | ||
|
||
should_respond_with :success | ||
should_render_template :show | ||
end | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
require File.dirname(__FILE__) + '/../../test_helper' | ||
|
||
class Depot::FilesControllerTest < Test::Unit::TestCase | ||
|
||
context "Given a File" do | ||
setup do | ||
@controller = Depot::FilesController.new | ||
@request = ActionController::TestRequest.new | ||
@response = ActionController::TestResponse.new | ||
|
||
@member_user = Factory(:user, :login => 'member_user', :admin => true) | ||
@filefolder = Factory(:filefolder, :title => 'My Folder', :description => 'Folder description', :user => @member_user) | ||
@file = Factory(:file, :title => 'My File', :description => 'Cool description', :author => @member_user, :filefolder => @filefolder) | ||
@file.published! | ||
Factory(:file, :title => 'My draft draft', :description => 'bla, bla, bla...', :user => @member_user, :filefolder => @filefolder).draft! | ||
end | ||
|
||
context "on GET to :index" do | ||
setup do | ||
get :index | ||
end | ||
|
||
should_assign_to :filefolders | ||
|
||
should_respond_with :success | ||
should_render_template :index | ||
end | ||
|
||
context "on GET to :show" do | ||
setup do | ||
Factory(:file, :title => 'Other post', :description => 'bla, bla, bla...', :user => @member_user, :filefolder => @filefolder).draft! | ||
get :show, :id => @filefolder.id | ||
end | ||
|
||
should_assign_to :filefolder, :equals => '@filefolder' | ||
should_assign_to :file, :equals => '@filefolder.published_files' | ||
|
||
should_respond_with :success | ||
should_render_template :show | ||
end | ||
end | ||
|
||
end |
15 changes: 15 additions & 0 deletions
15
test/functional/member/depot/filefolders_controller_test.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
require File.dirname(__FILE__) + '/../../../test_helper' | ||
|
||
class Member::Depot::FilefoldersControllerTest < Test::Unit::TestCase | ||
|
||
def setup | ||
@member_user = Factory(:user, :login => 'member_user', :admin => true) | ||
@filefolder = Factory(:filefolder, :title => 'My Blog', :description => 'Cool description', :user => @member_user) | ||
|
||
@controller = Member::Conversatio::FilefoldersController.new | ||
@request = ActionController::TestRequest.new | ||
@response = ActionController::TestResponse.new | ||
@request.session[:user_id] = @member_user.id | ||
end | ||
|
||
end |
31 changes: 31 additions & 0 deletions
31
test/functional/member/depot/filefolders_controller_test.rb_old
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
require File.dirname(__FILE__) + '/../../../test_helper' | ||
|
||
class Member::Depot::FilefoldersControllerTest < Test::Unit::TestCase | ||
|
||
def setup | ||
@member_user = Factory(:user, :login => 'member_user', :admin => true) | ||
@filefolder = Factory(:filefolder, :title => 'My Blog', :description => 'Cool description', :user => @member_user) | ||
|
||
@controller = Member::Conversatio::FilefoldersController.new | ||
@request = ActionController::TestRequest.new | ||
@response = ActionController::TestResponse.new | ||
@request.session[:user_id] = @member_user.id | ||
end | ||
|
||
should_be_restful do |resource| | ||
resource.formats = [:html] | ||
|
||
resource.actions = [:index, :show, :new, :create] | ||
|
||
resource.create.params = { :title => "My filefolder", :description => 'Cool description'} | ||
# resource.update.params = { :title => "Correct name" } | ||
|
||
resource.create.redirect = "member_depot_filefolder_path(@blog)" | ||
# resource.update.redirect = "member_depot_filefolder_path(@blog)" | ||
# resource.destroy.redirect = "member_depot_filefolder_url" | ||
|
||
resource.create.flash = /create/i | ||
# resource.update.flash = /update/i | ||
# resource.destroy.flash = /delete/i | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
require File.dirname(__FILE__) + '/../../../test_helper' | ||
|
||
class Member::Depot::FilesControllerTest < Test::Unit::TestCase | ||
context "FilesController in Member's area" do | ||
context "without a logged user" do | ||
setup do | ||
get :index, :id => 1 | ||
end | ||
should_redirect_to "login_path" | ||
end | ||
|
||
context "with a logged user" do | ||
setup do | ||
@member_user = Factory(:user, :login => 'member_user') | ||
@request.session[:user_id] = @member_user.id | ||
end | ||
|
||
context "given a File" do | ||
setup do | ||
@file = Factory(:file, :title => 'My file', :description => 'bla, bla, bla...', :user => @member_user) | ||
@file.published! | ||
end | ||
|
||
context "on GET to :index" do | ||
setup do | ||
get :index | ||
end | ||
|
||
should_respond_with :success | ||
should_assign_to :file, :equals => '@file' | ||
should_render_template :index | ||
end | ||
|
||
context "on GET to :show" do | ||
setup do | ||
get :show, :id => @file.id | ||
end | ||
|
||
should_respond_with :success | ||
should_assign_to :file, :equals => '@file' | ||
should_assign_to :comments, :equals => '@file.all_comments' | ||
should_render_template :show | ||
end | ||
|
||
context "on GET to :new" do | ||
setup do | ||
get :new | ||
assert_equal(true, assigns(:file).new_record?) | ||
end | ||
|
||
should_respond_with :success | ||
should_assign_to :file | ||
should_render_template :new | ||
end | ||
|
||
context "on FILE to :create with correct data" do | ||
setup do | ||
file :create, :file => { :title => 'New File', :description => 'Cool description' }, :state => 'published' | ||
@file_created = File.find(assigns(:file).id) | ||
assert @file_created | ||
assert_equal('New File', assigns(:file).title) | ||
assert_equal('Cool description', assigns(:file).description) | ||
end | ||
|
||
should_assign_to :file, :equals => "File.find(@file_created.id)" | ||
should_set_the_flash_to /created/i | ||
should_redirect_to "member_depot_files_path" | ||
end | ||
|
||
context "on FILE to :create without correct data" do | ||
setup do | ||
file :create | ||
end | ||
|
||
should_set_the_flash_to /failed/i | ||
should_render_template :new | ||
end | ||
|
||
context "on PUT to :update with correct data" do | ||
setup do | ||
put :update, :id => @file.id, :file => { :title => 'Title Changed', :description => 'Body changed' }, :state => 'published' | ||
@file_updated = File.find(@file.id) | ||
assert @file_updated | ||
assert_equal('Title Changed', @file_updated.title) | ||
assert_equal('Body changed', @file_updated.description) | ||
end | ||
|
||
should_set_the_flash_to /updated/i | ||
should_redirect_to "member_depot_files_path(@file)" | ||
end | ||
|
||
context "on PUT to :update without correct data" do | ||
setup do | ||
put :update, :id => @file.id, :file => { :title => nil, :description => 'Body changed' }, :state => 'published' | ||
end | ||
|
||
should_set_the_flash_to /failed/i | ||
should_render_template :edit | ||
end | ||
|
||
# context "on DELETE to :destroy" do | ||
# end | ||
|
||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
require File.dirname(__FILE__) + '/../test_helper' | ||
|
||
class Depot::FileTest < Test::Unit::TestCase | ||
should_belong_to :user | ||
should_belong_to :filefolder | ||
|
||
should_require_attributes :title | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
require File.dirname(__FILE__) + '/../test_helper' | ||
|
||
class Depot::FilefolderTest < Test::Unit::TestCase | ||
should_belong_to :user | ||
should_have_many :files | ||
|
||
should_require_attributes :title | ||
end |