refinerycms-inquiries 1.0.1 → 2.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.
Files changed (87) hide show
  1. data/.gitignore +3 -0
  2. data/.travis.yml +16 -0
  3. data/Gemfile +68 -0
  4. data/Guardfile +20 -0
  5. data/Rakefile +19 -0
  6. data/app/assets/stylesheets/refinery/inquiries/inquiries.css.scss +21 -0
  7. data/app/controllers/refinery/inquiries/admin/inquiries_controller.rb +50 -0
  8. data/app/controllers/refinery/inquiries/admin/settings_controller.rb +56 -0
  9. data/app/controllers/refinery/inquiries/inquiries_controller.rb +47 -0
  10. data/app/helpers/refinery/inquiries/inquiries_helper.rb +6 -0
  11. data/app/mailers/refinery/inquiries/inquiry_mailer.rb +22 -0
  12. data/app/models/refinery/inquiries/inquiry.rb +27 -0
  13. data/app/models/refinery/inquiries/setting.rb +63 -0
  14. data/app/views/refinery/inquiries/admin/inquiries/_inquiry.html.erb +27 -0
  15. data/app/views/refinery/inquiries/admin/inquiries/_submenu.html.erb +27 -0
  16. data/app/views/{admin → refinery/inquiries/admin}/inquiries/index.html.erb +2 -2
  17. data/app/views/{admin → refinery/inquiries/admin}/inquiries/show.html.erb +9 -7
  18. data/app/views/refinery/inquiries/admin/settings/_confirmation_email_form.html.erb +59 -0
  19. data/app/views/{admin/inquiry_settings → refinery/inquiries/admin/settings}/_notification_recipients_form.html.erb +3 -3
  20. data/app/views/{admin/inquiry_settings → refinery/inquiries/admin/settings}/edit.html.erb +1 -1
  21. data/app/views/refinery/inquiries/inquiries/new.html.erb +32 -0
  22. data/app/views/refinery/inquiries/inquiries/thank_you.html.erb +1 -0
  23. data/app/views/refinery/inquiries/inquiry_mailer/confirmation.text.erb +1 -0
  24. data/app/views/refinery/inquiries/inquiry_mailer/notification.text.erb +18 -0
  25. data/config/locales/bg.yml +77 -0
  26. data/config/locales/cs.yml +68 -66
  27. data/config/locales/da.yml +60 -58
  28. data/config/locales/de.yml +69 -67
  29. data/config/locales/en-GB.yml +68 -66
  30. data/config/locales/en.yml +68 -66
  31. data/config/locales/es.yml +71 -69
  32. data/config/locales/fr.yml +69 -67
  33. data/config/locales/it.yml +70 -68
  34. data/config/locales/lolcat.yml +69 -67
  35. data/config/locales/lt.yml +69 -67
  36. data/config/locales/lv.yml +69 -67
  37. data/config/locales/nb.yml +70 -68
  38. data/config/locales/nl.yml +69 -67
  39. data/config/locales/pl.yml +69 -67
  40. data/config/locales/pt-BR.yml +69 -67
  41. data/config/locales/ru.yml +69 -67
  42. data/config/locales/sk.yml +69 -67
  43. data/config/locales/sl.yml +69 -67
  44. data/config/locales/sv.yml +69 -67
  45. data/config/locales/zh-CN.yml +69 -67
  46. data/config/routes.rb +16 -16
  47. data/db/migrate/20101208082840_create_inquiries.rb +16 -34
  48. data/db/seeds.rb +50 -0
  49. data/lib/generators/refinery/inquiries/inquiries_generator.rb +19 -0
  50. data/lib/refinery/inquiries/configuration.rb +9 -0
  51. data/lib/refinery/inquiries/engine.rb +28 -0
  52. data/lib/refinery/inquiries.rb +26 -0
  53. data/lib/refinerycms-inquiries.rb +1 -23
  54. data/readme.md +12 -4
  55. data/refinerycms-inquiries.gemspec +11 -86
  56. data/spec/factories/inquiry.rb +7 -0
  57. data/spec/models/refinery/inquiries/inquiry_spec.rb +52 -0
  58. data/spec/requests/refinery/inquiries/admin/inquiries_spec.rb +138 -0
  59. data/spec/requests/refinery/inquiries/inquiries_spec.rb +81 -0
  60. data/spec/spec_helper.rb +56 -0
  61. data/tasks/rspec.rake +4 -0
  62. metadata +114 -39
  63. data/app/controllers/admin/inquiries_controller.rb +0 -41
  64. data/app/controllers/admin/inquiry_settings_controller.rb +0 -43
  65. data/app/controllers/inquiries_controller.rb +0 -43
  66. data/app/helpers/inquiries_helper.rb +0 -2
  67. data/app/mailers/inquiry_mailer.rb +0 -20
  68. data/app/models/inquiry.rb +0 -21
  69. data/app/models/inquiry_setting.rb +0 -33
  70. data/app/views/admin/inquiries/_inquiry.html.erb +0 -24
  71. data/app/views/admin/inquiries/_submenu.html.erb +0 -27
  72. data/app/views/admin/inquiry_settings/_confirmation_email_form.html.erb +0 -57
  73. data/app/views/inquiries/new.html.erb +0 -34
  74. data/app/views/inquiries/thank_you.html.erb +0 -1
  75. data/app/views/inquiry_mailer/confirmation.html.erb +0 -1
  76. data/app/views/inquiry_mailer/notification.html.erb +0 -18
  77. data/db/migrate/20101208082841_remove_position_and_open_from_inquiries.rb +0 -11
  78. data/db/seeds/pages_for_inquiries.rb +0 -55
  79. data/features/create_inquiries.feature +0 -38
  80. data/features/manage_inquiries.feature +0 -57
  81. data/features/step_definitions/inquiry_steps.rb +0 -25
  82. data/features/support/factories.rb +0 -7
  83. data/features/support/paths.rb +0 -26
  84. data/lib/gemspec.rb +0 -29
  85. data/lib/generators/refinerycms_inquiries_generator.rb +0 -6
  86. data/lib/inquiries.rb +0 -2
  87. data/spec/models/inquiry_spec.rb +0 -59
@@ -1,74 +1,76 @@
1
1
  zh-CN:
2
- plugins:
3
- refinery_inquiries:
4
- title: 咨询
5
- description: 提供一个联系表单与保存咨询
6
- inquiries:
7
- new:
8
- send: 发送消息
9
- privacy_policy: 我们珍视您的隐私
10
- admin:
2
+ refinery:
3
+ plugins:
4
+ refinerycms_inquiries:
5
+ title: 咨询
6
+ description: 提供一个联系表单与保存咨询
11
7
  inquiries:
12
- delete: 永久删除此咨询
13
- inquiry:
14
- read_inquiry: 阅读此咨询
15
- said:
16
- mark_as_spam: 标记为垃圾邮件
17
- mark_as_ham: 移到收件箱
18
- submenu:
19
- inbox: 收件箱
20
- spam: 垃圾邮件
21
- update_notified: 更新通知名单
22
- edit_confirmation_email: 编辑确认email
23
- index:
24
- no_inquiries: 你还没有收到任何的咨询.
25
- no_spam: 垃圾邮件箱为空.
26
- show:
27
- details: 详细
28
- age: 时间
29
- actions: 操作
30
- back_to_all_inquiries: 返回到所有的咨询
31
- spam: 垃圾邮件
32
- spam_yes: '是'
33
- inquiry: 咨询
34
- to:
35
- from:
36
- click_to_email: 点击发送到这个地址
37
- phone: 电话
38
- date: 日期
39
- message: 信息
40
- inquiry_settings:
41
- notification_recipients_form:
42
- inquiry_settings_value_name: 发送通知到
43
- hint: 当收到新的咨询时,Refinery将会发一封email通知你.
44
- example: "输入你的email地址如: jack@work.com, jill@office.com"
45
- confirmation_email_form:
46
- to:
47
- from:
48
- subject: 标题
49
- click_to_edit_subject: 点击这里编辑标题
50
- explanation: 每当有人在网站上联系你, Refinery发送出一封email去确认发送者的身份.
51
- below_edit_email_sent: 你可以在下面编辑你要发出去的email.
52
- the_customer_making_inquiry: 客户正在写咨询
53
- message: 信息
54
- note: "注意: 把你的客户名字在电子邮件出现的位置以文字 %name% 做替换"
55
- inquiry_mailer:
56
- notification:
57
- greeting: 您好
58
- you_recieved_new_inquiry: 你刚从你的网站收到一条新的咨询.
59
- inquiry_starts: --- 咨询开始处 ---
60
- inquiry_ends: --- 咨询结束处 ---
61
- from: 表单
62
- email: email
63
- phone: 电话
64
- message: 信息
65
- closing_line: 谨致问候
66
- ps: 附言 您所有的咨询被保存在“咨询”区域以便于你在日后查看.
67
- activerecord:
8
+ inquiries:
9
+ new:
10
+ send: 发送消息
11
+ privacy_policy: 我们珍视您的隐私
12
+ admin:
13
+ inquiries:
14
+ delete: 永久删除此咨询
15
+ inquiry:
16
+ read_inquiry: 阅读此咨询
17
+ said:
18
+ mark_as_spam: 标记为垃圾邮件
19
+ mark_as_ham: 移到收件箱
20
+ submenu:
21
+ inbox: 收件箱
22
+ spam: 垃圾邮件
23
+ update_notified: 更新通知名单
24
+ edit_confirmation_email: 编辑确认email
25
+ index:
26
+ no_inquiries: 你还没有收到任何的咨询.
27
+ no_spam: 垃圾邮件箱为空.
28
+ show:
29
+ details: 详细
30
+ age: 时间
31
+ actions: 操作
32
+ back_to_all_inquiries: 返回到所有的咨询
33
+ spam: 垃圾邮件
34
+ spam_yes: '是'
35
+ inquiry: 咨询
36
+ to:
37
+ from:
38
+ click_to_email: 点击发送到这个地址
39
+ phone: 电话
40
+ date: 日期
41
+ message: 信息
42
+ settings:
43
+ notification_recipients_form:
44
+ inquiry_settings_value_name: 发送通知到
45
+ hint: 当收到新的咨询时,Refinery将会发一封email通知你.
46
+ example: "输入你的email地址如: jack@work.com, jill@office.com"
47
+ confirmation_email_form:
48
+ to:
49
+ from:
50
+ subject: 标题
51
+ click_to_edit_subject: 点击这里编辑标题
52
+ explanation: 每当有人在网站上联系你, Refinery发送出一封email去确认发送者的身份.
53
+ below_edit_email_sent: 你可以在下面编辑你要发出去的email.
54
+ the_customer_making_inquiry: 客户正在写咨询
55
+ message: 信息
56
+ note: "注意: 把你的客户名字在电子邮件出现的位置以文字 %name% 做替换"
57
+ inquiry_mailer:
58
+ notification:
59
+ greeting: 您好
60
+ you_recieved_new_inquiry: 你刚从你的网站收到一条新的咨询.
61
+ inquiry_starts: --- 咨询开始处 ---
62
+ inquiry_ends: --- 咨询结束处 ---
63
+ from: 表单
64
+ email: email
65
+ phone: 电话
66
+ message: 信息
67
+ closing_line: 谨致问候
68
+ ps: 附言 您所有的咨询被保存在“咨询”区域以便于你在日后查看.
69
+ activerecord:
68
70
  models:
69
- inquiry: inquiry
71
+ refinery/inquiry: inquiry
70
72
  attributes:
71
- inquiry:
73
+ refinery/inquiry:
72
74
  name: 姓名
73
75
  email: email
74
76
  phone: 联系电话
data/config/routes.rb CHANGED
@@ -1,23 +1,23 @@
1
- Refinery::Application.routes.draw do
2
- get '/contact', :to => 'inquiries#new', :as => 'new_inquiry'
3
- resources :contact,
4
- :only => :create,
5
- :as => :inquiries,
6
- :controller => 'inquiries' do
7
- collection do
8
- get :thank_you
1
+ Refinery::Core::Engine.routes.draw do
2
+ namespace :inquiries, :path => '' do
3
+ get '/contact', :to => 'inquiries#new', :as => 'new_inquiry'
4
+
5
+ resources :contact,
6
+ :only => :create,
7
+ :as => :inquiries,
8
+ :controller => 'inquiries' do
9
+ get :thank_you, :on => :collection
9
10
  end
10
- end
11
11
 
12
- scope(:path => 'refinery', :as => 'admin', :module => 'admin') do
13
- resources :inquiries, :only => [:index, :show, :destroy] do
14
- collection do
15
- get :spam
12
+ namespace :admin, :path => 'refinery' do
13
+ resources :inquiries, :only => [:index, :show, :destroy] do
14
+ get :spam, :on => :collection
15
+ get :toggle_spam, :on => :member
16
16
  end
