yeti 0.3.0 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -4,7 +4,7 @@ module Yeti
4
4
  include ActiveModel::Dirty
5
5
 
6
6
  attr_reader :context
7
- delegate :id, :to_param, :persisted?, to: :edited
7
+ delegate :id, :to_param, to: :edited, allow_nil: true
8
8
 
9
9
  def self.from_id(context, id)
10
10
  new context, (find_by_id id if id)
@@ -27,6 +27,10 @@ module Yeti
27
27
  @edited ||= self.class.new_object
28
28
  end
29
29
 
30
+ def persisted?
31
+ edited ? edited.persisted? : false
32
+ end
33
+
30
34
  def errors
31
35
  @errors ||= ::Yeti::Errors.new(
32
36
  self,
@@ -1,3 +1,3 @@
1
1
  module Yeti
2
- VERSION = "0.3.0"
2
+ VERSION = "0.3.1"
3
3
  end
@@ -38,6 +38,13 @@ describe ::Yeti::Editor do
38
38
  it "delegates persisted? edited object" do
39
39
  should delegates(:persisted?).to :new_object
40
40
  end
41
+ it ".new_object can be nil" do
42
+ described_class.stub :new_object
43
+ subject.edited.should be_nil
44
+ subject.id.should be_nil
45
+ subject.to_param.should be_nil
46
+ subject.should_not be_persisted
47
+ end
41
48
  end
42
49
  context "initialize with context and object to edit" do
43
50
  subject{ described_class.new context, existing_object }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yeti
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: