yeti 0.3.1 → 0.3.2

Sign up to get free protection for your applications and to get access to all the features.
data/lib/yeti/editor.rb CHANGED
@@ -7,14 +7,14 @@ module Yeti
7
7
  delegate :id, :to_param, to: :edited, allow_nil: true
8
8
 
9
9
  def self.from_id(context, id)
10
- new context, (find_by_id id if id)
10
+ new context, (find_by_id context, id if id)
11
11
  end
12
12
 
13
- def self.find_by_id(id)
13
+ def self.find_by_id(context, id)
14
14
  raise NotImplementedError, "#{inspect}.find_by_id"
15
15
  end
16
16
 
17
- def self.new_object
17
+ def self.new_object(context)
18
18
  raise NotImplementedError, "#{inspect}.new_object"
19
19
  end
20
20
 
@@ -24,7 +24,7 @@ module Yeti
24
24
  end
25
25
 
26
26
  def edited
27
- @edited ||= self.class.new_object
27
+ @edited ||= self.class.new_object context
28
28
  end
29
29
 
30
30
  def persisted?
data/lib/yeti/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Yeti
2
- VERSION = "0.3.1"
2
+ VERSION = "0.3.2"
3
3
  end
@@ -5,19 +5,19 @@ describe ::Yeti::Editor do
5
5
  subject{ described_class.new context }
6
6
  it ".new_object is virtual" do
7
7
  lambda do
8
- described_class.new_object
8
+ described_class.new_object context
9
9
  end.should raise_error NotImplementedError, "Yeti::Editor.new_object"
10
10
  end
11
11
  it ".find_by_id is virtual" do
12
12
  lambda do
13
- described_class.find_by_id 1
13
+ described_class.find_by_id context, 1
14
14
  end.should raise_error NotImplementedError, "Yeti::Editor.find_by_id"
15
15
  end
16
16
  describe "initialization" do
17
17
  let(:new_object){ mock :new_object }
18
18
  let(:existing_object){ mock :existing_object }
19
19
  context "with context only" do
20
- before{ described_class.stub(:new_object).and_return new_object }
20
+ before{ described_class.stub(:new_object).with(context).and_return new_object }
21
21
  it "keeps given context" do
22
22
  subject.context.should be context
23
23
  end
@@ -74,14 +74,14 @@ describe ::Yeti::Editor do
74
74
  context "when given_id is nil" do
75
75
  let(:given_id){ nil }
76
76
  it "uses .new_object to generate object to edit" do
77
- described_class.should_receive(:new_object).and_return new_object
77
+ described_class.should_receive(:new_object).with(context).and_return new_object
78
78
  subject.edited.should be new_object
79
79
  end
80
80
  end
81
81
  context "when given_id is not nil" do
82
82
  let(:given_id){ "1" }
83
83
  it "uses .find_by_id to find object to edit" do
84
- described_class.should_receive(:find_by_id).with("1").and_return do
84
+ described_class.should_receive(:find_by_id).with(context, "1").and_return do
85
85
  existing_object
86
86
  end
87
87
  subject.edited.should be existing_object
@@ -115,7 +115,7 @@ describe ::Yeti::Editor do
115
115
  def self.name
116
116
  "ObjectEditor"
117
117
  end
118
- def self.new_object
118
+ def self.new_object(context)
119
119
  Struct.new(:id, :name).new nil, nil
120
120
  end
121
121
  end
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.1
4
+ version: 0.3.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-12-24 00:00:00.000000000 Z
12
+ date: 2012-12-25 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activemodel