noodall-form-builder 0.3.2 → 0.3.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -10,15 +10,15 @@ module Noodall
10
10
  @form = Noodall::Form.find(params[:form_id])
11
11
 
12
12
  @form_response = @form.responses.build(params[:form_response])
13
-
13
+
14
14
  #If the form response hasn't been constructed properly (i.e. a random spam POST)
15
- raise MongoMapper::DocumentNotFound, "Form response does not match form" unless @form_response.correct_fields?
16
-
15
+ #raise MongoMapper::DocumentNotFound, "Form response does not match form" unless @form_response.correct_fields?
16
+
17
17
  @form_response.ip = request.remote_ip
18
18
  @form_response.referrer = request.referer if @form_response.referrer.blank?
19
19
  @form_response.created_at = Time.zone.now
20
20
 
21
- respond_to do |format|
21
+ respond_to do |format|
22
22
  if @form_response.valid? and @form_response.save
23
23
  if @form_response.is_spam?
24
24
  logger.info "Form response was deemed to be spam: #{@form_response.inspect}"
@@ -36,12 +36,12 @@ Feature: Form Module
36
36
 
37
37
  Then the email address of the form should receive an email detailing the information submitted
38
38
  And they should receive an email confirming the request has been sent
39
-
40
- Scenario: Bad data is POSTed
41
- Given content exists with a form added via the contact module
42
- Then some random fields are POSTed by a spam bot
39
+
40
+ #Scenario: Bad data is POSTed
41
+ #Given content exists with a form added via the contact module
42
+ #Then some random fields are POSTed by a spam bot
43
43
  #todo - better way to structure this feature?
44
-
44
+
45
45
  Scenario: Validation
46
46
  Given content exists with a form added via the contact module
47
47
  When a website visitor visits the content
@@ -88,7 +88,10 @@ end
88
88
 
89
89
  Then /^I should see the form I selected$/ do
90
90
  @_form.fields.each do |field|
91
- page.should have_selector("label[for=form_response_#{field.underscored_name}]")
91
+ case field.class
92
+ when Noodall::TextField
93
+ page.should have_selector("label[for=form_response_#{field.underscored_name}]")
94
+ end
92
95
  end
93
96
  end
94
97
 
@@ -117,7 +120,9 @@ When /^they fill in and submit the form$/ do
117
120
  if field.name == 'Email'
118
121
  fill_in "form_response[#{field.underscored_name}]", :with => 'hello@example.com'
119
122
  else
120
- fill_in "form_response[#{field.underscored_name}]", :with => 'Weopunggggggggst'
123
+ if field.class == Noodall::TextField
124
+ fill_in "form_response[#{field.underscored_name}]", :with => 'Weopunggggggggst'
125
+ end
121
126
  end
122
127
  end
123
128
 
@@ -1,5 +1,5 @@
1
1
  module Noodall
2
2
  module FormBuilder
3
- VERSION = "0.3.2"
3
+ VERSION = "0.3.3"
4
4
  end
5
5
  end
@@ -10,6 +10,7 @@ Factory.define :select_field, :parent => :field, :class => Noodall::Select do |f
10
10
  field.default "Two"
11
11
  end
12
12
  Factory.define :radio_field, :parent => :select_field, :class => Noodall::Radio do |field|
13
+ field.options "One,Two,Three"
13
14
  end
14
15
  Factory.define :check_box_field, :parent => :field, :class => Noodall::CheckBox do |field|
15
16
  end
@@ -7,6 +7,10 @@ Factory.define :form, :class => Noodall::Form do |form|
7
7
  5.times do
8
8
  fields << Factory(:text_field)
9
9
  end
10
+ fields << Factory(:check_box_field)
11
+ fields << Factory(:select_field)
12
+ fields << Factory(:check_box_field)
13
+ fields << Factory(:radio_field)
10
14
 
11
15
  fields
12
16
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: noodall-form-builder
3
3
  version: !ruby/object:Gem::Version
4
- hash: 23
4
+ hash: 21
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 3
9
- - 2
10
- version: 0.3.2
9
+ - 3
10
+ version: 0.3.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - Steve England
@@ -17,13 +17,12 @@ autorequire:
17
17
  bindir: bin
18
18
  cert_chain: []
19
19
 
20
- date: 2011-07-18 00:00:00 +01:00
20
+ date: 2011-07-19 00:00:00 +01:00
21
21
  default_executable:
22
22
  dependencies:
23
23
  - !ruby/object:Gem::Dependency
24
- prerelease: false
25
- type: :development
26
- requirement: &id001 !ruby/object:Gem::Requirement
24
+ name: bundler
25
+ version_requirements: &id001 !ruby/object:Gem::Requirement
27
26
  none: false
28
27
  requirements:
29
28
  - - ">="
@@ -34,12 +33,12 @@ dependencies:
34
33
  - 0
35
34
  - 0
36
35
  version: 1.0.0
37
- version_requirements: *id001
38
- name: bundler
39
- - !ruby/object:Gem::Dependency
36
+ type: :development
40
37
  prerelease: false
41
- type: :runtime
42
- requirement: &id002 !ruby/object:Gem::Requirement
38
+ requirement: *id001
39
+ - !ruby/object:Gem::Dependency
40
+ name: fastercsv
41
+ version_requirements: &id002 !ruby/object:Gem::Requirement
43
42
  none: false
44
43
  requirements:
45
44
  - - ">="
@@ -48,8 +47,9 @@ dependencies:
48
47
  segments:
49
48
  - 0
50
49
  version: "0"
51
- version_requirements: *id002
52
- name: fastercsv
50
+ type: :runtime
51
+ prerelease: false
52
+ requirement: *id002
53
53
  description: Functionality for building custom forms
54
54
  email: []
55
55
 
@@ -206,7 +206,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
206
206
  requirements: []
207
207
 
208
208
  rubyforge_project:
209
- rubygems_version: 1.5.1
209
+ rubygems_version: 1.4.1
210
210
  signing_key:
211
211
  specification_version: 3
212
212
  summary: Noodall Form Builder