drafter 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.0
1
+ 0.2.1
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "drafter"
8
- s.version = "0.2.0"
8
+ s.version = "0.2.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["futurechimp"]
@@ -7,8 +7,10 @@ module Drafter
7
7
 
8
8
  # Apply the draft data to the draftable, without saving it..
9
9
  def apply_draft
10
- restore_attrs
11
- restore_files
10
+ if draft
11
+ restore_attrs
12
+ restore_files
13
+ end
12
14
  self
13
15
  end
14
16
 
@@ -12,23 +12,35 @@ class TestCreation < Minitest::Unit::TestCase
12
12
  describe "to an existing article" do
13
13
  before do
14
14
  @article.save!
15
- @article.text = "changed"
16
- @article.upload = file_upload("bar.txt")
17
- @article.save_draft
18
- @article.reload
19
- @article.apply_draft
20
15
  end
21
16
 
22
- it "should change the article without saving it" do
23
- assert @article.changed?
17
+ describe "when there's no draft" do
18
+ it "should just return the article" do
19
+ @article.apply_draft
20
+ assert @article
21
+ end
24
22
  end
25
23
 
26
- it "should apply the text change" do
27
- assert_equal("changed", @article.text)
28
- end
24
+ describe "with a draft" do
25
+ before do
26
+ @article.text = "changed"
27
+ @article.upload = file_upload("bar.txt")
28
+ @article.save_draft
29
+ @article.reload
30
+ @article.apply_draft
31
+ end
32
+
33
+ it "should change the article without saving it" do
34
+ assert @article.changed?
35
+ end
36
+
37
+ it "should apply the text change" do
38
+ assert_equal("changed", @article.text)
39
+ end
29
40
 
30
- it "should restore the draft upload" do
31
- assert_equal("bar.txt", @article.upload.filename)
41
+ it "should restore the draft upload" do
42
+ assert_equal("bar.txt", @article.upload.filename)
43
+ end
32
44
  end
33
45
  end
34
46
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: drafter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -223,7 +223,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
223
223
  version: '0'
224
224
  segments:
225
225
  - 0
226
- hash: 3926558565189411274
226
+ hash: 1415611400334149220
227
227
  required_rubygems_version: !ruby/object:Gem::Requirement
228
228
  none: false
229
229
  requirements: