coast 0.9.8 → 0.9.9
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +1 -1
- data/Gemfile.lock +7 -3
- data/README.md +1 -1
- data/lib/coast.rb +1 -1
- data/lib/coast/version.rb +1 -1
- data/test/test_coast.rb +16 -1
- metadata +2 -2
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -4,6 +4,7 @@ GEM
|
|
4
4
|
activesupport (3.2.11)
|
5
5
|
i18n (~> 0.6)
|
6
6
|
multi_json (~> 1.0)
|
7
|
+
binding_of_caller (0.6.8)
|
7
8
|
coderay (1.0.8)
|
8
9
|
i18n (0.6.1)
|
9
10
|
method_source (0.8.1)
|
@@ -12,11 +13,13 @@ GEM
|
|
12
13
|
os
|
13
14
|
multi_json (1.5.0)
|
14
15
|
os (0.9.6)
|
15
|
-
pry (0.9.
|
16
|
+
pry (0.9.11.4)
|
16
17
|
coderay (~> 1.0.5)
|
17
18
|
method_source (~> 0.8)
|
18
|
-
slop (~> 3.
|
19
|
-
|
19
|
+
slop (~> 3.4)
|
20
|
+
pry-stack_explorer (0.4.7)
|
21
|
+
binding_of_caller (~> 0.6.8)
|
22
|
+
slop (3.4.3)
|
20
23
|
|
21
24
|
PLATFORMS
|
22
25
|
ruby
|
@@ -26,3 +29,4 @@ DEPENDENCIES
|
|
26
29
|
micro_mock
|
27
30
|
micro_test
|
28
31
|
pry
|
32
|
+
pry-stack_explorer
|
data/README.md
CHANGED
data/lib/coast.rb
CHANGED
@@ -163,7 +163,7 @@ module Coast
|
|
163
163
|
@resourceful_item ||= resourceful_model.new(params[resourceful_model.name.underscore])
|
164
164
|
send(self.class.authorize_method, :create, @resourceful_item, request)
|
165
165
|
init_instance_variables
|
166
|
-
success = @skip_db_create || @resourceful_item.save
|
166
|
+
success = @skip_db_create || @resourceful_item.valid? && @resourceful_item.save
|
167
167
|
invoke_callback(:respond_to_create)
|
168
168
|
unless performed?
|
169
169
|
respond_to do |format|
|
data/lib/coast/version.rb
CHANGED
data/test/test_coast.rb
CHANGED
@@ -15,9 +15,12 @@ class TestCoast < MicroTest::Test
|
|
15
15
|
# Creates a mock model instance [ActiveRecord::Base].
|
16
16
|
def self.mock_model
|
17
17
|
mock = MicroMock.make.new
|
18
|
+
mock.def(:valid?) { true }
|
19
|
+
mock.attr(:errors, {})
|
18
20
|
mock.def(:destroy) { @destroyed = true }
|
19
21
|
mock.def(:destroyed?) { @destroyed }
|
20
22
|
mock.def(:update_attributes) { |*args| @attributes_updated = true }
|
23
|
+
mock.def(:saved?) { @saved }
|
21
24
|
mock.def(:save) { |*args| @saved = true }
|
22
25
|
mock.class.def(:find) { |*args| TestCoast.mock_model }
|
23
26
|
mock.class.def(:all) { (1..5).map { TestCoast.mock_model } }
|
@@ -41,7 +44,7 @@ class TestCoast < MicroTest::Test
|
|
41
44
|
mock.def(:authorize_invoked?) { @authorize_invoked }
|
42
45
|
mock.def(:respond_to) { |&block| @responded = true; block.call(format) }
|
43
46
|
mock.def(:responded?) { @responded }
|
44
|
-
mock.def(:render) { |*args| @performed = @rendered = true }
|
47
|
+
mock.def(:render) { |*args| @render_args = args; @performed = @rendered = true }
|
45
48
|
mock.def(:performed?) { @performed }
|
46
49
|
mock.def(:rendered?) { @rendered }
|
47
50
|
mock.def(:redirect_to) { |*args| @redirected = true; render }
|
@@ -131,8 +134,20 @@ class TestCoast < MicroTest::Test
|
|
131
134
|
end
|
132
135
|
end
|
133
136
|
|
137
|
+
test "<create> invalid record" do
|
138
|
+
@controller.class.class_eval do
|
139
|
+
before :create do
|
140
|
+
@resourceful_item = TestCoast.mock_model
|
141
|
+
@resourceful_item.def("valid?") { false }
|
142
|
+
end
|
143
|
+
end
|
144
|
+
@controller.create
|
145
|
+
assert !@controller.instance_eval{ @resourceful_item }.saved?
|
146
|
+
end
|
147
|
+
|
134
148
|
test "<create> flash message" do
|
135
149
|
@controller.create
|
150
|
+
assert @controller.instance_eval{ @resourceful_item }.saved?
|
136
151
|
assert @controller.flash[:notice].ends_with?("was successfully created.")
|
137
152
|
end
|
138
153
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: coast
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.9
|
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: 2013-01-
|
12
|
+
date: 2013-01-28 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|