tb_inquiries 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/MIT-LICENSE +20 -0
- data/README.markdown +76 -0
- data/Rakefile +28 -0
- data/app/assets/images/spud/admin/contacts_thumb.png +0 -0
- data/app/assets/javascripts/spud/admin/inquiries.js +8 -0
- data/app/assets/javascripts/spud/inquiries/sitemaps.js +2 -0
- data/app/assets/stylesheets/spud/admin/inquiries.css +4 -0
- data/app/assets/stylesheets/spud/inquiries/sitemaps.css +4 -0
- data/app/controllers/contacts_controller.rb +82 -0
- data/app/controllers/spud/admin/inquiries_controller.rb +38 -0
- data/app/controllers/spud/admin/inquiry_forms_controller.rb +58 -0
- data/app/controllers/spud/inquiries/sitemaps_controller.rb +7 -0
- data/app/helpers/contacts_helper.rb +3 -0
- data/app/mailers/spud/inquiry_mailer.rb +10 -0
- data/app/models/spud_inquiry.rb +46 -0
- data/app/models/spud_inquiry_field.rb +13 -0
- data/app/models/spud_inquiry_form.rb +27 -0
- data/app/models/spud_inquiry_form_field.rb +21 -0
- data/app/views/contacts/_show.html.erb +45 -0
- data/app/views/contacts/show.html.erb +4 -0
- data/app/views/contacts/show.js.erb +1 -0
- data/app/views/contacts/thankyou.html.erb +2 -0
- data/app/views/contacts/thankyou.js.erb +1 -0
- data/app/views/layouts/spud/inquiries/detail.html.erb +6 -0
- data/app/views/spud/admin/inquiries/index.html.erb +30 -0
- data/app/views/spud/admin/inquiries/show.html.erb +8 -0
- data/app/views/spud/admin/inquiry_forms/_form.html.erb +52 -0
- data/app/views/spud/admin/inquiry_forms/_spud_inquiry_form_field_fields.html.erb +56 -0
- data/app/views/spud/admin/inquiry_forms/edit.html.erb +6 -0
- data/app/views/spud/admin/inquiry_forms/index.html.erb +22 -0
- data/app/views/spud/admin/inquiry_forms/new.html.erb +9 -0
- data/app/views/spud/inquiries/sitemaps/show.xml.builder +16 -0
- data/app/views/spud/inquiry_mailer/inquiry_notification.html.erb +15 -0
- data/app/views/spud/inquiry_mailer/inquiry_notification.text.erb +7 -0
- data/config/routes.rb +16 -0
- data/db/migrate/20120117133405_create_spud_inquiries.rb +8 -0
- data/db/migrate/20120117133412_create_spud_inquiry_fields.rb +13 -0
- data/db/migrate/20120121194439_create_spud_inquiry_forms.rb +9 -0
- data/db/migrate/20120121194447_create_spud_inquiry_form_fields.rb +12 -0
- data/db/migrate/20120122173829_add_field_order_to_spud_inquiry_form_fields.rb +7 -0
- data/db/migrate/20120126132407_add_spud_inquiry_form_id_to_spud_inquiries.rb +11 -0
- data/db/migrate/20120126132522_add_recipients_to_spud_inquiry_forms.rb +6 -0
- data/db/migrate/20120127023335_add_url_name_to_spud_inquiry_forms.rb +6 -0
- data/db/migrate/20120413124900_change_inquiry_form_fields_column.rb +9 -0
- data/db/migrate/20121228145215_add_thank_you_content_to_spud_inquiry_form.rb +5 -0
- data/db/migrate/20130627121030_add_placeholder_to_spud_inquiry_form_fields.rb +5 -0
- data/db/migrate/20131111143656_add_submit_title_to_spud_inquiry_form.rb +5 -0
- data/db/migrate/20131111143945_add_field_name_to_spud_inquiry_form_fields.rb +5 -0
- data/db/migrate/20131111144731_add_class_name_to_spud_inquiry_form_fields.rb +5 -0
- data/db/migrate/20131204163221_add_field_name_to_spud_inquiry_fields.rb +5 -0
- data/lib/spud_inquiries/configuration.rb +16 -0
- data/lib/spud_inquiries/engine.rb +28 -0
- data/lib/spud_inquiries/liquid_form.rb +47 -0
- data/lib/spud_inquiries/version.rb +5 -0
- data/lib/tasks/spud_inquiries_tasks.rake +4 -0
- data/lib/tb_inquiries.rb +7 -0
- data/spec/controllers/contacts_controller_spec.rb +69 -0
- data/spec/controllers/spud/admin/inquiries_controller_spec.rb +55 -0
- data/spec/controllers/spud/admin/inquiry_forms_controller_spec.rb +98 -0
- data/spec/controllers/spud/inquiries/sitemaps_controller_spec.rb +24 -0
- data/spec/dummy/README.rdoc +261 -0
- data/spec/dummy/Rakefile +7 -0
- data/spec/dummy/app/assets/javascripts/application.js +15 -0
- data/spec/dummy/app/assets/stylesheets/application.css +13 -0
- data/spec/dummy/app/controllers/application_controller.rb +3 -0
- data/spec/dummy/app/helpers/application_helper.rb +2 -0
- data/spec/dummy/app/views/layouts/application.html.erb +14 -0
- data/spec/dummy/config/application.rb +57 -0
- data/spec/dummy/config/boot.rb +10 -0
- data/spec/dummy/config/database.yml +9 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +37 -0
- data/spec/dummy/config/environments/production.rb +67 -0
- data/spec/dummy/config/environments/test.rb +44 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy/config/initializers/inflections.rb +15 -0
- data/spec/dummy/config/initializers/mime_types.rb +5 -0
- data/spec/dummy/config/initializers/secret_token.rb +8 -0
- data/spec/dummy/config/initializers/session_store.rb +8 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/spec/dummy/config/locales/en.yml +5 -0
- data/spec/dummy/config/routes.rb +3 -0
- data/spec/dummy/config.ru +4 -0
- data/spec/dummy/db/migrate/20120610131537_create_spud_admin_permissions.spud_core.rb +12 -0
- data/spec/dummy/db/migrate/20120610131538_create_spud_users.spud_core.rb +30 -0
- data/spec/dummy/db/migrate/20120610131539_add_time_zone_to_spud_user.spud_core.rb +7 -0
- data/spec/dummy/db/migrate/20120610131540_add_scope_to_spud_admin_permissions.spud_core.rb +7 -0
- data/spec/dummy/db/migrate/20120610131541_create_spud_user_settings.spud_core.rb +12 -0
- data/spec/dummy/db/migrate/20140109151036_create_spud_roles.tb_core.rb +11 -0
- data/spec/dummy/db/migrate/20140109151037_create_spud_permissions.tb_core.rb +11 -0
- data/spec/dummy/db/migrate/20140109151038_create_spud_role_permissions.tb_core.rb +12 -0
- data/spec/dummy/db/migrate/20140109151039_drop_spud_admin_permissions.tb_core.rb +16 -0
- data/spec/dummy/db/migrate/20140109151040_create_spud_inquiries.spud_inquiries.rb +9 -0
- data/spec/dummy/db/migrate/20140109151041_create_spud_inquiry_fields.spud_inquiries.rb +14 -0
- data/spec/dummy/db/migrate/20140109151042_create_spud_inquiry_forms.spud_inquiries.rb +10 -0
- data/spec/dummy/db/migrate/20140109151043_create_spud_inquiry_form_fields.spud_inquiries.rb +13 -0
- data/spec/dummy/db/migrate/20140109151044_add_field_order_to_spud_inquiry_form_fields.spud_inquiries.rb +8 -0
- data/spec/dummy/db/migrate/20140109151045_add_spud_inquiry_form_id_to_spud_inquiries.spud_inquiries.rb +12 -0
- data/spec/dummy/db/migrate/20140109151046_add_recipients_to_spud_inquiry_forms.spud_inquiries.rb +7 -0
- data/spec/dummy/db/migrate/20140109151047_add_url_name_to_spud_inquiry_forms.spud_inquiries.rb +7 -0
- data/spec/dummy/db/migrate/20140109151048_change_inquiry_form_fields_column.spud_inquiries.rb +10 -0
- data/spec/dummy/db/migrate/20140109151049_add_thank_you_content_to_spud_inquiry_form.spud_inquiries.rb +6 -0
- data/spec/dummy/db/migrate/20140109151050_add_placeholder_to_spud_inquiry_form_fields.spud_inquiries.rb +6 -0
- data/spec/dummy/db/migrate/20140109151051_add_submit_title_to_spud_inquiry_form.spud_inquiries.rb +6 -0
- data/spec/dummy/db/migrate/20140109151052_add_field_name_to_spud_inquiry_form_fields.spud_inquiries.rb +6 -0
- data/spec/dummy/db/migrate/20140109151053_add_class_name_to_spud_inquiry_form_fields.spud_inquiries.rb +6 -0
- data/spec/dummy/db/migrate/20140109151054_add_field_name_to_spud_inquiry_fields.spud_inquiries.rb +6 -0
- data/spec/dummy/db/migrate/20140110151647_create_tb_liquid_spud_liquid_tags.tb_liquid.rb +13 -0
- data/spec/dummy/db/schema.rb +143 -0
- data/spec/dummy/log/test.log +425 -0
- data/spec/dummy/public/404.html +26 -0
- data/spec/dummy/public/422.html +26 -0
- data/spec/dummy/public/500.html +25 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/dummy/script/rails +6 -0
- data/spec/models/spud_inquiry_field_spec.rb +18 -0
- data/spec/models/spud_inquiry_form_field_spec.rb +36 -0
- data/spec/models/spud_inquiry_form_spec.rb +28 -0
- data/spec/models/spud_inquiry_spec.rb +22 -0
- data/spec/spec_helper.rb +49 -0
- data/spec/support/authlogic_helper.rb +2 -0
- metadata +384 -0
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
<fieldset class="fields">
|
|
2
|
+
<hr/>
|
|
3
|
+
<div class="control-group">
|
|
4
|
+
<%=f.label :name,:class => "control-label"%>
|
|
5
|
+
<div class="controls">
|
|
6
|
+
<%=f.text_field :name, class: 'input-xxlarge'%>
|
|
7
|
+
</div>
|
|
8
|
+
</div>
|
|
9
|
+
<div class="control-group">
|
|
10
|
+
<%=f.label :field_type,:class => "control-label"%>
|
|
11
|
+
<div class="controls">
|
|
12
|
+
<%=f.select :field_type, [["Text Field",0],["Checkbox",1],["Text Area",2],["Dropdown",3],["Radio",4]]%>
|
|
13
|
+
</div>
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
</div>
|
|
17
|
+
<div class="control-group">
|
|
18
|
+
<%=f.label :placeholder,:class => "control-label"%>
|
|
19
|
+
<div class="controls">
|
|
20
|
+
<%=f.text_field :placeholder%>
|
|
21
|
+
</div>
|
|
22
|
+
</div>
|
|
23
|
+
<div class="control-group">
|
|
24
|
+
<%=f.label :options,:class => "control-label"%>
|
|
25
|
+
<div class="controls">
|
|
26
|
+
<%=f.text_field :options, class: 'input-xxlarge'%>
|
|
27
|
+
</div>
|
|
28
|
+
</div>
|
|
29
|
+
<div class="control-group">
|
|
30
|
+
<%=f.label :default_value,:class => "control-label"%>
|
|
31
|
+
<div class="controls">
|
|
32
|
+
<%=f.text_field :default_value%>
|
|
33
|
+
</div>
|
|
34
|
+
</div>
|
|
35
|
+
<div class="control-group">
|
|
36
|
+
<%=f.label :class_name,:class => "control-label"%>
|
|
37
|
+
<div class="controls">
|
|
38
|
+
<%=f.text_field :class_name, class: 'input-xxlarge'%>
|
|
39
|
+
</div>
|
|
40
|
+
</div>
|
|
41
|
+
<div class="control-group">
|
|
42
|
+
<%=f.label :field_order,:class => "control-label"%>
|
|
43
|
+
<div class="controls">
|
|
44
|
+
<%=f.text_field :field_order, class: 'input-xxlarge'%>
|
|
45
|
+
</div>
|
|
46
|
+
</div>
|
|
47
|
+
<div class="control-group">
|
|
48
|
+
<%=f.label :required,:class => "control-label"%>
|
|
49
|
+
<div class="controls">
|
|
50
|
+
<%=f.check_box :required%>
|
|
51
|
+
</div>
|
|
52
|
+
</div>
|
|
53
|
+
<div class="control-group">
|
|
54
|
+
<%= link_to_remove_fields "Remove", f %>
|
|
55
|
+
</div>
|
|
56
|
+
</fieldset>
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
<%=form_for @inquiry_form,:url => spud_admin_inquiry_form_path(@inquiry_form),:html=>{:class=>"form-horizontal"} do |f|%>
|
|
2
|
+
<%=render :partial => "form",:locals => {:f => f}%>
|
|
3
|
+
<div class="form-actions">
|
|
4
|
+
<%=f.submit "Save Form", :class=>"btn btn-primary","data-loading-text"=>"Saving..."%> or <%=link_to "cancel",spud_admin_inquiry_forms_path,:class => "btn"%>
|
|
5
|
+
</div>
|
|
6
|
+
<%end%>
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
<% content_for :data_controls do%>
|
|
2
|
+
<%=link_to "New Form",new_spud_admin_inquiry_form_path(),:class => "btn btn-primary",:title => "New Form"%>
|
|
3
|
+
<% end %>
|
|
4
|
+
|
|
5
|
+
<%=content_for :detail do%>
|
|
6
|
+
<div class="page_list">
|
|
7
|
+
<%@inquiry_forms.each do |inquiry_form|%>
|
|
8
|
+
<div class="page_row">
|
|
9
|
+
|
|
10
|
+
<span class="row_meta"><%=link_to inquiry_form.name,edit_spud_admin_inquiry_form_path(inquiry_form)%></span>
|
|
11
|
+
|
|
12
|
+
<span class="edit_controls">
|
|
13
|
+
<%=link_to "Edit",edit_spud_admin_inquiry_form_path(inquiry_form),:class => 'btn'%>
|
|
14
|
+
<%=link_to "Remove",spud_admin_inquiry_form_path(inquiry_form),:method => :delete,:class => 'btn btn-danger', :data => {:confirm => "Are you sure you want to remove this file?" }%></span>
|
|
15
|
+
<br style="clear:both;"/>
|
|
16
|
+
</div>
|
|
17
|
+
<%end%>
|
|
18
|
+
<%=will_paginate @inquiry_forms%>
|
|
19
|
+
|
|
20
|
+
</div>
|
|
21
|
+
|
|
22
|
+
<% end %>
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
<%=form_for @inquiry_form,:url => spud_admin_inquiry_forms_path(),:html=>{:class=>"form-horizontal"} do |f|%>
|
|
2
|
+
<%=render :partial => "form",:locals => {:f => f}%>
|
|
3
|
+
<div class="form-actions">
|
|
4
|
+
<%=f.submit "Create Form", :class=>"btn btn-primary","data-loading-text"=>"Saving..."%> or <%=link_to "cancel",spud_admin_inquiry_forms_path,:class => "btn"%>
|
|
5
|
+
</div>
|
|
6
|
+
<%end%>
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
|
|
2
|
+
xml.instruct! :xml, :version => '1.0', :encoding => 'UTF-8'
|
|
3
|
+
|
|
4
|
+
# create the urlset
|
|
5
|
+
xml.urlset :xmlns => 'http://www.sitemaps.org/schemas/sitemap/0.9' do
|
|
6
|
+
@forms.each do |form|
|
|
7
|
+
xml.url do
|
|
8
|
+
if form.url_name == Spud::Inquiries.default_contact_form
|
|
9
|
+
xml.loc contact_url()
|
|
10
|
+
else
|
|
11
|
+
xml.loc contact_url(:id => form.url_name)
|
|
12
|
+
end
|
|
13
|
+
xml.lastmod form.updated_at.strftime('%Y-%m-%d')
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html>
|
|
3
|
+
<head>
|
|
4
|
+
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type" />
|
|
5
|
+
</head>
|
|
6
|
+
<body>
|
|
7
|
+
<h2>Inquiry Received</h2>
|
|
8
|
+
|
|
9
|
+
<%@inquiry.spud_inquiry_fields.each do |field|%>
|
|
10
|
+
<p><strong><%=field.name%></strong>
|
|
11
|
+
<%=field.value%>
|
|
12
|
+
</p>
|
|
13
|
+
<%end%>
|
|
14
|
+
</body>
|
|
15
|
+
</html>
|
data/config/routes.rb
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
Rails.application.routes.draw do
|
|
2
|
+
namespace :spud do
|
|
3
|
+
namespace :admin do
|
|
4
|
+
resources :inquiries
|
|
5
|
+
resources :inquiry_forms
|
|
6
|
+
end
|
|
7
|
+
namespace :inquiries do
|
|
8
|
+
resource :sitemap,:only => [:show]
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
post "/contact/inquire" => "contacts#inquire"
|
|
12
|
+
get "/contact/thankyou" => "contacts#thankyou"
|
|
13
|
+
if Spud::Inquiries.enable_routes
|
|
14
|
+
get "/contact(/:id)" => "contacts#show", :as => :contact
|
|
15
|
+
end
|
|
16
|
+
end
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
class CreateSpudInquiryFields < ActiveRecord::Migration
|
|
2
|
+
def change
|
|
3
|
+
create_table :spud_inquiry_fields do |t|
|
|
4
|
+
t.string :name
|
|
5
|
+
t.text :value
|
|
6
|
+
t.integer :spud_inquiry_id
|
|
7
|
+
|
|
8
|
+
t.timestamps
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
add_index :spud_inquiry_fields,:spud_inquiry_id, :name => "inquiry_field_parent_id"
|
|
12
|
+
end
|
|
13
|
+
end
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
class CreateSpudInquiryFormFields < ActiveRecord::Migration
|
|
2
|
+
def change
|
|
3
|
+
create_table :spud_inquiry_form_fields do |t|
|
|
4
|
+
t.integer :spud_inquiry_form_id
|
|
5
|
+
t.string :field_type
|
|
6
|
+
t.string :name
|
|
7
|
+
t.string :options
|
|
8
|
+
t.string :default_value
|
|
9
|
+
t.timestamps
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
end
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
class AddFieldOrderToSpudInquiryFormFields < ActiveRecord::Migration
|
|
2
|
+
def change
|
|
3
|
+
add_column :spud_inquiry_form_fields, :field_order, :integer
|
|
4
|
+
add_column :spud_inquiry_form_fields, :required, :boolean
|
|
5
|
+
add_index :spud_inquiry_form_fields,:field_order, :name => "form_field_order"
|
|
6
|
+
end
|
|
7
|
+
end
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
class AddSpudInquiryFormIdToSpudInquiries < ActiveRecord::Migration
|
|
2
|
+
def change
|
|
3
|
+
add_column :spud_inquiries, :spud_inquiry_form_id, :integer
|
|
4
|
+
add_column :spud_inquiries, :recipients, :text
|
|
5
|
+
add_column :spud_inquiries, :subject,:string
|
|
6
|
+
add_column :spud_inquiries, :marked_as_read,:boolean,:default => false
|
|
7
|
+
|
|
8
|
+
add_index :spud_inquiries, :marked_as_read, :name => "idx_inquiry_read"
|
|
9
|
+
add_index :spud_inquiries, :spud_inquiry_form_id, :name => "idx_inquiry_form"
|
|
10
|
+
end
|
|
11
|
+
end
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
module Spud
|
|
2
|
+
module Inquiries
|
|
3
|
+
include ActiveSupport::Configurable
|
|
4
|
+
|
|
5
|
+
config_accessor :default_contact_form,:enable_routes,:mail_delivery_format,:base_layout,:from_address,:enable_sitemap,:enable_action_caching, :automount
|
|
6
|
+
|
|
7
|
+
self.enable_routes = true
|
|
8
|
+
self.automount = true
|
|
9
|
+
self.default_contact_form = "contact"
|
|
10
|
+
self.base_layout = "application"
|
|
11
|
+
self.mail_delivery_format = :html
|
|
12
|
+
self.from_address = "no-reply@example.org"
|
|
13
|
+
self.enable_sitemap = true
|
|
14
|
+
self.enable_action_caching = false
|
|
15
|
+
end
|
|
16
|
+
end
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
require 'tb_core'
|
|
2
|
+
require 'tb_liquid'
|
|
3
|
+
|
|
4
|
+
module Spud
|
|
5
|
+
module Inquiries
|
|
6
|
+
class Engine < Rails::Engine
|
|
7
|
+
engine_name :spud_inquiries
|
|
8
|
+
|
|
9
|
+
initializer :admin do
|
|
10
|
+
Spud::Core.configure do |config|
|
|
11
|
+
config.admin_applications += [{:name => "Inquiries",:thumbnail => "spud/admin/contacts_thumb.png",:url => "/spud/admin/inquiries",:order => 88}]
|
|
12
|
+
if Spud::Inquiries.enable_sitemap == true
|
|
13
|
+
config.sitemap_urls += [:spud_inquiries_sitemap_url]
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
initializer :liquid_form do
|
|
19
|
+
Spud::Inquiries::FormActionView.class_eval do
|
|
20
|
+
include Spud::Inquiries::Engine.routes.url_helpers
|
|
21
|
+
include Spud::Inquiries::Engine.routes.mounted_helpers
|
|
22
|
+
include ContactsHelper
|
|
23
|
+
end
|
|
24
|
+
Liquid::Template.register_tag('inquiry', Spud::Inquiries::InquiryForm) if defined?(Liquid::Template)
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
require 'liquid'
|
|
2
|
+
module Spud
|
|
3
|
+
module Inquiries
|
|
4
|
+
class FormActionView < ActionView::Base
|
|
5
|
+
include ActionView::Helpers
|
|
6
|
+
|
|
7
|
+
def protect_against_forgery?
|
|
8
|
+
return false
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
class InquiryForm < Liquid::Tag
|
|
13
|
+
|
|
14
|
+
def initialize(tag_name, form_name, tokens)
|
|
15
|
+
@form_name = form_name
|
|
16
|
+
@spud_inquiry_form = SpudInquiryForm.where(:name => form_name).includes(:spud_inquiry_form_fields).first
|
|
17
|
+
@view = FormActionView.new([Rails.application.config.paths["app/views"].first, Spud::Inquiries::Engine.config.paths["app/views"].first])
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def tag_name
|
|
21
|
+
return "inquiry"
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def tag_value
|
|
25
|
+
return @form_name
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def render(context)
|
|
29
|
+
if !@spud_inquiry_form.blank?
|
|
30
|
+
@spud_inquiry = @spud_inquiry_form.spud_inquiries.new()
|
|
31
|
+
@spud_inquiry.build_inquiry_form_fields()
|
|
32
|
+
@view.render(
|
|
33
|
+
:partial => "/contacts/show",
|
|
34
|
+
:locals => {
|
|
35
|
+
:spud_inquiry_form => @spud_inquiry_form,
|
|
36
|
+
:spud_inquiry => @spud_inquiry,
|
|
37
|
+
:contact_inquire_path => '/contact/inquire'
|
|
38
|
+
}
|
|
39
|
+
)
|
|
40
|
+
else
|
|
41
|
+
return ''
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
end
|
data/lib/tb_inquiries.rb
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe ContactsController do
|
|
4
|
+
before(:each) do
|
|
5
|
+
Spud::Core.configure do |config|
|
|
6
|
+
config.site_name = "Test Site"
|
|
7
|
+
config.multisite_mode_enabled = false
|
|
8
|
+
config.multisite_config = []
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
describe :show do
|
|
13
|
+
it "should return a form by url name" do
|
|
14
|
+
form = FactoryGirl.create(:spud_inquiry_form)
|
|
15
|
+
get :show, :id => form.url_name
|
|
16
|
+
assigns(:inquiry_form).should == form
|
|
17
|
+
assigns(:spud_inquiry).should_not be_blank
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
it "should redirect to root if inquiry not found" do
|
|
21
|
+
get :show, :id => 1234
|
|
22
|
+
response.should redirect_to "/"
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
describe :inquire do
|
|
27
|
+
before(:each) do
|
|
28
|
+
@form = FactoryGirl.create(:spud_inquiry_form)
|
|
29
|
+
@field = FactoryGirl.create(:spud_inquiry_form_field,:spud_inquiry_form => @form,:name => "email",:field_type => '0', :required => true)
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
it "should fail if spam field assigned" do
|
|
33
|
+
post :inquire,:spud_inquiry => {:spud_inquiry_form_id => @form.id}, :other_email => "test@spamcastle.com"
|
|
34
|
+
flash[:error].should =~ /You must be a robot/i
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
it "should fail if inquiry not submitted" do
|
|
38
|
+
post :inquire
|
|
39
|
+
response.should redirect_to "/"
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
it "should fail if the inquiry form is invalid" do
|
|
43
|
+
post :inquire,:spud_inquiry => {:spud_inquiry_form_id => @form.id + 2}
|
|
44
|
+
response.should redirect_to "/"
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
it "should fail if required field is blank" do
|
|
48
|
+
post :inquire, :spud_inquiry => {:spud_inquiry_form_id => @form.id}
|
|
49
|
+
response.should_not be_success
|
|
50
|
+
response.should_not redirect_to contact_thankyou_url
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
# it "should succed if fields are valid" do
|
|
54
|
+
# post :inquire,:spud_inquiry => {:spud_inquiry_form_id => @form.id, "email" => "test@test.com"}
|
|
55
|
+
# assigns(:inquiry).should be_valid
|
|
56
|
+
# response.should be_success
|
|
57
|
+
# response.should redirect_to contact_thankyou_url
|
|
58
|
+
|
|
59
|
+
# end
|
|
60
|
+
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
describe :thankyou do
|
|
64
|
+
it "should render successfully" do
|
|
65
|
+
get :thankyou
|
|
66
|
+
response.should be_success
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
end
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe Spud::Admin::InquiriesController do
|
|
4
|
+
before(:each) do
|
|
5
|
+
activate_authlogic
|
|
6
|
+
u = SpudUser.new(:login => "testuser",:email => "test@testuser.com",:password => "test",:password_confirmation => "test")
|
|
7
|
+
u.super_admin = true
|
|
8
|
+
u.save
|
|
9
|
+
@user = SpudUserSession.create(u)
|
|
10
|
+
Spud::Core.configure do |config|
|
|
11
|
+
config.site_name = "Test Site"
|
|
12
|
+
config.multisite_mode_enabled = false
|
|
13
|
+
config.multisite_config = []
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
describe :index do
|
|
18
|
+
it "should return an array of menus" do
|
|
19
|
+
2.times {|x| s = FactoryGirl.create(:spud_inquiry)}
|
|
20
|
+
get :index
|
|
21
|
+
assigns(:inquiries).count.should be > 1
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
describe :show do
|
|
26
|
+
it "should return a preview of an inquiry" do
|
|
27
|
+
s = FactoryGirl.create(:spud_inquiry)
|
|
28
|
+
get :show, :id => s.id
|
|
29
|
+
assigns(:inquiry).should == s
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
it "should redirect to index if inquiry not found" do
|
|
33
|
+
get :show, :id => 1234
|
|
34
|
+
response.should redirect_to spud_admin_inquiries_url
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
describe :destroy do
|
|
39
|
+
it "should destroy the menu" do
|
|
40
|
+
inquiry = FactoryGirl.create(:spud_inquiry)
|
|
41
|
+
lambda {
|
|
42
|
+
delete :destroy, :id => inquiry.id
|
|
43
|
+
}.should change(SpudInquiry,:count).by(-1)
|
|
44
|
+
response.should be_redirect
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
it "should not destroy the menu with a wrong id" do
|
|
48
|
+
inquiry = FactoryGirl.create(:spud_inquiry)
|
|
49
|
+
lambda {
|
|
50
|
+
delete :destroy,:id => "23532"
|
|
51
|
+
}.should_not change(SpudInquiry,:count)
|
|
52
|
+
response.should be_redirect
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
end
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe Spud::Admin::InquiryFormsController do
|
|
4
|
+
before(:each) do
|
|
5
|
+
activate_authlogic
|
|
6
|
+
u = SpudUser.new(:login => "testuser",:email => "test@testuser.com",:password => "test",:password_confirmation => "test")
|
|
7
|
+
u.super_admin = true
|
|
8
|
+
u.save
|
|
9
|
+
@user = SpudUserSession.create(u)
|
|
10
|
+
Spud::Core.configure do |config|
|
|
11
|
+
config.site_name = "Test Site"
|
|
12
|
+
config.multisite_mode_enabled = false
|
|
13
|
+
config.multisite_config = []
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
describe :index do
|
|
18
|
+
it "should return an array of menus" do
|
|
19
|
+
2.times {|x| s = FactoryGirl.create(:spud_inquiry_form)}
|
|
20
|
+
get :index
|
|
21
|
+
assigns(:inquiry_forms).count.should be > 1
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
describe :new do
|
|
26
|
+
it "should respond with a new form" do
|
|
27
|
+
get :new
|
|
28
|
+
assigns(:inquiry_form).should_not be_blank
|
|
29
|
+
response.should be_success
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
describe :create do
|
|
34
|
+
it "should create a new form with a valid form submission" do
|
|
35
|
+
lambda {
|
|
36
|
+
post :create, :spud_inquiry_form => FactoryGirl.attributes_for(:spud_inquiry_form).reject{|k,v| k == 'site_id' || k == 'id'}
|
|
37
|
+
}.should change(SpudInquiryForm,:count).by(1)
|
|
38
|
+
response.should be_redirect
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
it "should not create a form with an invalid form entry" do
|
|
42
|
+
lambda {
|
|
43
|
+
post :create, :spud_inquiry_form => FactoryGirl.attributes_for(:spud_inquiry_form,:name => nil).reject{|k,v| k == 'site_id' || k == 'id'}
|
|
44
|
+
}.should_not change(SpudInquiryForm,:count)
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
describe :edit do
|
|
49
|
+
it "should respond with form by id" do
|
|
50
|
+
form1 = FactoryGirl.create(:spud_inquiry_form)
|
|
51
|
+
form2 = FactoryGirl.create(:spud_inquiry_form)
|
|
52
|
+
get :edit,:id => form2.id
|
|
53
|
+
assigns(:inquiry_form).should == form2
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
it "should redirect to index if form not found" do
|
|
57
|
+
get :edit,:id => 1234
|
|
58
|
+
response.should redirect_to spud_admin_inquiry_forms_url
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
describe :update do
|
|
63
|
+
it "should update the name when the name attribute is changed" do
|
|
64
|
+
form = FactoryGirl.create(:spud_inquiry_form)
|
|
65
|
+
new_name = 'MyForm'
|
|
66
|
+
lambda {
|
|
67
|
+
put :update, :id => form.id, :spud_inquiry_form => form.attributes.merge!(:name => new_name).reject{|k,v| k == 'site_id' || k == 'id'}
|
|
68
|
+
form.reload
|
|
69
|
+
}.should change(form,:name).to(new_name)
|
|
70
|
+
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
it "should redirect to the admin forms after a successful update" do
|
|
74
|
+
form = FactoryGirl.create(:spud_inquiry_form)
|
|
75
|
+
new_name = 'MyForm'
|
|
76
|
+
put :update,:id => form.id, :spud_inquiry_form => form.attributes.merge!(:name => new_name).reject{|k,v| k == 'site_id' || k == 'id'}
|
|
77
|
+
response.should redirect_to(spud_admin_inquiry_forms_url)
|
|
78
|
+
end
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
describe :destroy do
|
|
82
|
+
it "should destroy the form" do
|
|
83
|
+
form = FactoryGirl.create(:spud_inquiry_form)
|
|
84
|
+
lambda {
|
|
85
|
+
delete :destroy, :id => form.id
|
|
86
|
+
}.should change(SpudInquiryForm,:count).by(-1)
|
|
87
|
+
response.should be_redirect
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
it "should not destroy the form with a wrong id" do
|
|
91
|
+
menu = FactoryGirl.create(:spud_inquiry_form)
|
|
92
|
+
lambda {
|
|
93
|
+
delete :destroy,:id => "23532"
|
|
94
|
+
}.should_not change(SpudInquiryForm,:count)
|
|
95
|
+
response.should be_redirect
|
|
96
|
+
end
|
|
97
|
+
end
|
|
98
|
+
end
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe Spud::Inquiries::SitemapsController do
|
|
4
|
+
describe :show do
|
|
5
|
+
before(:each) do
|
|
6
|
+
Spud::Core.configure do |config|
|
|
7
|
+
config.site_name = "Test Site"
|
|
8
|
+
config.multisite_mode_enabled = false
|
|
9
|
+
config.multisite_config = []
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
it "should return the sitemap urls" do
|
|
14
|
+
get :show, :format => :xml
|
|
15
|
+
assigns(:forms).should == SpudInquiryForm.all
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
it "should only respond to an XML format" do
|
|
19
|
+
expect {
|
|
20
|
+
get :show
|
|
21
|
+
}.to raise_exception(ActionController::UnknownFormat)
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|