radiant-forms-extension 3.2.2 → 3.2.4
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/app/controllers/forms_controller.rb +8 -0
- data/config/routes.rb +1 -1
- data/forms_extension.rb +1 -1
- data/lib/forms/tags/core.rb +50 -19
- data/radiant-forms-extension.gemspec +2 -2
- data/spec/controllers/forms_controller_spec.rb +16 -0
- data/spec/lib/forms/tags/core_spec.rb +12 -0
- data/spec/spec.opts +1 -2
- metadata +4 -4
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
3.2.
|
1
|
+
3.2.4
|
@@ -4,10 +4,18 @@ class FormsController < ApplicationController
|
|
4
4
|
|
5
5
|
skip_before_filter :verify_authenticity_token
|
6
6
|
|
7
|
+
def new
|
8
|
+
@response = find_or_create_response
|
9
|
+
@response.update_attribute(:result, nil)
|
10
|
+
|
11
|
+
redirect_to :back
|
12
|
+
end
|
13
|
+
|
7
14
|
def update
|
8
15
|
@page = Page.find(params[:page_id]) rescue Page.first
|
9
16
|
@page.data = params
|
10
17
|
@page.request = OpenStruct.new({
|
18
|
+
:referrer => request.referer,
|
11
19
|
:session => session # Creating a pretend response object
|
12
20
|
})
|
13
21
|
|
data/config/routes.rb
CHANGED
data/forms_extension.rb
CHANGED
data/lib/forms/tags/core.rb
CHANGED
@@ -179,13 +179,25 @@ module Forms
|
|
179
179
|
desc %{
|
180
180
|
Allows access to the response of a submitted form
|
181
181
|
@<r:response>...<r:get /><r:clear />...</r:response>@
|
182
|
-
|
183
|
-
_Will not expand if a form has not been submitted or has been cleared_
|
184
182
|
}
|
185
183
|
tag 'response' do |tag|
|
186
184
|
tag.locals.response = Forms::Tags::Responses.current(tag,request)
|
187
185
|
|
188
|
-
tag.expand
|
186
|
+
tag.expand
|
187
|
+
end
|
188
|
+
|
189
|
+
desc %{
|
190
|
+
Expands if a response object exists in the user session
|
191
|
+
}
|
192
|
+
tag 'response:if_response' do |tag|
|
193
|
+
tag.expand if tag.locals.response.present? and tag.locals.response.results.present?
|
194
|
+
end
|
195
|
+
|
196
|
+
desc %{
|
197
|
+
Expands unless a response object exists in the user session
|
198
|
+
}
|
199
|
+
tag 'response:unless_response' do |tag|
|
200
|
+
tag.expand if tag.locals.response.blank? or tag.locals.response.results.blank?
|
189
201
|
end
|
190
202
|
|
191
203
|
desc %{
|
@@ -194,58 +206,77 @@ module Forms
|
|
194
206
|
@<r:response:clear />@
|
195
207
|
}
|
196
208
|
tag 'response:clear' do |tag|
|
197
|
-
|
209
|
+
if tag.locals.response.present? and tag.locals.response.result.present?
|
210
|
+
Forms::Tags::Responses.clear(tag)
|
211
|
+
end
|
198
212
|
|
199
|
-
|
213
|
+
tag.expand
|
200
214
|
end
|
201
215
|
|
202
216
|
desc %{ Expand if there is a response to a specified for value }
|
203
217
|
tag 'response:if_results' do |tag|
|
204
218
|
extension = tag.attr['extension'].to_sym
|
205
|
-
|
206
|
-
|
207
|
-
|
219
|
+
if tag.locals.response.result.present?
|
220
|
+
tag.locals.response_extension = tag.locals.response.result[:results][extension]
|
221
|
+
|
222
|
+
if tag.locals.response_extension.present?
|
223
|
+
tag.expand
|
224
|
+
end
|
225
|
+
end
|
208
226
|
end
|
209
227
|
|
210
228
|
desc %{ Expand if there is a response to a specified for value }
|
211
229
|
tag 'response:unless_results' do |tag|
|
212
230
|
extension = tag.attr['extension'].to_sym
|
213
|
-
tag.locals.response_extension = tag.locals.response.result[:results][extension]
|
214
231
|
|
215
|
-
|
232
|
+
unless tag.locals.response.result.present?
|
233
|
+
tag.expand
|
234
|
+
else
|
235
|
+
tag.locals.response_extension = tag.locals.response.result[:results][extension]
|
236
|
+
|
237
|
+
unless tag.locals.response_extension.present?
|
238
|
+
tag.expand
|
239
|
+
end
|
240
|
+
end
|
216
241
|
end
|
217
242
|
|
218
243
|
desc %{ Expand if there is a positive response to a specified for value of an extension
|
219
244
|
|
220
245
|
<pre>
|
221
|
-
<r:response:if_get extension='bogus_gateway'
|
246
|
+
<r:response:if_get extension='bogus_gateway' name='checkout'>yay</r:response:if_get>
|
222
247
|
</pre>
|
223
248
|
}
|
224
249
|
tag 'response:if_get' do |tag|
|
225
|
-
|
226
|
-
|
250
|
+
if tag.locals.response_extension.present?
|
251
|
+
query = tag.attr['name'].to_sym
|
252
|
+
result = tag.locals.response_extension[query]
|
227
253
|
|
228
|
-
|
254
|
+
tag.expand if result.present? and result === true
|
255
|
+
end
|
229
256
|
end
|
230
257
|
|
231
258
|
desc %{ Expand if there is a negative response to a specified for value of an extension
|
232
259
|
|
233
260
|
<pre>
|
234
|
-
<r:response:unless_get extension='bogus_gateway'
|
261
|
+
<r:response:unless_get extension='bogus_gateway' name='checkout'>no</r:response:unless_get>
|
235
262
|
</pre>
|
236
263
|
}
|
237
264
|
tag 'response:unless_get' do |tag|
|
238
|
-
|
239
|
-
|
265
|
+
if tag.locals.response_extension.present?
|
266
|
+
query = tag.attr['name'].to_sym
|
267
|
+
result = tag.locals.response_extension[query]
|
240
268
|
|
241
|
-
|
269
|
+
tag.expand if !result.present? or result != true
|
270
|
+
else
|
271
|
+
tag.expand
|
272
|
+
end
|
242
273
|
end
|
243
274
|
|
244
275
|
desc %{
|
245
276
|
Access the attributes of a submitted form.
|
246
277
|
|
247
278
|
@<r:response:get name="object[value]" />@ an object which was submitted with the form
|
248
|
-
@<r:response:get name="
|
279
|
+
@<r:response:get name="results[mail][value]" />@ a response to the mail extension hooking the form
|
249
280
|
|
250
281
|
_Refer to the readme on extensions to find out what they return_
|
251
282
|
}
|
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{radiant-forms-extension}
|
8
|
-
s.version = "3.2.
|
8
|
+
s.version = "3.2.4"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["dirkkelly"]
|
12
|
-
s.date = %q{2010-10-
|
12
|
+
s.date = %q{2010-10-26}
|
13
13
|
s.description = %q{Send data from a page to a form handler, extendable with addons}
|
14
14
|
s.email = %q{dirk.kelly@squaretalent.com}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -3,6 +3,22 @@ require File.dirname(__FILE__) + '/../spec_helper'
|
|
3
3
|
describe FormsController do
|
4
4
|
dataset :pages, :forms
|
5
5
|
|
6
|
+
context '#new' do
|
7
|
+
|
8
|
+
it 'should redirect to :back' do
|
9
|
+
request.env['HTTP_REFERER'] = '/back'
|
10
|
+
@object = Object.new
|
11
|
+
stub(@object).result = { :some => 'array'}
|
12
|
+
|
13
|
+
mock(controller).find_or_create_response { @object }
|
14
|
+
mock(@object).update_attribute(:result, nil)
|
15
|
+
|
16
|
+
get :new
|
17
|
+
|
18
|
+
response.should redirect_to("/back")
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
6
22
|
context '#create' do
|
7
23
|
|
8
24
|
before :each do
|
@@ -26,6 +26,8 @@ describe Forms::Tags::Core do
|
|
26
26
|
'form:read:each',
|
27
27
|
|
28
28
|
'response',
|
29
|
+
'response:if_response',
|
30
|
+
'response:unless_response',
|
29
31
|
'response:clear',
|
30
32
|
'response:get',
|
31
33
|
'response:if_results',
|
@@ -174,6 +176,15 @@ describe Forms::Tags::Core do
|
|
174
176
|
end
|
175
177
|
|
176
178
|
describe 'unless_results' do
|
179
|
+
context 'response result does not exist' do
|
180
|
+
it 'should render' do
|
181
|
+
@response.result = nil
|
182
|
+
|
183
|
+
tag = %{<r:response:unless_results extension='bogus'>success</r:response:unless_results>}
|
184
|
+
exp = %{success}
|
185
|
+
@page.should render(tag).as(exp)
|
186
|
+
end
|
187
|
+
end
|
177
188
|
context 'extension did not send results' do
|
178
189
|
it 'should render' do
|
179
190
|
tag = %{<r:response:unless_results extension='bogus'>success</r:response:unless_results>}
|
@@ -190,6 +201,7 @@ describe Forms::Tags::Core do
|
|
190
201
|
@page.should render(tag).as(exp)
|
191
202
|
end
|
192
203
|
end
|
204
|
+
|
193
205
|
end
|
194
206
|
|
195
207
|
describe 'if_get' do
|
data/spec/spec.opts
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: radiant-forms-extension
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 7
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 3
|
8
8
|
- 2
|
9
|
-
-
|
10
|
-
version: 3.2.
|
9
|
+
- 4
|
10
|
+
version: 3.2.4
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- dirkkelly
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-10-
|
18
|
+
date: 2010-10-26 00:00:00 +08:00
|
19
19
|
default_executable:
|
20
20
|
dependencies: []
|
21
21
|
|