refinerycms-inquiries 1.0.1 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +3 -0
- data/.travis.yml +16 -0
- data/Gemfile +68 -0
- data/Guardfile +20 -0
- data/Rakefile +19 -0
- data/app/assets/stylesheets/refinery/inquiries/inquiries.css.scss +21 -0
- data/app/controllers/refinery/inquiries/admin/inquiries_controller.rb +50 -0
- data/app/controllers/refinery/inquiries/admin/settings_controller.rb +56 -0
- data/app/controllers/refinery/inquiries/inquiries_controller.rb +47 -0
- data/app/helpers/refinery/inquiries/inquiries_helper.rb +6 -0
- data/app/mailers/refinery/inquiries/inquiry_mailer.rb +22 -0
- data/app/models/refinery/inquiries/inquiry.rb +27 -0
- data/app/models/refinery/inquiries/setting.rb +63 -0
- data/app/views/refinery/inquiries/admin/inquiries/_inquiry.html.erb +27 -0
- data/app/views/refinery/inquiries/admin/inquiries/_submenu.html.erb +27 -0
- data/app/views/{admin → refinery/inquiries/admin}/inquiries/index.html.erb +2 -2
- data/app/views/{admin → refinery/inquiries/admin}/inquiries/show.html.erb +9 -7
- data/app/views/refinery/inquiries/admin/settings/_confirmation_email_form.html.erb +59 -0
- data/app/views/{admin/inquiry_settings → refinery/inquiries/admin/settings}/_notification_recipients_form.html.erb +3 -3
- data/app/views/{admin/inquiry_settings → refinery/inquiries/admin/settings}/edit.html.erb +1 -1
- data/app/views/refinery/inquiries/inquiries/new.html.erb +32 -0
- data/app/views/refinery/inquiries/inquiries/thank_you.html.erb +1 -0
- data/app/views/refinery/inquiries/inquiry_mailer/confirmation.text.erb +1 -0
- data/app/views/refinery/inquiries/inquiry_mailer/notification.text.erb +18 -0
- data/config/locales/bg.yml +77 -0
- data/config/locales/cs.yml +68 -66
- data/config/locales/da.yml +60 -58
- data/config/locales/de.yml +69 -67
- data/config/locales/en-GB.yml +68 -66
- data/config/locales/en.yml +68 -66
- data/config/locales/es.yml +71 -69
- data/config/locales/fr.yml +69 -67
- data/config/locales/it.yml +70 -68
- data/config/locales/lolcat.yml +69 -67
- data/config/locales/lt.yml +69 -67
- data/config/locales/lv.yml +69 -67
- data/config/locales/nb.yml +70 -68
- data/config/locales/nl.yml +69 -67
- data/config/locales/pl.yml +69 -67
- data/config/locales/pt-BR.yml +69 -67
- data/config/locales/ru.yml +69 -67
- data/config/locales/sk.yml +69 -67
- data/config/locales/sl.yml +69 -67
- data/config/locales/sv.yml +69 -67
- data/config/locales/zh-CN.yml +69 -67
- data/config/routes.rb +16 -16
- data/db/migrate/20101208082840_create_inquiries.rb +16 -34
- data/db/seeds.rb +50 -0
- data/lib/generators/refinery/inquiries/inquiries_generator.rb +19 -0
- data/lib/refinery/inquiries/configuration.rb +9 -0
- data/lib/refinery/inquiries/engine.rb +28 -0
- data/lib/refinery/inquiries.rb +26 -0
- data/lib/refinerycms-inquiries.rb +1 -23
- data/readme.md +12 -4
- data/refinerycms-inquiries.gemspec +11 -86
- data/spec/factories/inquiry.rb +7 -0
- data/spec/models/refinery/inquiries/inquiry_spec.rb +52 -0
- data/spec/requests/refinery/inquiries/admin/inquiries_spec.rb +138 -0
- data/spec/requests/refinery/inquiries/inquiries_spec.rb +81 -0
- data/spec/spec_helper.rb +56 -0
- data/tasks/rspec.rake +4 -0
- metadata +114 -39
- data/app/controllers/admin/inquiries_controller.rb +0 -41
- data/app/controllers/admin/inquiry_settings_controller.rb +0 -43
- data/app/controllers/inquiries_controller.rb +0 -43
- data/app/helpers/inquiries_helper.rb +0 -2
- data/app/mailers/inquiry_mailer.rb +0 -20
- data/app/models/inquiry.rb +0 -21
- data/app/models/inquiry_setting.rb +0 -33
- data/app/views/admin/inquiries/_inquiry.html.erb +0 -24
- data/app/views/admin/inquiries/_submenu.html.erb +0 -27
- data/app/views/admin/inquiry_settings/_confirmation_email_form.html.erb +0 -57
- data/app/views/inquiries/new.html.erb +0 -34
- data/app/views/inquiries/thank_you.html.erb +0 -1
- data/app/views/inquiry_mailer/confirmation.html.erb +0 -1
- data/app/views/inquiry_mailer/notification.html.erb +0 -18
- data/db/migrate/20101208082841_remove_position_and_open_from_inquiries.rb +0 -11
- data/db/seeds/pages_for_inquiries.rb +0 -55
- data/features/create_inquiries.feature +0 -38
- data/features/manage_inquiries.feature +0 -57
- data/features/step_definitions/inquiry_steps.rb +0 -25
- data/features/support/factories.rb +0 -7
- data/features/support/paths.rb +0 -26
- data/lib/gemspec.rb +0 -29
- data/lib/generators/refinerycms_inquiries_generator.rb +0 -6
- data/lib/inquiries.rb +0 -2
- data/spec/models/inquiry_spec.rb +0 -59
@@ -0,0 +1,138 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
module Refinery
|
4
|
+
module Inquiries
|
5
|
+
module Admin
|
6
|
+
describe Inquiry do
|
7
|
+
login_refinery_user
|
8
|
+
|
9
|
+
let!(:inquiry) do
|
10
|
+
Factory(:inquiry, :name => "David Jones",
|
11
|
+
:email => "dave@refinerycms.com",
|
12
|
+
:message => "Hello, I really like your website. Was it hard to build and maintain or could anyone do it?")
|
13
|
+
end
|
14
|
+
|
15
|
+
context "when no" do
|
16
|
+
before(:each) { Refinery::Inquiries::Inquiry.destroy_all }
|
17
|
+
|
18
|
+
context "inquiries" do
|
19
|
+
it "shows message" do
|
20
|
+
visit refinery.inquiries_admin_inquiries_path
|
21
|
+
|
22
|
+
page.should have_content("You have not received any inquiries yet.")
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
context "spam inquiries" do
|
27
|
+
it "shows message" do
|
28
|
+
visit refinery.spam_inquiries_admin_inquiries_path
|
29
|
+
|
30
|
+
page.should have_content("Hooray! You don't have any spam.")
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
describe "action links" do
|
36
|
+
before(:each) { visit refinery.inquiries_admin_inquiries_path }
|
37
|
+
|
38
|
+
specify "in the side pane" do
|
39
|
+
within "#actions" do
|
40
|
+
page.should have_content("Inbox")
|
41
|
+
page.should have_selector("a[href='/refinery/inquiries']")
|
42
|
+
page.should have_content("Spam")
|
43
|
+
page.should have_selector("a[href='/refinery/inquiries/spam']")
|
44
|
+
page.should have_content("Update who gets notified")
|
45
|
+
page.should have_selector("a[href*='/refinery/inquiries/settings/inquiry_notification_recipients/edit']")
|
46
|
+
page.should have_content("Edit confirmation email")
|
47
|
+
page.should have_selector("a[href*='/refinery/inquiries/settings/inquiry_confirmation_body/edit']")
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
describe "index" do
|
53
|
+
it "shows inquiry list" do
|
54
|
+
visit refinery.inquiries_admin_inquiries_path
|
55
|
+
|
56
|
+
page.should have_content("David Jones said Hello, I really like your website. Was it hard to build ...")
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
describe "show" do
|
61
|
+
it "shows inquiry details" do
|
62
|
+
visit refinery.inquiries_admin_inquiries_path
|
63
|
+
|
64
|
+
click_link "Read the inquiry"
|
65
|
+
|
66
|
+
page.should have_content("From David Jones [dave@refinerycms.com]")
|
67
|
+
page.should have_content("Hello, I really like your website. Was it hard to build and maintain or could anyone do it?")
|
68
|
+
within "#actions" do
|
69
|
+
page.should have_content("Age")
|
70
|
+
page.should have_content("Back to all Inquiries")
|
71
|
+
page.should have_selector("a[href='/refinery/inquiries']")
|
72
|
+
page.should have_content("Remove this inquiry forever")
|
73
|
+
page.should have_selector("a[href='/refinery/inquiries/#{inquiry.id}']")
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
describe "destroy" do
|
79
|
+
it "removes inquiry" do
|
80
|
+
visit refinery.inquiries_admin_inquiries_path
|
81
|
+
|
82
|
+
click_link "Remove this inquiry forever"
|
83
|
+
|
84
|
+
page.should have_content("'#{inquiry.name}' was successfully removed.")
|
85
|
+
Refinery::Inquiries::Inquiry.count.should == 0
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
describe "spam" do
|
90
|
+
it "moves inquiry to spam" do
|
91
|
+
visit refinery.inquiries_admin_inquiries_path
|
92
|
+
|
93
|
+
click_link "Mark as spam"
|
94
|
+
|
95
|
+
within "#actions" do
|
96
|
+
page.should have_content("Spam (1)")
|
97
|
+
click_link "Spam (1)"
|
98
|
+
end
|
99
|
+
|
100
|
+
page.should have_content("David Jones said Hello, I really like your website. Was it hard to build ...")
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
=begin
|
105
|
+
describe "update who gets notified" do
|
106
|
+
it "sets receiver", :js => true do
|
107
|
+
visit refinery.inquiries_admin_inquiries_path
|
108
|
+
|
109
|
+
click_link "Update who gets notified"
|
110
|
+
|
111
|
+
within_frame "dialog_iframe" do
|
112
|
+
fill_in "Send notifications to", :with => "phil@refinerycms.com"
|
113
|
+
click_button "Save"
|
114
|
+
end
|
115
|
+
|
116
|
+
page.should have_content("'Notification Recipients' was successfully updated.")
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
describe "updating confirmation email copy" do
|
121
|
+
it "sets message", :js => true do
|
122
|
+
visit refinery.inquiries_admin_inquiries_path
|
123
|
+
|
124
|
+
click_link "Edit confirmation email"
|
125
|
+
|
126
|
+
within_frame "dialog_iframe" do
|
127
|
+
fill_in "Message", :with => "Thanks %name%! We'll never get back to you!"
|
128
|
+
click_button "Save"
|
129
|
+
end
|
130
|
+
|
131
|
+
page.should have_content("'Confirmation Body' was successfully updated.")
|
132
|
+
end
|
133
|
+
end
|
134
|
+
=end
|
135
|
+
end
|
136
|
+
end
|
137
|
+
end
|
138
|
+
end
|
@@ -0,0 +1,81 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
module Refinery
|
4
|
+
module Inquiries
|
5
|
+
describe "inquiries" do
|
6
|
+
before(:each) do
|
7
|
+
Factory(:refinery_user)
|
8
|
+
|
9
|
+
# load in seeds we use in migration
|
10
|
+
Refinery::Inquiries::Engine.load_seed
|
11
|
+
end
|
12
|
+
|
13
|
+
context "when valid data" do
|
14
|
+
it "is successful" do
|
15
|
+
visit refinery.inquiries_new_inquiry_path
|
16
|
+
|
17
|
+
fill_in "Name", :with => "Ugis Ozols"
|
18
|
+
fill_in "Email", :with => "ugis.ozols@refinerycms.com"
|
19
|
+
fill_in "Message", :with => "Hey, I'm testing!"
|
20
|
+
click_button "Send message"
|
21
|
+
|
22
|
+
page.current_path.should == refinery.thank_you_inquiries_inquiries_path
|
23
|
+
page.should have_content("Thank You")
|
24
|
+
|
25
|
+
within "#body_content" do
|
26
|
+
page.should have_content("We've received your inquiry and will get back to you with a response shortly.")
|
27
|
+
page.should have_content("Return to the home page")
|
28
|
+
page.should have_selector("a[href='/']")
|
29
|
+
end
|
30
|
+
|
31
|
+
Refinery::Inquiries::Inquiry.count.should == 1
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
context "when invalid data" do
|
36
|
+
it "is not successful" do
|
37
|
+
visit refinery.inquiries_new_inquiry_path
|
38
|
+
|
39
|
+
click_button "Send message"
|
40
|
+
|
41
|
+
page.current_path.should == refinery.inquiries_new_inquiry_path
|
42
|
+
page.should have_content("There were problems with the following fields")
|
43
|
+
page.should have_content("Name can't be blank")
|
44
|
+
page.should have_content("Email is invalid")
|
45
|
+
page.should have_content("Message can't be blank")
|
46
|
+
page.should have_no_content("Phone can't be blank")
|
47
|
+
|
48
|
+
Refinery::Inquiries::Inquiry.count.should == 0
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
describe "privacy" do
|
53
|
+
context "when show contact privacy link setting set to false" do
|
54
|
+
before(:each) do
|
55
|
+
Refinery::Inquiries.stub(:show_contact_privacy_link).and_return(false)
|
56
|
+
end
|
57
|
+
|
58
|
+
it "won't show link" do
|
59
|
+
visit refinery.inquiries_new_inquiry_path
|
60
|
+
|
61
|
+
page.should have_no_content("We value your privacy")
|
62
|
+
page.should have_no_selector("a[href='/pages/privacy-policy']")
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
context "when show contact privacy link setting set to true" do
|
67
|
+
before(:each) do
|
68
|
+
Refinery::Inquiries.config.stub(:show_contact_privacy_link).and_return(true)
|
69
|
+
end
|
70
|
+
|
71
|
+
it "shows the link" do
|
72
|
+
visit refinery.inquiries_new_inquiry_path
|
73
|
+
|
74
|
+
page.should have_content("We value your privacy")
|
75
|
+
page.should have_selector("a[href='/pages/privacy-policy']")
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
|
3
|
+
def setup_environment
|
4
|
+
# Configure Rails Environment
|
5
|
+
ENV["RAILS_ENV"] ||= 'test'
|
6
|
+
|
7
|
+
require File.expand_path("../dummy/config/environment", __FILE__)
|
8
|
+
|
9
|
+
require 'rspec/rails'
|
10
|
+
require 'capybara/rspec'
|
11
|
+
require 'factory_girl_rails'
|
12
|
+
|
13
|
+
Rails.backtrace_cleaner.remove_silencers!
|
14
|
+
|
15
|
+
RSpec.configure do |config|
|
16
|
+
config.mock_with :rspec
|
17
|
+
config.treat_symbols_as_metadata_keys_with_true_values = true
|
18
|
+
config.filter_run :focus => true
|
19
|
+
config.run_all_when_everything_filtered = true
|
20
|
+
end
|
21
|
+
|
22
|
+
# set javascript driver for capybara
|
23
|
+
Capybara.javascript_driver = :selenium
|
24
|
+
end
|
25
|
+
|
26
|
+
def each_run
|
27
|
+
ActiveSupport::Dependencies.clear
|
28
|
+
|
29
|
+
FactoryGirl.reload
|
30
|
+
|
31
|
+
# Requires supporting files with custom matchers and macros, etc,
|
32
|
+
# in ./support/ and its subdirectories including factories.
|
33
|
+
([Rails.root.to_s] | ::Refinery::Plugins.registered.pathnames).map{|p|
|
34
|
+
Dir[File.join(p, 'spec', 'support', '**', '*.rb').to_s]
|
35
|
+
}.flatten.sort.each do |support_file|
|
36
|
+
require support_file
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
# If spork is available in the Gemfile it'll be used but we don't force it.
|
41
|
+
unless (begin; require 'spork'; rescue LoadError; nil end).nil?
|
42
|
+
Spork.prefork do
|
43
|
+
# Loading more in this block will cause your tests to run faster. However,
|
44
|
+
# if you change any configuration or code from libraries loaded here, you'll
|
45
|
+
# need to restart spork for it take effect.
|
46
|
+
setup_environment
|
47
|
+
end
|
48
|
+
|
49
|
+
Spork.each_run do
|
50
|
+
# This code will be run each time you run your specs.
|
51
|
+
each_run
|
52
|
+
end
|
53
|
+
else
|
54
|
+
setup_environment
|
55
|
+
each_run
|
56
|
+
end
|
data/tasks/rspec.rake
ADDED
metadata
CHANGED
@@ -1,29 +1,87 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: refinerycms-inquiries
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
+
hash: 15
|
4
5
|
prerelease:
|
5
|
-
|
6
|
+
segments:
|
7
|
+
- 2
|
8
|
+
- 0
|
9
|
+
- 0
|
10
|
+
version: 2.0.0
|
6
11
|
platform: ruby
|
7
12
|
authors:
|
8
|
-
-
|
13
|
+
- Philip Arndt
|
14
|
+
- "U\xC4\xA3is Ozols"
|
15
|
+
- David Jones
|
9
16
|
autorequire:
|
10
17
|
bindir: bin
|
11
18
|
cert_chain: []
|
12
19
|
|
13
|
-
date:
|
14
|
-
default_executable:
|
20
|
+
date: 2012-03-06 00:00:00 Z
|
15
21
|
dependencies:
|
16
22
|
- !ruby/object:Gem::Dependency
|
17
|
-
name:
|
23
|
+
name: refinerycms-core
|
18
24
|
prerelease: false
|
19
25
|
requirement: &id001 !ruby/object:Gem::Requirement
|
20
26
|
none: false
|
21
27
|
requirements:
|
22
28
|
- - ~>
|
23
29
|
- !ruby/object:Gem::Version
|
24
|
-
|
30
|
+
hash: 13
|
31
|
+
segments:
|
32
|
+
- 2
|
33
|
+
- 0
|
34
|
+
- 1
|
35
|
+
version: 2.0.1
|
25
36
|
type: :runtime
|
26
37
|
version_requirements: *id001
|
38
|
+
- !ruby/object:Gem::Dependency
|
39
|
+
name: refinerycms-settings
|
40
|
+
prerelease: false
|
41
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
42
|
+
none: false
|
43
|
+
requirements:
|
44
|
+
- - ~>
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
hash: 13
|
47
|
+
segments:
|
48
|
+
- 2
|
49
|
+
- 0
|
50
|
+
- 1
|
51
|
+
version: 2.0.1
|
52
|
+
type: :runtime
|
53
|
+
version_requirements: *id002
|
54
|
+
- !ruby/object:Gem::Dependency
|
55
|
+
name: filters_spam
|
56
|
+
prerelease: false
|
57
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
58
|
+
none: false
|
59
|
+
requirements:
|
60
|
+
- - ~>
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
hash: 15
|
63
|
+
segments:
|
64
|
+
- 0
|
65
|
+
- 2
|
66
|
+
version: "0.2"
|
67
|
+
type: :runtime
|
68
|
+
version_requirements: *id003
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: refinerycms-testing
|
71
|
+
prerelease: false
|
72
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ~>
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
hash: 15
|
78
|
+
segments:
|
79
|
+
- 2
|
80
|
+
- 0
|
81
|
+
- 0
|
82
|
+
version: 2.0.0
|
83
|
+
type: :development
|
84
|
+
version_requirements: *id004
|
27
85
|
description: Inquiry handling functionality extracted from Refinery CMS to allow you to have a contact form and manage inquiries in the Refinery backend.
|
28
86
|
email: info@refinerycms.com
|
29
87
|
executables: []
|
@@ -33,24 +91,31 @@ extensions: []
|
|
33
91
|
extra_rdoc_files: []
|
34
92
|
|
35
93
|
files:
|
36
|
-
-
|
37
|
-
-
|
38
|
-
-
|
39
|
-
-
|
40
|
-
-
|
41
|
-
- app/
|
42
|
-
- app/
|
43
|
-
- app/
|
44
|
-
- app/
|
45
|
-
- app/
|
46
|
-
- app/
|
47
|
-
- app/
|
48
|
-
- app/
|
49
|
-
- app/views/admin/
|
50
|
-
- app/views/inquiries/
|
51
|
-
- app/views/inquiries/
|
52
|
-
- app/views/
|
53
|
-
- app/views/
|
94
|
+
- .gitignore
|
95
|
+
- .travis.yml
|
96
|
+
- Gemfile
|
97
|
+
- Guardfile
|
98
|
+
- Rakefile
|
99
|
+
- app/assets/stylesheets/refinery/inquiries/inquiries.css.scss
|
100
|
+
- app/controllers/refinery/inquiries/admin/inquiries_controller.rb
|
101
|
+
- app/controllers/refinery/inquiries/admin/settings_controller.rb
|
102
|
+
- app/controllers/refinery/inquiries/inquiries_controller.rb
|
103
|
+
- app/helpers/refinery/inquiries/inquiries_helper.rb
|
104
|
+
- app/mailers/refinery/inquiries/inquiry_mailer.rb
|
105
|
+
- app/models/refinery/inquiries/inquiry.rb
|
106
|
+
- app/models/refinery/inquiries/setting.rb
|
107
|
+
- app/views/refinery/inquiries/admin/inquiries/_inquiry.html.erb
|
108
|
+
- app/views/refinery/inquiries/admin/inquiries/_submenu.html.erb
|
109
|
+
- app/views/refinery/inquiries/admin/inquiries/index.html.erb
|
110
|
+
- app/views/refinery/inquiries/admin/inquiries/show.html.erb
|
111
|
+
- app/views/refinery/inquiries/admin/settings/_confirmation_email_form.html.erb
|
112
|
+
- app/views/refinery/inquiries/admin/settings/_notification_recipients_form.html.erb
|
113
|
+
- app/views/refinery/inquiries/admin/settings/edit.html.erb
|
114
|
+
- app/views/refinery/inquiries/inquiries/new.html.erb
|
115
|
+
- app/views/refinery/inquiries/inquiries/thank_you.html.erb
|
116
|
+
- app/views/refinery/inquiries/inquiry_mailer/confirmation.text.erb
|
117
|
+
- app/views/refinery/inquiries/inquiry_mailer/notification.text.erb
|
118
|
+
- config/locales/bg.yml
|
54
119
|
- config/locales/cs.yml
|
55
120
|
- config/locales/da.yml
|
56
121
|
- config/locales/de.yml
|
@@ -73,22 +138,21 @@ files:
|
|
73
138
|
- config/locales/zh-CN.yml
|
74
139
|
- config/routes.rb
|
75
140
|
- db/migrate/20101208082840_create_inquiries.rb
|
76
|
-
- db/
|
77
|
-
-
|
78
|
-
-
|
79
|
-
-
|
80
|
-
-
|
81
|
-
- features/support/factories.rb
|
82
|
-
- features/support/paths.rb
|
83
|
-
- lib/gemspec.rb
|
84
|
-
- lib/generators/refinerycms_inquiries_generator.rb
|
85
|
-
- lib/inquiries.rb
|
141
|
+
- db/seeds.rb
|
142
|
+
- lib/generators/refinery/inquiries/inquiries_generator.rb
|
143
|
+
- lib/refinery/inquiries.rb
|
144
|
+
- lib/refinery/inquiries/configuration.rb
|
145
|
+
- lib/refinery/inquiries/engine.rb
|
86
146
|
- lib/refinerycms-inquiries.rb
|
87
147
|
- license.md
|
88
148
|
- readme.md
|
89
149
|
- refinerycms-inquiries.gemspec
|
90
|
-
- spec/
|
91
|
-
|
150
|
+
- spec/factories/inquiry.rb
|
151
|
+
- spec/models/refinery/inquiries/inquiry_spec.rb
|
152
|
+
- spec/requests/refinery/inquiries/admin/inquiries_spec.rb
|
153
|
+
- spec/requests/refinery/inquiries/inquiries_spec.rb
|
154
|
+
- spec/spec_helper.rb
|
155
|
+
- tasks/rspec.rake
|
92
156
|
homepage: http://refinerycms.com
|
93
157
|
licenses: []
|
94
158
|
|
@@ -102,19 +166,30 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
102
166
|
requirements:
|
103
167
|
- - ">="
|
104
168
|
- !ruby/object:Gem::Version
|
169
|
+
hash: 3
|
170
|
+
segments:
|
171
|
+
- 0
|
105
172
|
version: "0"
|
106
173
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
107
174
|
none: false
|
108
175
|
requirements:
|
109
176
|
- - ">="
|
110
177
|
- !ruby/object:Gem::Version
|
178
|
+
hash: 3
|
179
|
+
segments:
|
180
|
+
- 0
|
111
181
|
version: "0"
|
112
182
|
requirements: []
|
113
183
|
|
114
184
|
rubyforge_project:
|
115
|
-
rubygems_version: 1.
|
185
|
+
rubygems_version: 1.8.17
|
116
186
|
signing_key:
|
117
187
|
specification_version: 3
|
118
188
|
summary: Inquiry handling functionality for the Refinery CMS project.
|
119
|
-
test_files:
|
120
|
-
|
189
|
+
test_files:
|
190
|
+
- spec/factories/inquiry.rb
|
191
|
+
- spec/models/refinery/inquiries/inquiry_spec.rb
|
192
|
+
- spec/requests/refinery/inquiries/admin/inquiries_spec.rb
|
193
|
+
- spec/requests/refinery/inquiries/inquiries_spec.rb
|
194
|
+
- spec/spec_helper.rb
|
195
|
+
has_rdoc:
|
@@ -1,41 +0,0 @@
|
|
1
|
-
class Admin::InquiriesController < Admin::BaseController
|
2
|
-
|
3
|
-
crudify :inquiry, :title_attribute => "name", :order => "created_at DESC"
|
4
|
-
helper_method :group_by_date
|
5
|
-
|
6
|
-
before_filter :find_all_ham, :only => [:index]
|
7
|
-
before_filter :find_all_spam, :only => [:spam]
|
8
|
-
before_filter :get_spam_count, :only => [:index, :spam]
|
9
|
-
|
10
|
-
def index
|
11
|
-
@inquiries = @inquiries.with_query(params[:search]) if searching?
|
12
|
-
@inquiries = @inquiries.paginate({:page => params[:page]})
|
13
|
-
end
|
14
|
-
|
15
|
-
def spam
|
16
|
-
self.index
|
17
|
-
render :action => 'index'
|
18
|
-
end
|
19
|
-
|
20
|
-
def toggle_spam
|
21
|
-
find_inquiry
|
22
|
-
@inquiry.toggle!(:spam)
|
23
|
-
|
24
|
-
redirect_to :back
|
25
|
-
end
|
26
|
-
|
27
|
-
protected
|
28
|
-
|
29
|
-
def find_all_ham
|
30
|
-
@inquiries = Inquiry.ham
|
31
|
-
end
|
32
|
-
|
33
|
-
def find_all_spam
|
34
|
-
@inquiries = Inquiry.spam
|
35
|
-
end
|
36
|
-
|
37
|
-
def get_spam_count
|
38
|
-
@spam_count = Inquiry.count(:conditions => {:spam => true})
|
39
|
-
end
|
40
|
-
|
41
|
-
end
|
@@ -1,43 +0,0 @@
|
|
1
|
-
class Admin::InquirySettingsController < Admin::BaseController
|
2
|
-
|
3
|
-
crudify :refinery_setting,
|
4
|
-
:title_attribute => "name",
|
5
|
-
:order => 'name ASC',
|
6
|
-
:redirect_to_url => "admin_inquiries_url"
|
7
|
-
|
8
|
-
before_filter :set_url_override?, :only => [:edit, :update]
|
9
|
-
after_filter :save_subject_for_confirmation?, :only => :update
|
10
|
-
around_filter :rewrite_flash?, :only => :update
|
11
|
-
|
12
|
-
protected
|
13
|
-
def rewrite_flash?
|
14
|
-
yield
|
15
|
-
|
16
|
-
flash[:notice] = flash[:notice].to_s.gsub(/(\'.*\')/) {|m| m.titleize}.gsub('Inquiry ', '')
|
17
|
-
end
|
18
|
-
|
19
|
-
def save_subject_for_confirmation?
|
20
|
-
InquirySetting.confirmation_subject = params[:subject] if params.keys.include?('subject')
|
21
|
-
end
|
22
|
-
|
23
|
-
def set_url_override?
|
24
|
-
@url_override = admin_inquiry_setting_url(@refinery_setting, :dialog => from_dialog?)
|
25
|
-
end
|
26
|
-
|
27
|
-
def find_refinery_setting
|
28
|
-
# ensure that we're dealing with the name of the setting, not the id.
|
29
|
-
begin
|
30
|
-
if params[:id].to_i.to_s == params[:id]
|
31
|
-
params[:id] = RefinerySetting.find(params[:id]).name.to_s
|
32
|
-
end
|
33
|
-
rescue
|
34
|
-
end
|
35
|
-
|
36
|
-
# prime the setting first, if it's valid.
|
37
|
-
if InquirySetting.methods.map(&:to_sym).include?(params[:id].to_s.gsub('inquiry_', '').to_sym)
|
38
|
-
InquirySetting.send(params[:id].to_s.gsub('inquiry_', '').to_sym)
|
39
|
-
end
|
40
|
-
@refinery_setting = RefinerySetting.find_by_name(params[:id])
|
41
|
-
end
|
42
|
-
|
43
|
-
end
|
@@ -1,43 +0,0 @@
|
|
1
|
-
class InquiriesController < ApplicationController
|
2
|
-
|
3
|
-
before_filter :find_page, :only => [:create, :new]
|
4
|
-
|
5
|
-
def thank_you
|
6
|
-
@page = Page.find_by_link_url("/contact/thank_you", :include => [:parts, :slugs])
|
7
|
-
end
|
8
|
-
|
9
|
-
def new
|
10
|
-
@inquiry = Inquiry.new
|
11
|
-
end
|
12
|
-
|
13
|
-
def create
|
14
|
-
@inquiry = Inquiry.new(params[:inquiry])
|
15
|
-
|
16
|
-
if @inquiry.save
|
17
|
-
if @inquiry.ham?
|
18
|
-
begin
|
19
|
-
InquiryMailer.notification(@inquiry, request).deliver
|
20
|
-
rescue
|
21
|
-
logger.warn "There was an error delivering an inquiry notification.\n#{$!}\n"
|
22
|
-
end
|
23
|
-
|
24
|
-
begin
|
25
|
-
InquiryMailer.confirmation(@inquiry, request).deliver
|
26
|
-
rescue
|
27
|
-
logger.warn "There was an error delivering an inquiry confirmation:\n#{$!}\n"
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
redirect_to thank_you_inquiries_url
|
32
|
-
else
|
33
|
-
render :action => 'new'
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
protected
|
38
|
-
|
39
|
-
def find_page
|
40
|
-
@page = Page.find_by_link_url('/contact', :include => [:parts, :slugs])
|
41
|
-
end
|
42
|
-
|
43
|
-
end
|
@@ -1,20 +0,0 @@
|
|
1
|
-
class InquiryMailer < ActionMailer::Base
|
2
|
-
|
3
|
-
def confirmation(inquiry, request)
|
4
|
-
subject InquirySetting.confirmation_subject
|
5
|
-
recipients inquiry.email
|
6
|
-
from "\"#{RefinerySetting[:site_name]}\" <no-reply@#{request.domain(RefinerySetting.find_or_set(:tld_length, 1))}>"
|
7
|
-
reply_to InquirySetting.notification_recipients.split(',').first
|
8
|
-
sent_on Time.now
|
9
|
-
@inquiry = inquiry
|
10
|
-
end
|
11
|
-
|
12
|
-
def notification(inquiry, request)
|
13
|
-
subject InquirySetting.notification_subject
|
14
|
-
recipients InquirySetting.notification_recipients
|
15
|
-
from "\"#{RefinerySetting[:site_name]}\" <no-reply@#{request.domain(RefinerySetting.find_or_set(:tld_length, 1))}>"
|
16
|
-
sent_on Time.now
|
17
|
-
@inquiry = inquiry
|
18
|
-
end
|
19
|
-
|
20
|
-
end
|
data/app/models/inquiry.rb
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
class Inquiry < ActiveRecord::Base
|
2
|
-
|
3
|
-
filters_spam :message_field => :message,
|
4
|
-
:email_field => :email,
|
5
|
-
:author_field => :name,
|
6
|
-
:other_fields => [:phone],
|
7
|
-
:extra_spam_words => %w()
|
8
|
-
|
9
|
-
validates :name, :presence => true
|
10
|
-
validates :message, :presence => true
|
11
|
-
validates :email, :format=> { :with => /^([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/i }
|
12
|
-
|
13
|
-
acts_as_indexed :fields => [:name, :email, :message, :phone]
|
14
|
-
|
15
|
-
default_scope :order => 'created_at DESC' # previously scope :newest
|
16
|
-
|
17
|
-
def self.latest(number = 7, include_spam = false)
|
18
|
-
include_spam ? limit(number) : ham.limit(number)
|
19
|
-
end
|
20
|
-
|
21
|
-
end
|