17
- member do
18
- get :toggle_spam
17
+
18
+ scope :path => 'inquiries' do
19
+ resources :settings, :only => [:edit, :update]
19
20
  end
20
21
  end
21
- resources :inquiry_settings, :only => [:edit, :update]
22
22
  end
23
23
  end
@@ -1,42 +1,24 @@
1
1
  class CreateInquiries < ActiveRecord::Migration
2
- def self.up
3
- unless ::Inquiry.table_exists?
4
- create_table ::Inquiry.table_name, :force => true do |t|
5
- t.string "name"
6
- t.string "email"
7
- t.string "phone"
8
- t.text "message"
9
- t.integer "position"
10
- t.boolean "open", :default => true
11
- t.datetime "created_at"
12
- t.datetime "updated_at"
13
- t.boolean "spam", :default => false
2
+ def up
3
+ unless ::Refinery::Inquiries::Inquiry.table_exists?
4
+ create_table :refinery_inquiries_inquiries, :force => true do |t|
5
+ t.string :name
6
+ t.string :email
7
+ t.string :phone
8
+ t.text :message
9
+ t.boolean :spam, :default => false
10
+ t.timestamps
14
11
  end
15
12
 
16
- add_index ::Inquiry.table_name, :id
13
+ add_index :refinery_inquiries_inquiries, :id
17
14
  end
18
-
19
- # todo: remove at 1.0
20
- create_table ::InquirySetting.table_name, :force => true do |t|
21
- t.string "name"
22
- t.text "value"
23
- t.boolean "destroyable"
24
- t.datetime "created_at"
25
- t.datetime "updated_at"
26
- end unless ::InquirySetting.table_exists?
27
-
28
- ::Page.reset_column_information if defined?(::Page)
29
-
30
- load(Rails.root.join('db', 'seeds', 'pages_for_inquiries.rb').to_s)
31
15
  end
32
16
 
33
- def self.down
34
- drop_table ::Inquiry.table_name
35
- # todo: remove at 1.0
36
- drop_table ::InquirySetting.table_name
37
-
38
- ::Page.delete_all({
17
+ def down
18
+ drop_table ::Refinery::Inquiries::Inquiry.table_name
19
+
20
+ ::Refinery::Page.delete_all({
39
21
  :link_url => ("/contact" || "/contact/thank_you")
40
- }) if defined?(::Page)
22
+ }) if defined?(::Refinery::Page)
41
23
  end
