yeti 0.3.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/yeti/editor.rb +5 -1
- data/lib/yeti/version.rb +1 -1
- data/spec/yeti/editor_spec.rb +7 -0
- metadata +1 -1
data/lib/yeti/editor.rb
CHANGED
@@ -4,7 +4,7 @@ module Yeti
|
|
4
4
|
include ActiveModel::Dirty
|
5
5
|
|
6
6
|
attr_reader :context
|
7
|
-
delegate :id, :to_param, :
|
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,
|
data/lib/yeti/version.rb
CHANGED
data/spec/yeti/editor_spec.rb
CHANGED
@@ -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 }
|