Skip to content

Commit

Permalink
Fixing up some of the tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jcnetdev committed Jul 6, 2008
1 parent d5bc8ba commit afd86bd
Show file tree
Hide file tree
Showing 10 changed files with 297 additions and 248 deletions.
6 changes: 3 additions & 3 deletions app/models/parser.rb
Expand Up @@ -38,9 +38,9 @@ def parse_proper
self.command.uses += 1 self.command.uses += 1
self.command.last_use_date = Time.now self.command.last_use_date = Time.now
self.command.save unless self.command.new_record? self.command.save unless self.command.new_record?
elsif tokens.size > 1 and self.command_name and self.command_name.length < 5 # elsif tokens.size > 1 and self.command_name and self.command_name.length < 5
# tried to search for something but failed # # tried to search for something but failed
return nil # return nil
else else
# find default if passed in # find default if passed in
self.command = Command.by_name(@default) self.command = Command.by_name(@default)
Expand Down
26 changes: 26 additions & 0 deletions db/development_structure.sql
@@ -0,0 +1,26 @@
CREATE TABLE `banned_url_patterns` (
`id` int(11) NOT NULL auto_increment,
`pattern` varchar(255) default NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

CREATE TABLE `commands` (
`id` int(11) NOT NULL auto_increment,
`name` varchar(255) default NULL,
`url` text,
`description` text,
`uses` bigint(11) default '0',
`spam` tinyint(1) default '0',
`last_use_date` datetime default NULL,
`golden_egg_date` datetime default NULL,
`created_at` datetime default NULL,
`updated_at` datetime default NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8;

CREATE TABLE `schema_migrations` (
`version` varchar(255) NOT NULL,
UNIQUE KEY `unique_schema_migrations` (`version`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

INSERT INTO schema_migrations (version) VALUES ('0');
19 changes: 0 additions & 19 deletions test/fixtures/users.yml

This file was deleted.

@@ -1,18 +1,14 @@
require File.dirname(__FILE__) + '/../test_helper' require File.dirname(__FILE__) + '/../test_helper'
require File.dirname(__FILE__) + '/../../app/helpers/application_helper.rb' require File.dirname(__FILE__) + '/../../app/helpers/application_helper.rb'
require 'command_controller'


# Re-raise errors caught by the controller. # Re-raise errors caught by the controller.
class CommandController; def rescue_action(e) raise e end; end class CommandsController; def rescue_action(e) raise e end; end


class CommandControllerTest < Test::Unit::TestCase class CommandsControllerTest < Test::Unit::TestCase
include ApplicationHelper
include CommandHelper
include ParserHelper
fixtures :commands, :banned_url_patterns fixtures :commands, :banned_url_patterns


def setup def setup
@controller = CommandController.new @controller = CommandsController.new
@request = ActionController::TestRequest.new @request = ActionController::TestRequest.new
@response = ActionController::TestResponse.new @response = ActionController::TestResponse.new
end end
Expand All @@ -34,7 +30,7 @@ def test_banning_empty_string
pattern = BannedUrlPattern.new pattern = BannedUrlPattern.new
pattern.pattern = '' pattern.pattern = ''
pattern.save pattern.save
post :add_command, {'x' => '', 'command' => {'name' => 'aaaaa', 'url' => 'http://aaaaa.com', 'description' => 'A great site!'}} post :create, {'x' => '', 'command' => {'name' => 'aaaaa', 'url' => 'http://aaaaa.com', 'description' => 'A great site!'}}
assert_redirected_to :action => 'index' assert_redirected_to :action => 'index'
assert_equal(1, Command.find_all("url LIKE 'http://aaaaa.com'").size) assert_equal(1, Command.find_all("url LIKE 'http://aaaaa.com'").size)
end end
Expand Down
18 changes: 0 additions & 18 deletions test/functional/documentation_controller_test.rb

This file was deleted.

16 changes: 7 additions & 9 deletions test/functional/kernel_controller_test.rb
Expand Up @@ -14,7 +14,7 @@ def setup
@response = ActionController::TestResponse.new @response = ActionController::TestResponse.new
end end
def command_names def command_names
assigns['commands'].collect{|command|command.name}.join(",") assigns["commands"].collect{|command|command.name}.join(",")
end end
def test_ls def test_ls
get :ls get :ls
Expand All @@ -36,24 +36,22 @@ def test_man
get :man, {'args', 'gim'} get :man, {'args', 'gim'}
assert_response :success assert_response :success
get :man, {'args', 'blah_blah_blah'} get :man, {'args', 'blah_blah_blah'}
assert_tag :content => 'No manual entry for blah_blah_blah'
# assert_select "body > div", :text => "No manual entry for blah_blah_blah"

get :man, {'args', 'blah blah blah'} get :man, {'args', 'blah blah blah'}
assert_tag :content => 'No manual entry for blah blah blah'
# assert_select "body > div", :text => "No manual entry for blah blah blah"
end end
def test_truncate_with_ellipses def test_truncate_with_ellipses
assert_equal 'abcd', truncate_with_ellipses("abcd", 5) assert_equal 'abcd', truncate_with_ellipses("abcd", 5)
assert_equal 'abcde', truncate_with_ellipses("abcde", 5) assert_equal 'abcde', truncate_with_ellipses("abcde", 5)
assert_equal 'abcde...', truncate_with_ellipses("abcdef", 5) assert_equal 'abcde...', truncate_with_ellipses("abcdef", 5)
end end

def test_url_format_recognized def test_url_format_recognized
assert url_format_recognized('http://foo.com') assert url_format_recognized('http://foo.com')
assert url_format_recognized('{blah}') assert url_format_recognized('{blah}')
assert ! url_format_recognized('foo {blah}') assert ! url_format_recognized('foo {blah}')
end end
def test_where
assert_equal nil, @controller.where(nil)
assert_equal nil, @controller.where('')
assert_equal nil, @controller.where(' ')
assert_equal "name like '%foo%' or description like '%foo%' or url like '%foo%'", @controller.where('foo')
end
end end
90 changes: 0 additions & 90 deletions test/functional/sessions_controller_test.rb

This file was deleted.

87 changes: 0 additions & 87 deletions test/functional/users_controller_test.rb

This file was deleted.

2 changes: 2 additions & 0 deletions test/unit/command_test.rb
Expand Up @@ -10,4 +10,6 @@ def setup
def test_truth def test_truth
assert true assert true
end end


end end

0 comments on commit afd86bd

Please sign in to comment.