42
- end
24
+ end
data/db/seeds.rb ADDED
@@ -0,0 +1,50 @@
1
+ ::Refinery::User.all.each do |user|
2
+ if user.plugins.where(:name => 'refinery_inquiries').blank?
3
+ user.plugins.create(:name => "refinery_inquiries")
4
+ end
5
+ end if defined?(::Refinery::User)
6
+
7
+ if defined?(::Refinery::Page)
8
+ unless Refinery::Page.where(:link_url => '/contact').any?
9
+ contact_us_page = ::Refinery::Page.create({
10
+ :title => "Contact",
11
+ :link_url => "/contact",
12
+ :menu_match => "^/(inquiries|contact).*$",
13
+ :deletable => false
14
+ })
15
+ contact_us_page.parts.create({
16
+ :title => "Body",
17
+ :body => "<p>Get in touch with us. Just use the form below and we'll get back to you as soon as we can.</p>"
18
+ })
19
+ contact_us_page.parts.create({
20
+ :title => "Side Body",
21
+ :body => ""
22
+ })
23
+ end
24
+
25
+ unless Refinery::Page.where(:link_url => '/contact/thank_you').any?
26
+ thank_you_page = contact_us_page.children.create({
27
+ :title => "Thank You",
28
+ :link_url => "/contact/thank_you",
29
+ :menu_match => "^/(inquiries|contact)/thank_you$",
30
+ :show_in_menu => false,
31
+ :deletable => false
32
+ })
33
+ thank_you_page.parts.create({
34
+ :title => "Body",
35
+ :body => "<p>We've received your inquiry and will get back to you with a response shortly.</p><p><a href='/'>Return to the home page</a></p>"
36
+ })
37
+ end
38
+
39
+ unless Refinery::Page.by_title('Privacy Policy').any?
40
+ privacy_policy_page = contact_us_page.children.create({
41
+ :title => "Privacy Policy",
42
+ :deletable => true,
43
+ :show_in_menu => false
44
+ })
45
+ privacy_policy_page.parts.create({
46
+ :title => "Body",
47
+ :body => "<p>We respect your privacy. We do not market, rent or sell our email list to any outside parties.</p><p>We need your e-mail address so that we can ensure that the people using our forms are bona fide. It also allows us to send you e-mail newsletters and other communications, if you opt-in. Your postal address is required in order to send you information and pricing, if you request it.</p><p>Please call us at 123 456 7890 if you have any questions or concerns.</p>"
48
+ })
49
+ end
50
+ end
@@ -0,0 +1,19 @@
1
+ module Refinery
2
+ class InquiriesGenerator < Rails::Generators::Base
3
+ def rake_db
4
+ rake("refinery_inquiries:install:migrations")
5
+ rake("refinery_settings:install:migrations")
6
+ end
7
+
8
+ def append_load_seed_data
9
+ create_file 'db/seeds.rb' unless File.exists?(File.join(destination_root, 'db', 'seeds.rb'))
10
+ append_file 'db/seeds.rb', :verbose => true do
11
+ <<-EOH
12
+
13
+ # Added by Refinery CMS Inquiries engine
14
+ Refinery::Inquiries::Engine.load_seed
15
+ EOH
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,9 @@
1
+ module Refinery
2
+ module Inquiries
3
+ include ActiveSupport::Configurable
4
+
5
+ config_accessor :show_contact_privacy_link
6
+
7
+ self.show_contact_privacy_link = true
8
+ end
9
+ end
@@ -0,0 +1,28 @@
1
+ module Refinery
2
+ module Inquiries
3
+ class Engine < Rails::Engine
4
+ include Refinery::Engine
5
+
6
+ isolate_namespace Refinery::Inquiries
7
+
8
+ initializer "init plugin" do
9
+ Refinery::Plugin.register do |plugin|
10
+ plugin.pathname = root
11
+ plugin.name = "refinerycms_inquiries"
12
+ plugin.url = proc { Refinery::Core::Engine.routes.url_helpers.inquiries_admin_inquiries_path }
13
+ plugin.menu_match = %r{/refinery/inquiries(/.+?)?$}
14
+ plugin.activity = {
15
+ :class_name => :'refinery/inquiries/inquiry',
16
+ :title => 'name',
17
+ :url_prefix => nil,
18
+ :url => 'refinery.inquiries_admin_inquiries_path'
19
+ }
20
+ end
21
+ end
22
+
23
+ config.after_initialize do
24
+ Refinery.register_engine(Refinery::Inquiries)
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,26 @@
1
+ require 'refinerycms-core'
2
+ require 'refinerycms-settings'
3
+ require 'filters_spam'
4
+
5
+ module Refinery
6
+ autoload :InquiriesGenerator, 'generators/refinery/inquiries/inquiries_generator'
7
+
8
+ module Inquiries
9
+ require 'refinery/inquiries/engine'
10
+ require 'refinery/inquiries/configuration'
11
+
12
+ autoload :Version, 'refinery/inquiries/version'
13
+
14
+ class << self
15
+ attr_writer :root
16
+
17
+ def root
18
+ @root ||= Pathname.new(File.expand_path('../../../', __FILE__))
19
+ end
20
+
21
+ def factory_paths
22
+ @factory_paths ||= [ root.join("spec/factories").to_s ]
23
+ end
24
+ end
25
+ end
26
+ end
@@ -1,23 +1 @@
1
- require File.expand_path('../inquiries', __FILE__)
2
-
3
- module Refinery
4
- module Inquiries
5
- class Engine < Rails::Engine
6
- config.to_prepare do
7
- require 'filters_spam'
8
- end
9
-
10
- config.after_initialize do
11
- Refinery::Plugin.register do |plugin|
12
- plugin.name = "refinery_inquiries"
13
- plugin.directory = "inquiries"
14
- plugin.menu_match = /(refinery|admin)\/inquir(ies|y_settings)$/
15
- plugin.activity = {
16
- :class => InquirySetting,
17
- :title => 'name'
18
- }
19
- end
20
- end
21
- end
22
- end
23
- end
1
+ require 'refinery/inquiries'
data/readme.md CHANGED
@@ -6,17 +6,17 @@
6
6
 
