statesman 0.8.0 → 0.8.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 22f3c63fa8f737d3fbaef505d2329bd8e0ed1183
4
- data.tar.gz: ef478f905d16dc128d8ddeaefbf52ccce0731938
3
+ metadata.gz: 8e2492b67d3e6a95fa6a91b704073a73834f2044
4
+ data.tar.gz: 557ecfbe2b21238c38c12ece93296e0faf5f3869
5
5
  SHA512:
6
- metadata.gz: 810023ee4183eeb404a4ed5cee4d933d45590ab4eaf3a30864fb15181ac8d8de8e9ff0f7ed50a36ecad0e7414d303da750b824cd29d5984d95dfa3095eb93411
7
- data.tar.gz: 0a83338cf2ab14661eef2fca42ee08511fc9e27538965e5b1213843492efd8bb24aa7bb442ae4b830917a87dba30dd581e434e5d70538054b08560ad6d41aac1
6
+ metadata.gz: 052ef370bf131a2772a3f35644872cb13c29c06d7f5153c175853e94c791ab9095ceabf480fb58b8afb056eab69f268f3e0ce4eb6fc48001ceef7821a58191d9
7
+ data.tar.gz: d7d13cc58202b83c95a6ec3fba0faf9e6842c959e6b0d43cf21c783af1aca0c8b6a66c3e51e68d684e9c3439d3b0ece04c6c6090b31d29541cb7392461f20f1a
data/CHANGELOG.md CHANGED
@@ -1,3 +1,8 @@
1
+ ## v0.8.1 19 August 2014
2
+ *Fixes*
3
+
4
+ - Adds check in Machine#transition to make sure the 'to' state is not an empty array (patch by [@barisbalic](https://github.com/barisbalic))
5
+
1
6
  ## v0.8.0 29 June 2014
2
7
  *Additions*
3
8
 
data/README.md CHANGED
@@ -199,6 +199,23 @@ class Order < ActiveRecord::Base
199
199
  to: :state_machine
200
200
  end
201
201
  ```
202
+ #### Using PostgreSQL JSON column
203
+
204
+ By default, Statesman uses `serialize` to store the metadata in JSON format.
205
+ It is also possible to use the PostgreSQL JSON column if you are using Rails 4. To do that
206
+
207
+ * Change `metadata` column type in the transition model migration to `json`
208
+
209
+ ```ruby
210
+ # Before
211
+ t.text :metadata, default: "{}"
212
+ # After
213
+ t.json :metadata, default: "{}"
214
+ ```
215
+
216
+ * Remove `include Statesman::Adapters::ActiveRecordTransition` statement from your
217
+ transition model
218
+
202
219
 
203
220
  ## Configuration
204
221
 
@@ -66,6 +66,8 @@ module Statesman
66
66
  from = to_s_or_nil(options[:from])
67
67
  to = Array(options[:to]).map { |item| to_s_or_nil(item) }
68
68
 
69
+ raise InvalidStateError, "No to states provided." if to.empty?
70
+
69
71
  successors[from] ||= []
70
72
 
71
73
  ([from] + to).each { |state| validate_state(state) }
@@ -1,3 +1,3 @@
1
1
  module Statesman
2
- VERSION = "0.8.0"
2
+ VERSION = "0.8.1"
3
3
  end
@@ -114,6 +114,30 @@ describe Statesman::Machine do
114
114
  end
115
115
  end
116
116
 
117
+ context "given no 'from' state and a valid 'to' state" do
118
+ it "raises an error" do
119
+ expect do
120
+ machine.transition from: nil, to: :x
121
+ end.to raise_error(Statesman::InvalidStateError)
122
+ end
123
+ end
124
+
125
+ context "given a valid 'from' state and a no 'to' state" do
126
+ it "raises an error" do
127
+ expect do
128
+ machine.transition from: :x, to: nil
129
+ end.to raise_error(Statesman::InvalidStateError)
130
+ end
131
+ end
132
+
133
+ context "given a valid 'from' state and an empty 'to' state array" do
134
+ it "raises an error" do
135
+ expect do
136
+ machine.transition from: :x, to: []
137
+ end.to raise_error(Statesman::InvalidStateError)
138
+ end
139
+ end
140
+
117
141
  context "given an invalid 'from' state" do
118
142
  it "raises an error" do
119
143
  expect do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: statesman
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.0
4
+ version: 0.8.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Harry Marr
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-07-29 00:00:00.000000000 Z
12
+ date: 2014-08-19 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler