radiant-forms-extension 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (43) hide show
  1. data/.gitignore +3 -0
  2. data/README.md +117 -0
  3. data/Rakefile +137 -0
  4. data/VERSION +1 -0
  5. data/app/controllers/admin/forms_controller.rb +10 -0
  6. data/app/controllers/forms_controller.rb +35 -0
  7. data/app/models/form.rb +5 -0
  8. data/app/models/form_page.rb +7 -0
  9. data/app/models/response.rb +11 -0
  10. data/app/views/admin/forms/_fields.html.haml +56 -0
  11. data/app/views/admin/forms/_filters.html.haml +7 -0
  12. data/app/views/admin/forms/_form.html.haml +6 -0
  13. data/app/views/admin/forms/_header.html.haml +3 -0
  14. data/app/views/admin/forms/edit.html.haml +15 -0
  15. data/app/views/admin/forms/index.html.haml +20 -0
  16. data/app/views/admin/forms/new.html.haml +15 -0
  17. data/app/views/admin/forms/remove.html.haml +20 -0
  18. data/config/locales/en.yml +3 -0
  19. data/config/routes.rb +9 -0
  20. data/cucumber.yml +1 -0
  21. data/db/migrate/001_create_forms.rb +16 -0
  22. data/db/migrate/002_create_user_observer.rb +15 -0
  23. data/db/migrate/003_rename_output_to_content.rb +9 -0
  24. data/db/migrate/004_create_responses.rb +13 -0
  25. data/forms_extension.rb +24 -0
  26. data/lib/forms/admin_ui.rb +23 -0
  27. data/lib/forms/application_controller_extensions.rb +20 -0
  28. data/lib/forms/extension_methods.rb +14 -0
  29. data/lib/forms/page_extensions.rb +6 -0
  30. data/lib/forms/site_controller_extensions.rb +19 -0
  31. data/lib/forms/tags.rb +277 -0
  32. data/lib/tasks/forms_extension_tasks.rake +55 -0
  33. data/public/images/admin/extensions/form/form.png +0 -0
  34. data/radiant-forms-extension.gemspec +87 -0
  35. data/spec/controllers/forms_controller_spec.rb +150 -0
  36. data/spec/datasets/forms.rb +30 -0
  37. data/spec/lib/forms/extension_methods_spec.rb +41 -0
  38. data/spec/lib/forms/tags_spec.rb +122 -0
  39. data/spec/models/form_spec.rb +40 -0
  40. data/spec/models/response_spec.rb +31 -0
  41. data/spec/spec.opts +7 -0
  42. data/spec/spec_helper.rb +18 -0
  43. metadata +102 -0
@@ -0,0 +1,122 @@
1
+ require File.dirname(__FILE__) + '/../../spec_helper'
2
+
3
+ describe Forms::Tags do
4
+ dataset :pages, :forms
5
+
6
+ context 'form output' do
7
+
8
+ before :all do
9
+ @form = forms(:test)
10
+ @page = pages(:home)
11
+ end
12
+
13
+ describe '<r:form>' do
14
+ it 'should render the correct HTML' do
15
+ tag = %{<r:form name="#{@form.title}" />}
16
+
17
+ expected = %{<form enctype="multipart/form-data" name="#{@form.title}" method="post" action="/forms/#{@form.id}" id="form_test_form">
18
+ <input type="hidden" name="page_id" value="#{@page.id}" />
19
+ <input type="hidden" name="form_id" value="#{@form.id}" />
20
+ <input type="text" value="" name="request[test]" class="text" id="request_test" /></form>}
21
+
22
+ @page.should render(tag).as(expected)
23
+ end
24
+ end
25
+
26
+ describe '<r:form:label>' do
27
+
28
+ it 'should render the correct HTML' do
29
+ tag = %{<r:form:label for="test[field]">text</r:form:label>}
30
+ expected = %{<label id="test_field_label" for="test_field">text</label>}
31
+ @page.should render(tag).as(expected)
32
+ end
33
+
34
+ it 'should require the name attribute' do
35
+ tag = %{<r:form:label />}
36
+ @page.should_not render(tag)
37
+ end
38
+
39
+ end
40
+
41
+ %w(text password reset checkbox radio hidden file button).each do |type|
42
+
43
+ describe "<r:form:#{type}>" do
44
+
45
+ it 'should render the correct HTML' do
46
+ tag = %{<r:form:#{type} name="test[field]">text</r:form:#{type}>}
47
+ expected = %{<input type="#{type}" value="" name="test[field]" class="#{type}" id="test_field" />}
48
+ @page.should render(tag).as(expected)
49
+ end
50
+
51
+ it 'should require the name attribute' do
52
+ tag = %{<r:form:#{type} />}
53
+ @page.should_not render(tag)
54
+ end
55
+
56
+ end
57
+
58
+ end
59
+
60
+ describe '<r:form:select>' do
61
+
62
+ it 'should render the correct HTML' do
63
+ tag = %{<r:form:select name="test[field]" />}
64
+ expected = %{<select name="test[field]" id="test_field"></select>}
65
+ @page.should render(tag).as(expected)
66
+ end
67
+
68
+ it 'should render correct options HTML' do
69
+ tag = %{<r:form:select name="test[field]"><r:option value="one" /><r:option value="two">three</r:option></r:form:select>}
70
+ expected = %{<select name="test[field]" id="test_field"><option value="one">one</option><option value="two">three</option></select>}
71
+ @page.should render(tag).as(expected)
72
+ end
73
+
74
+ it 'should require the name attribute' do
75
+ tag = %{<r:form:select />}
76
+ @page.should_not render(tag)
77
+ end
78
+
79
+ end
80
+
81
+ describe '<r:form:radios>' do
82
+
83
+ it 'should render the correct HTML' do
84
+ tag = %{<r:form:radios name="test[field]" />}
85
+ expected = %{}
86
+ @page.should render(tag).as(expected)
87
+ end
88
+
89
+ it 'should render correct options HTML' do
90
+ tag = %{<r:form:radios name="test[field]"><r:option value="one" /><r:option value="two" /></r:form:radios>}
91
+ expected = %{<input name="test[field]" id="test_field_one" type="radio" value="one" /><input name="test[field]" id="test_field_two" type="radio" value="two" />}
92
+ @page.should render(tag).as(expected)
93
+ end
94
+
95
+ it 'should require the name attribute' do
96
+ tag = %{<r:form:radios />}
97
+ @page.should_not render(tag)
98
+ end
99
+
100
+ end
101
+
102
+ describe '<r:form:submit>' do
103
+
104
+ it 'should render the correct HTML' do
105
+
106
+ end
107
+
108
+ end
109
+
110
+ end
111
+
112
+ context 'form hooking' do
113
+
114
+
115
+ end
116
+
117
+ context 'form response' do
118
+
119
+ end
120
+
121
+
122
+ end
@@ -0,0 +1,40 @@
1
+ require File.dirname(__FILE__) + '/../spec_helper'
2
+
3
+ describe Form do
4
+ dataset :forms
5
+
6
+ describe '#attributes' do
7
+
8
+ before :all do
9
+ @form = forms(:test)
10
+ end
11
+
12
+ it 'should have a title string' do
13
+ @form.title.is_a?(String).should == true
14
+ end
15
+
16
+ it 'should have an action string' do
17
+ @form.action = ''
18
+ @form.action.is_a?(String).should == true
19
+ end
20
+
21
+ it 'should have a redirect_to string' do
22
+ @form.redirect_to = ''
23
+ @form.redirect_to.is_a?(String).should == true
24
+ end
25
+
26
+ it 'should have a body string' do
27
+ @form.body.is_a?(String).should == true
28
+ end
29
+
30
+ it 'should have an content string' do
31
+ @form.content.is_a?(String).should == true
32
+ end
33
+
34
+ it 'should have a config string' do
35
+ @form.config.is_a?(String).should == true
36
+ end
37
+
38
+ end
39
+
40
+ end
@@ -0,0 +1,31 @@
1
+ require File.dirname(__FILE__) + '/../spec_helper'
2
+
3
+ describe Response do
4
+
5
+ before :each do
6
+ @response = Response.new
7
+ @object = { 'test' => 'test' }
8
+ end
9
+
10
+ context 'setting' do
11
+
12
+ it 'should store an object' do
13
+ @response.result.should be_nil
14
+ @response.result = @object
15
+ @response.result.should_not be_nil
16
+ end
17
+
18
+ it 'should return an object' do
19
+ @response.result_json = @object.to_json
20
+ @response.result.should_not be_nil
21
+ @response.result == @object
22
+ end
23
+
24
+ it 'should set and return the same object' do
25
+ @response.result = @object
26
+ @response.result.should == @object
27
+ end
28
+
29
+ end
30
+
31
+ end
data/spec/spec.opts ADDED
@@ -0,0 +1,7 @@
1
+ --colour
2
+ --format
3
+ progress
4
+ --loadby
5
+ mtime
6
+ --reverse
7
+ --debugger
@@ -0,0 +1,18 @@
1
+ unless defined? RADIANT_ROOT
2
+ ENV["RAILS_ENV"] = "test"
3
+ case
4
+ when ENV["RADIANT_ENV_FILE"]
5
+ require ENV["RADIANT_ENV_FILE"]
6
+ when File.dirname(__FILE__) =~ %r{vendor/radiant/vendor/extensions}
7
+ require "#{File.expand_path(File.dirname(__FILE__) + "/../../../../../../")}/config/environment"
8
+ else
9
+ require "#{File.expand_path(File.dirname(__FILE__) + "/../../../../")}/config/environment"
10
+ end
11
+ end
12
+ require "#{RADIANT_ROOT}/spec/spec_helper"
13
+
14
+ Dataset::Resolver.default << (File.dirname(__FILE__) + "/datasets")
15
+
16
+ Spec::Runner.configure do |config|
17
+ config.mock_with :rr
18
+ end
metadata ADDED
@@ -0,0 +1,102 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: radiant-forms-extension
3
+ version: !ruby/object:Gem::Version
4
+ version: 2.0.0
5
+ platform: ruby
6
+ authors:
7
+ - dirkkelly
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2010-08-02 00:00:00 +08:00
13
+ default_executable:
14
+ dependencies: []
15
+
16
+ description: Send data from a page to a form handler, extendable with addons
17
+ email: dirk.kelly@squaretalent.com
18
+ executables: []
19
+
20
+ extensions: []
21
+
22
+ extra_rdoc_files:
23
+ - README.md
24
+ files:
25
+ - .gitignore
26
+ - README.md
27
+ - Rakefile
28
+ - VERSION
29
+ - app/controllers/admin/forms_controller.rb
30
+ - app/controllers/forms_controller.rb
31
+ - app/models/form.rb
32
+ - app/models/form_page.rb
33
+ - app/models/response.rb
34
+ - app/views/admin/forms/_fields.html.haml
35
+ - app/views/admin/forms/_filters.html.haml
36
+ - app/views/admin/forms/_form.html.haml
37
+ - app/views/admin/forms/_header.html.haml
38
+ - app/views/admin/forms/edit.html.haml
39
+ - app/views/admin/forms/index.html.haml
40
+ - app/views/admin/forms/new.html.haml
41
+ - app/views/admin/forms/remove.html.haml
42
+ - config/locales/en.yml
43
+ - config/routes.rb
44
+ - cucumber.yml
45
+ - db/migrate/001_create_forms.rb
46
+ - db/migrate/002_create_user_observer.rb
47
+ - db/migrate/003_rename_output_to_content.rb
48
+ - db/migrate/004_create_responses.rb
49
+ - forms_extension.rb
50
+ - lib/forms/admin_ui.rb
51
+ - lib/forms/application_controller_extensions.rb
52
+ - lib/forms/extension_methods.rb
53
+ - lib/forms/page_extensions.rb
54
+ - lib/forms/site_controller_extensions.rb
55
+ - lib/forms/tags.rb
56
+ - lib/tasks/forms_extension_tasks.rake
57
+ - public/images/admin/extensions/form/form.png
58
+ - radiant-forms-extension.gemspec
59
+ - spec/controllers/forms_controller_spec.rb
60
+ - spec/datasets/forms.rb
61
+ - spec/lib/forms/extension_methods_spec.rb
62
+ - spec/lib/forms/tags_spec.rb
63
+ - spec/models/form_spec.rb
64
+ - spec/models/response_spec.rb
65
+ - spec/spec.opts
66
+ - spec/spec_helper.rb
67
+ has_rdoc: true
68
+ homepage: http://github.com/squaretalent/radiant-forms-extension
69
+ licenses: []
70
+
71
+ post_install_message:
72
+ rdoc_options:
73
+ - --charset=UTF-8
74
+ require_paths:
75
+ - lib
76
+ required_ruby_version: !ruby/object:Gem::Requirement
77
+ requirements:
78
+ - - ">="
79
+ - !ruby/object:Gem::Version
80
+ version: "0"
81
+ version:
82
+ required_rubygems_version: !ruby/object:Gem::Requirement
83
+ requirements:
84
+ - - ">="
85
+ - !ruby/object:Gem::Version
86
+ version: "0"
87
+ version:
88
+ requirements: []
89
+
90
+ rubyforge_project:
91
+ rubygems_version: 1.3.5
92
+ signing_key:
93
+ specification_version: 3
94
+ summary: Forms Extension for Radiant CMS
95
+ test_files:
96
+ - spec/controllers/forms_controller_spec.rb
97
+ - spec/datasets/forms.rb
98
+ - spec/lib/forms/extension_methods_spec.rb
99
+ - spec/lib/forms/tags_spec.rb
100
+ - spec/models/form_spec.rb
101
+ - spec/models/response_spec.rb
102
+ - spec/spec_helper.rb