7
7
  Include the latest [gem](http://rubygems.org/gems/refinerycms-inquiries) into your Refinery CMS application's Gemfile:
8
8
 
9
- gem 'refinerycms-inquiries', '~> 1.0.0'
9
+ gem 'refinerycms-inquiries', '~> 2.0.0'
10
10
 
11
11
  Then type the following at command line inside your Refinery CMS application's root directory:
12
12
 
13
13
  bundle install
14
14
 
15
- #### Installation on Refinery 0.9.9 or above.
15
+ #### Installation on Refinery 2.0.0 or above.
16
16
 
17
17
  To install the migrations, run:
18
18
 
19
- rails generate refinerycms_inquiries
19
+ rails generate refinery:inquiries
20
20
 
21
21
  Next migrate your database and you're done:
22
22
 
@@ -40,4 +40,12 @@ Go into your 'Inquiries' tab in the Refinery admin area and click on "Update who
40
40
 
41
41
  ## How do I Edit the Automatic Confirmation Email
42
42
 
43
- Go into your 'Inquiries' tab in the Refinery admin area and click on "Edit confirmation email"
43
+ Go into your 'Inquiries' tab in the Refinery admin area and click on "Edit confirmation email"
44
+
45
+ ## Help! How do I send emails from no-reply@domain.com.au instead of no-reply@com.au?
46
+
47
+ Simply set the following in config/application.rb:
48
+
49
+ ```ruby
50
+ config.action_dispatch.tld_length = 2
51
+ ```
@@ -1,96 +1,21 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = %q{refinerycms-inquiries}
3
- s.version = %q{1.0.1}
4
- s.date = %q{2011-05-28}
3
+ s.version = %q{2.0.0}
4
+ s.date = "#{Date.today.strftime("%Y-%m-%d")}"
5
5
  s.summary = %q{Inquiry handling functionality for the Refinery CMS project.}
6
6
  s.description = %q{Inquiry handling functionality extracted from Refinery CMS to allow you to have a contact form and manage inquiries in the Refinery backend.}
7
7
  s.homepage = %q{http://refinerycms.com}
8
8
  s.email = %q{info@refinerycms.com}
9
- s.authors = ["Resolve Digital"]
9
+ s.authors = ['Philip Arndt', 'Uģis Ozols', 'David Jones']
10
10
  s.require_paths = %w(lib)
11
11
 
12
- s.files = [
13
- 'app',
14
- 'app/controllers',
15
- 'app/controllers/admin',
16
- 'app/controllers/admin/inquiries_controller.rb',
17
- 'app/controllers/admin/inquiry_settings_controller.rb',
18
- 'app/controllers/inquiries_controller.rb',
19
- 'app/helpers',
20
- 'app/helpers/inquiries_helper.rb',
21
- 'app/mailers',
22
- 'app/mailers/inquiry_mailer.rb',
23
- 'app/models',
24
- 'app/models/inquiry.rb',
25
- 'app/models/inquiry_setting.rb',
26
- 'app/views',
27
- 'app/views/admin',
28
- 'app/views/admin/inquiries',
29
- 'app/views/admin/inquiries/_inquiry.html.erb',
30
- 'app/views/admin/inquiries/_submenu.html.erb',
31
- 'app/views/admin/inquiries/index.html.erb',
32
- 'app/views/admin/inquiries/show.html.erb',
33
- 'app/views/admin/inquiry_settings',
34
- 'app/views/admin/inquiry_settings/_confirmation_email_form.html.erb',
35
- 'app/views/admin/inquiry_settings/_notification_recipients_form.html.erb',
36
- 'app/views/admin/inquiry_settings/edit.html.erb',
37
- 'app/views/inquiries',
38
- 'app/views/inquiries/new.html.erb',
39
- 'app/views/inquiries/thank_you.html.erb',
40
- 'app/views/inquiry_mailer',
41
- 'app/views/inquiry_mailer/confirmation.html.erb',
42
- 'app/views/inquiry_mailer/notification.html.erb',
43
- 'config',
44
- 'config/locales',
45
- 'config/locales/cs.yml',
46
- 'config/locales/da.yml',
47
- 'config/locales/de.yml',
48
- 'config/locales/en-GB.yml',
49
- 'config/locales/en.yml',
50
- 'config/locales/es.yml',
51
- 'config/locales/fr.yml',
52
- 'config/locales/it.yml',
53
- 'config/locales/lolcat.yml',
54
- 'config/locales/lt.yml',
55
- 'config/locales/lv.yml',
56
- 'config/locales/nb.yml',
57
- 'config/locales/nl.yml',
58
- 'config/locales/pl.yml',
59
- 'config/locales/pt-BR.yml',
60
- 'config/locales/ru.yml',
61
- 'config/locales/sk.yml',
62
- 'config/locales/sl.yml',
63
- 'config/locales/sv.yml',
64
- 'config/locales/zh-CN.yml',
65
- 'config/routes.rb',
66
- 'db',
67
- 'db/migrate',
68
- 'db/migrate/20101208082840_create_inquiries.rb',
69
- 'db/migrate/20101208082841_remove_position_and_open_from_inquiries.rb',
70
- 'db/seeds',
71
- 'db/seeds/pages_for_inquiries.rb',
72
- 'features',
73
- 'features/create_inquiries.feature',
74
- 'features/manage_inquiries.feature',
75
- 'features/step_definitions',
76
- 'features/step_definitions/inquiry_steps.rb',
77
- 'features/support',
78
- 'features/support/factories.rb',
79
- 'features/support/paths.rb',
80
- 'lib',
81
- 'lib/gemspec.rb',
82
- 'lib/generators',
83
- 'lib/generators/refinerycms_inquiries_generator.rb',
84
- 'lib/inquiries.rb',
85
- 'lib/refinerycms-inquiries.rb',
86
- 'license.md',
87
- 'readme.md',
88
- 'refinerycms-inquiries.gemspec',
89
- 'spec',
90
- 'spec/models',
91
- 'spec/models/inquiry_spec.rb'
92
- ]
93
- s.require_path = 'lib'
12
+ s.files = `git ls-files`.split("\n")
13
+ s.test_files = `git ls-files -- spec/*`.split("\n")
94
14
 
95
- s.add_dependency('filters_spam', '~> 0.2')
15
+ s.add_dependency 'refinerycms-core', '~> 2.0.1'
16
+ s.add_dependency 'refinerycms-settings', '~> 2.0.1'
17
+ s.add_dependency 'filters_spam', '~> 0.2'
18
+
19
+ # Development dependencies
20
+ s.add_development_dependency 'refinerycms-testing', '~> 2.0.0'
96
21
  end
@@ -0,0 +1,7 @@
1
+ FactoryGirl.define do
2
+ factory :inquiry, :class => Refinery::Inquiries::Inquiry do
3
+ name "Refinery"
4
+ email "refinery@cms.com"
5
+ message "Hello..."
6
+ end
7
+ end
@@ -0,0 +1,52 @@
1
+ require 'spec_helper'
2
+
3
+ module Refinery
4
+ module Inquiries
5
+ describe Inquiry do
6
+ describe "validations" do
7
+ subject do
8
+ Factory.build(:inquiry,
9
+ :name => "Ugis Ozols",
10
+ :email => "ugis.ozols@refinerycms.com",
11
+ :message => "Hey, I'm testing!")
12
+ end
13
+
14
+ it { should be_valid }
15
+ its(:errors) { should be_empty }
16
+ its(:name) { should == "Ugis Ozols" }
17
+ its(:email) { should == "ugis.ozols@refinerycms.com" }
18
+ its(:message) { should == "Hey, I'm testing!" }
19
+ end
20
+
21
+ describe "default scope" do
22
+ it "orders by created_at in desc" do
23
+ inquiry1 = Factory(:inquiry, :created_at => 1.hour.ago)
24
+ inquiry2 = Factory(:inquiry, :created_at => 2.hours.ago)
25
+ inquiries = Refinery::Inquiries::Inquiry.all
26
+ inquiries.first.should == inquiry1
27
+ inquiries.second.should == inquiry2
28
+ end
29
+ end
30
+
31
+ describe ".latest" do
32
+ it "returns latest 7 non-spam inquiries by default" do
33
+ 8.times { Factory(:inquiry) }
34
+ Refinery::Inquiries::Inquiry.last.toggle!(:spam)
35
+ Refinery::Inquiries::Inquiry.latest.length.should == 7
36
+ end
37
+
38
+ it "returns latest 7 inquiries including spam ones" do
39
+ 4.times { Factory(:inquiry) }
40
+ 3.times { Factory(:inquiry) }
41
+ Refinery::Inquiries::Inquiry.all[0..2].each { |inquiry| inquiry.toggle!(:spam) }
42
+ Refinery::Inquiries::Inquiry.latest(7, true).length.should == 7
43
+ end
44
+
45
+ it "returns latest n inquiries" do
46
+ 4.times { Factory(:inquiry) }
47
+ Refinery::Inquiries::Inquiry.latest(3).length.should == 3
48
+ end
49
+ end
50
+ end
51
+ end
52
+ end