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 "webmock"
gem "timecop"
gem "test-unit-rails"
gem "ruby-prof"
end
group :assets do

View File

@ -52,12 +52,6 @@ GEM
net-ssh-gateway (>= 1.1.0)
capistrano-unicorn (0.1.10)
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)
coderay (1.0.9)
crack (0.4.1)
@ -154,7 +148,6 @@ GEM
json (~> 1.4)
ref (1.0.5)
rmagick (2.13.2)
rr (1.1.2)
ruby-prof (0.13.0)
safe_yaml (0.9.5)
sanitize (2.0.6)
@ -186,25 +179,6 @@ GEM
statistics2 (0.54)
term-ansicolor (1.2.2)
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)
libv8 (~> 3.11.8.12)
ref
@ -235,8 +209,6 @@ GEM
activesupport (>= 2.3.4)
chronic (>= 0.6.3)
xml-simple (1.1.2)
xpath (2.0.0)
nokogiri (~> 1.3)
PLATFORMS
ruby
@ -273,7 +245,6 @@ DEPENDENCIES
simplecov
statistics2
term-ansicolor
test-unit-rails
therubyracer
timecop
uglifier (>= 1.0.3)

View File

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

View File

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

View File

@ -38,7 +38,7 @@ class DTextTest < ActiveSupport::TestCase
end
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
def test_spoilers_with_no_closing_tag_2
@ -50,7 +50,7 @@ class DTextTest < ActiveSupport::TestCase
end
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
def test_paragraphs
@ -74,7 +74,7 @@ class DTextTest < ActiveSupport::TestCase
end
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
def test_code