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 CHANGED
@@ -6,6 +6,6 @@ group :test do
6
6
  gem "micro_test"
7
7
  gem "micro_mock"
8
8
  gem "pry"
9
- # gem "pry-stack_explorer"
9
+ gem "pry-stack_explorer"
10
10
  # gem "awesome_print"
11
11
  end
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.10)
16
+ pry (0.9.11.4)
16
17
  coderay (~> 1.0.5)
17
18
  method_source (~> 0.8)
18
- slop (~> 3.3.1)
19
- slop (3.3.3)
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
@@ -176,7 +176,7 @@ $ gem install coast
176
176
  $ gem unpack coast
177
177
  $ cd coast-[VERSION]
178
178
  $ bundle
179
- $ mt
179
+ $ bundle exec mt
180
180
  ```
181
181
 
182
182
  Ahh... passing tests.
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
@@ -1,3 +1,3 @@
1
1
  module Coast
2
- VERSION = "0.9.8"
2
+ VERSION = "0.9.9"
3
3
  end
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.8
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-15 00:00:00.000000000 Z
12
+ date: 2013-01-28 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport