Fixes #2042, fix specs

This commit is contained in:
r888888888
2013-12-03 17:19:56 -08:00
parent d270f9d98b
commit b618322ac1
5 changed files with 25 additions and 38 deletions

View File

@@ -10,8 +10,6 @@ group :test do
gem "vcr" gem "vcr"
gem "webmock" gem "webmock"
gem "timecop" gem "timecop"
gem "test-unit-rails"
gem "ruby-prof"
end end
group :assets do group :assets do

View File

@@ -52,12 +52,6 @@ GEM
net-ssh-gateway (>= 1.1.0) net-ssh-gateway (>= 1.1.0)
capistrano-unicorn (0.1.10) capistrano-unicorn (0.1.10)
capistrano capistrano
capybara (2.2.0)
mime-types (>= 1.16)
nokogiri (>= 1.3.3)
rack (>= 1.0.0)
rack-test (>= 0.5.4)
xpath (~> 2.0)
chronic (0.9.1) chronic (0.9.1)
coderay (1.0.9) coderay (1.0.9)
crack (0.4.1) crack (0.4.1)
@@ -154,7 +148,6 @@ GEM
json (~> 1.4) json (~> 1.4)
ref (1.0.5) ref (1.0.5)
rmagick (2.13.2) rmagick (2.13.2)
rr (1.1.2)
ruby-prof (0.13.0) ruby-prof (0.13.0)
safe_yaml (0.9.5) safe_yaml (0.9.5)
sanitize (2.0.6) sanitize (2.0.6)
@@ -186,25 +179,6 @@ GEM
statistics2 (0.54) statistics2 (0.54)
term-ansicolor (1.2.2) term-ansicolor (1.2.2)
tins (~> 0.8) tins (~> 0.8)
test-unit (2.5.5)
test-unit-activesupport (1.0.1)
activesupport
test-unit
test-unit-capybara (1.0.4)
capybara (>= 2.1.0)
json
test-unit (>= 2.5.3)
test-unit-notify (1.0.1)
test-unit (>= 2.4.9)
test-unit-rails (1.0.2)
rails
test-unit-activesupport
test-unit-capybara
test-unit-notify
test-unit-rr
test-unit-rr (1.0.3)
rr (>= 1.1.1)
test-unit (>= 2.5.2)
therubyracer (0.11.4) therubyracer (0.11.4)
libv8 (~> 3.11.8.12) libv8 (~> 3.11.8.12)
ref ref
@@ -235,8 +209,6 @@ GEM
activesupport (>= 2.3.4) activesupport (>= 2.3.4)
chronic (>= 0.6.3) chronic (>= 0.6.3)
xml-simple (1.1.2) xml-simple (1.1.2)
xpath (2.0.0)
nokogiri (~> 1.3)
PLATFORMS PLATFORMS
ruby ruby
@@ -273,7 +245,6 @@ DEPENDENCIES
simplecov simplecov
statistics2 statistics2
term-ansicolor term-ansicolor
test-unit-rails
therubyracer therubyracer
timecop timecop
uglifier (>= 1.0.3) uglifier (>= 1.0.3)

View File

@@ -198,11 +198,17 @@ class DText
when /\[code\](?!\])/ when /\[code\](?!\])/
flags[:code] = true flags[:code] = true
stack << "pre"
'<pre>' '<pre>'
when /\[\/code\](?!\])/ when /\[\/code\](?!\])/
flags[:code] = false flags[:code] = false
'</pre>' if stack.last == "pre"
stack.pop
"</pre>"
else
""
end
when /\[expand(?:\=([^\]]*))?\](?!\])/ when /\[expand(?:\=([^\]]*))?\](?!\])/
stack << "expandable" stack << "expandable"

View File

@@ -125,8 +125,12 @@ class Pool < ActiveRecord::Base
name.gsub(/\s+/, "_") name.gsub(/\s+/, "_")
end end
def self.normalize_post_ids(post_ids) def self.normalize_post_ids(post_ids, unique)
post_ids.scan(/\d+/).uniq.join(" ") hoge = post_ids.scan(/\d+/)
if unique
hoge = hoge.uniq
end
hoge.join(" ")
end end
def self.find_by_name(name) def self.find_by_name(name)
@@ -139,6 +143,14 @@ class Pool < ActiveRecord::Base
end end
end end
def is_series?
category == "series"
end
def is_collection?
category == "collection"
end
def initialize_is_active def initialize_is_active
self.is_deleted = false if is_deleted.nil? self.is_deleted = false if is_deleted.nil?
self.is_active = true if is_active.nil? self.is_active = true if is_active.nil?
@@ -165,7 +177,7 @@ class Pool < ActiveRecord::Base
end end
def normalize_post_ids def normalize_post_ids
self.post_ids = self.class.normalize_post_ids(post_ids) self.post_ids = self.class.normalize_post_ids(post_ids, is_collection?)
end end
def revert_to!(version) def revert_to!(version)

View File

@@ -38,7 +38,7 @@ class DTextTest < ActiveSupport::TestCase
end end
def test_spoilers_with_no_closing_tag_1 def test_spoilers_with_no_closing_tag_1
assert_equal("<div class=\"spoiler\">\n<p>this is a spoiler with no closing tag</p>\n<p>new text</p>\n</div>", p("[spoiler]this is a spoiler with no closing tag\n\nnew text")) assert_equal("<div class=\"spoiler\"><p>this is a spoiler with no closing tag</p><p>new text</p></div>", p("[spoiler]this is a spoiler with no closing tag\n\nnew text"))
end end
def test_spoilers_with_no_closing_tag_2 def test_spoilers_with_no_closing_tag_2
@@ -50,7 +50,7 @@ class DTextTest < ActiveSupport::TestCase
end end
def test_spoilers_nested def test_spoilers_nested
assert_equal("<div class=\"spoiler\">\n<p>this is</p>\n<div class=\"spoiler\"><p>a nested</p></div>\n<p>spoiler</p>\n</div>", p("[spoiler]this is [spoiler]a nested[/spoiler] spoiler[/spoiler]")) assert_equal("<div class=\"spoiler\"><p>this is</p><div class=\"spoiler\"><p>a nested</p></div><p>spoiler</p></div>", p("[spoiler]this is [spoiler]a nested[/spoiler] spoiler[/spoiler]"))
end end
def test_paragraphs def test_paragraphs
@@ -74,7 +74,7 @@ class DTextTest < ActiveSupport::TestCase
end end
def test_quote_blocks_nested def test_quote_blocks_nested
assert_equal("<blockquote>\n<p>a</p>\n<blockquote><p>b</p></blockquote>\n<p>c</p>\n</blockquote>", p("[quote]\na\n[quote]\nb\n[/quote]\nc\n[/quote]")) assert_equal("<blockquote><p>a</p><blockquote><p>b</p></blockquote><p>c</p></blockquote>", p("[quote]\na\n[quote]\nb\n[/quote]\nc\n[/quote]"))
end end
def test_code def test_code