refinerycms-forms 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/lib/generators/refinery/form/USAGE +20 -0
- data/lib/generators/refinery/form/form_generator.rb +34 -0
- data/lib/generators/refinery/form/templates/.gitignore +2 -0
- data/lib/generators/refinery/form/templates/.gitkeep +0 -0
- data/lib/generators/refinery/form/templates/Gemfile +44 -0
- data/lib/generators/refinery/form/templates/Rakefile +19 -0
- data/lib/generators/refinery/form/templates/app/controllers/refinery/namespace/admin/plural_name_controller.rb.erb +65 -0
- data/lib/generators/refinery/form/templates/app/controllers/refinery/namespace/admin/settings_controller.rb.erb +53 -0
- data/lib/generators/refinery/form/templates/app/controllers/refinery/namespace/plural_name_controller.rb.erb +63 -0
- data/lib/generators/refinery/form/templates/app/mailers/refinery/namespace/mailer.rb.erb +22 -0
- data/lib/generators/refinery/form/templates/app/models/refinery/namespace/setting.rb.erb +40 -0
- data/lib/generators/refinery/form/templates/app/models/refinery/namespace/singular_name.rb.erb +53 -0
- data/lib/generators/refinery/form/templates/app/views/refinery/namespace/admin/plural_name/_records.html.erb +23 -0
- data/lib/generators/refinery/form/templates/app/views/refinery/namespace/admin/plural_name/_singular_name.html.erb +25 -0
- data/lib/generators/refinery/form/templates/app/views/refinery/namespace/admin/plural_name/_submenu.html.erb +29 -0
- data/lib/generators/refinery/form/templates/app/views/refinery/namespace/admin/plural_name/index.html.erb +4 -0
- data/lib/generators/refinery/form/templates/app/views/refinery/namespace/admin/plural_name/show.html.erb +52 -0
- data/lib/generators/refinery/form/templates/app/views/refinery/namespace/admin/plural_name/spam.html.erb +27 -0
- data/lib/generators/refinery/form/templates/app/views/refinery/namespace/admin/settings/_confirmation_email_form.html.erb +50 -0
- data/lib/generators/refinery/form/templates/app/views/refinery/namespace/admin/settings/_notification_recipients_form.html.erb +21 -0
- data/lib/generators/refinery/form/templates/app/views/refinery/namespace/admin/settings/edit.html.erb +5 -0
- data/lib/generators/refinery/form/templates/app/views/refinery/namespace/mailer/confirmation.html.erb +1 -0
- data/lib/generators/refinery/form/templates/app/views/refinery/namespace/mailer/notification.html.erb +17 -0
- data/lib/generators/refinery/form/templates/app/views/refinery/namespace/plural_name/new.html.erb +43 -0
- data/lib/generators/refinery/form/templates/app/views/refinery/namespace/plural_name/thank_you.html.erb +1 -0
- data/lib/generators/refinery/form/templates/config/locales/cs.yml +78 -0
- data/lib/generators/refinery/form/templates/config/locales/da.yml +60 -0
- data/lib/generators/refinery/form/templates/config/locales/de.yml +78 -0
- data/lib/generators/refinery/form/templates/config/locales/en.yml +78 -0
- data/lib/generators/refinery/form/templates/config/locales/es.yml +60 -0
- data/lib/generators/refinery/form/templates/config/locales/fr.yml +78 -0
- data/lib/generators/refinery/form/templates/config/locales/it.yml +60 -0
- data/lib/generators/refinery/form/templates/config/locales/lv.yml +77 -0
- data/lib/generators/refinery/form/templates/config/locales/nb.yml +69 -0
- data/lib/generators/refinery/form/templates/config/locales/nl.yml +78 -0
- data/lib/generators/refinery/form/templates/config/locales/pt-BR.yml +78 -0
- data/lib/generators/refinery/form/templates/config/locales/ru.yml +71 -0
- data/lib/generators/refinery/form/templates/config/locales/sk.yml +78 -0
- data/lib/generators/refinery/form/templates/config/locales/sl.yml +61 -0
- data/lib/generators/refinery/form/templates/config/locales/tr.yml +78 -0
- data/lib/generators/refinery/form/templates/config/locales/zh-CN.yml +78 -0
- data/lib/generators/refinery/form/templates/config/routes.rb.erb +30 -0
- data/lib/generators/refinery/form/templates/db/migrate/1_create_plural_name.rb.erb +29 -0
- data/lib/generators/refinery/form/templates/db/seeds.rb.erb +39 -0
- data/lib/generators/refinery/form/templates/lib/generators/refinery/plural_name_generator.rb.erb +20 -0
- data/lib/generators/refinery/form/templates/lib/refinery/plural_name/engine.rb.erb +23 -0
- data/lib/generators/refinery/form/templates/lib/refinery/plural_name.rb.erb +18 -0
- data/lib/generators/refinery/form/templates/lib/refinerycms-plural_name.rb.erb +1 -0
- data/lib/generators/refinery/form/templates/readme.md +10 -0
- data/lib/generators/refinery/form/templates/refinerycms-plural_name.gemspec +22 -0
- data/lib/generators/refinery/form/templates/script/rails +10 -0
- data/lib/generators/refinery/form/templates/spec/controllers/refinery/plural_name/plural_name_controller_spec.rb +75 -0
- data/lib/generators/refinery/form/templates/spec/features/refinery/namespace/admin/plural_name_spec.rb.erb +166 -0
- data/lib/generators/refinery/form/templates/spec/features/refinery/namespace/admin/settings_spec.rb.erb +54 -0
- data/lib/generators/refinery/form/templates/spec/features/refinery/namespace/singular_name_spec.rb.erb +34 -0
- data/lib/generators/refinery/form/templates/spec/models/refinery/namespace/setting_spec.rb +34 -0
- data/lib/generators/refinery/form/templates/spec/requests/refinery/plural_name/plural_name_requests_spec.rb +32 -0
- data/lib/generators/refinery/form/templates/spec/routing/refinery/plural_name/admin/plural_name_routing_spec.rb +51 -0
- data/lib/generators/refinery/form/templates/spec/routing/refinery/plural_name/plural_name_routing_spec.rb +63 -0
- data/lib/generators/refinery/form/templates/spec/spec_helper.rb +30 -0
- data/lib/generators/refinery/form/templates/spec/support/factories/refinery/plural_name.rb.erb +7 -0
- data/lib/generators/refinery/form/templates/tasks/rspec.rake +6 -0
- data/lib/generators/refinery/form/templates/tasks/testing.rake +8 -0
- data/lib/refinery/forms/engine.rb +22 -0
- data/lib/refinery/forms.rb +1 -0
- data/lib/refinerycms-forms.rb +1 -0
- metadata +137 -0
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
zh-CN:
|
|
2
|
+
refinery:
|
|
3
|
+
plugins:
|
|
4
|
+
<%= plural_name %>:
|
|
5
|
+
title: <%= plural_name.titleize %>
|
|
6
|
+
description: 提供联系方式表格来存放 <%= plural_name.humanize.downcase %>
|
|
7
|
+
<%= namespacing.underscore %>:
|
|
8
|
+
<%= plural_name %>:
|
|
9
|
+
new:
|
|
10
|
+
send: 发送邮件
|
|
11
|
+
privacy_policy: 我们重视您的隐私
|
|
12
|
+
admin:
|
|
13
|
+
<%= plural_name %>:
|
|
14
|
+
<%= singular_name %>:
|
|
15
|
+
delete_<%= singular_name %>: 永久删除 <%= singular_name.humanize.downcase %>
|
|
16
|
+
read_<%= singular_name %>: 阅读这个 <%= singular_name.humanize.downcase %>
|
|
17
|
+
said: 说
|
|
18
|
+
mark_as_spam: 标记为垃圾邮件
|
|
19
|
+
mark_as_ham: 移动到收件箱
|
|
20
|
+
submenu:
|
|
21
|
+
inbox: 收件箱
|
|
22
|
+
spam: 垃圾邮件
|
|
23
|
+
update_notified: 通知相关人员
|
|
24
|
+
edit_confirmation_email: 编辑确认邮件
|
|
25
|
+
index:
|
|
26
|
+
no_<%= plural_name %>: 您尚未收到任何 <%= plural_name.humanize.downcase %>
|
|
27
|
+
spam:
|
|
28
|
+
no_spam: 太棒了!一封垃圾邮件都没有~
|
|
29
|
+
show:
|
|
30
|
+
details: 详细
|
|
31
|
+
age: 岁
|
|
32
|
+
actions: 操作
|
|
33
|
+
back_to_all_<%= plural_name %>: 返回到全部 <%= plural_name.humanize.downcase %>
|
|
34
|
+
spam: 垃圾信息
|
|
35
|
+
spam_yes: 是
|
|
36
|
+
<%= singular_name %>: <%= class_name.underscore.titleize %>
|
|
37
|
+
to: 收件人(To)
|
|
38
|
+
from: 发件人(From)
|
|
39
|
+
click_to_email: 点击来发送
|
|
40
|
+
phone: 电话
|
|
41
|
+
date: 日期
|
|
42
|
+
message: 信息
|
|
43
|
+
settings:
|
|
44
|
+
notification_recipients_form:
|
|
45
|
+
<%= singular_name %>_settings_value_name: 发通知给
|
|
46
|
+
explanation: 每当有人联系您时, Refinery都会发邮件给您.
|
|
47
|
+
hint: 当有新的 <%= singular_name.humanize.downcase %> 被提交时, Refinery 会发邮件告知您。
|
|
48
|
+
example: "输入您的Email地址, 形如: jack@work.com, jill@office.com"
|
|
49
|
+
confirmation_email_form:
|
|
50
|
+
to: 收件人
|
|
51
|
+
from: 发件人
|
|
52
|
+
subject: 主题
|
|
53
|
+
click_to_edit_subject: 点击编辑主题
|
|
54
|
+
explanation: 当有人试图联系您时,Refinery 都会发邮件跟他(拥有<%= singular_name.humanize.downcase %> 的人)进行确认
|
|
55
|
+
below_edit_email_sent: 您可以在下面编辑邮件内容
|
|
56
|
+
the_customer_making_<%= singular_name %>: 建立 <%= singular_name.humanize.downcase %> 的顾客
|
|
57
|
+
message: 邮件
|
|
58
|
+
note: "提示: 您可以在希望出现对方姓名的地方,使用%name%"
|
|
59
|
+
mailer:
|
|
60
|
+
notification:
|
|
61
|
+
greeting: 你好
|
|
62
|
+
you_recieved_new_<%= singular_name %>: 您刚刚收到了一封新 <%= singular_name.humanize.downcase %>.
|
|
63
|
+
<%= singular_name %>_starts: --- <%= singular_name.humanize.downcase %> 开始---
|
|
64
|
+
<%= singular_name %>_ends: --- <%= singular_name.humanize.downcase %> 结束---
|
|
65
|
+
from: 发件人
|
|
66
|
+
email: Email
|
|
67
|
+
phone: 电话
|
|
68
|
+
message: 正文
|
|
69
|
+
closing_line: 此致,
|
|
70
|
+
ps_html: 注:所有您的<%= plural_name.humanize.downcase %>都会保存在"<%= plural_name.titleize %>"里。这样您可以在任何时间查看它们。
|
|
71
|
+
activerecord:
|
|
72
|
+
models:
|
|
73
|
+
<%= singular_name %>: <%= class_name.underscore.titleize %>
|
|
74
|
+
attributes:
|
|
75
|
+
<%= singular_name %>:
|
|
76
|
+
<% attributes.each do |a| -%>
|
|
77
|
+
<%= a.name %>: <%= a.name.humanize %>
|
|
78
|
+
<% end -%>
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
Refinery::Core::Engine.routes.draw do
|
|
2
|
+
# Frontend routes
|
|
3
|
+
namespace :<%= namespacing.underscore %> do
|
|
4
|
+
|
|
5
|
+
resources :<%= plural_name %><%= ", :path => ''" if namespacing.underscore == plural_name %>, :only => [:index, :new, :create] do
|
|
6
|
+
collection do
|
|
7
|
+
get :thank_you
|
|
8
|
+
end
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
# Admin routes
|
|
13
|
+
namespace :<%= namespacing.underscore %>, :path => '' do
|
|
14
|
+
namespace :admin, :path => "#{Refinery::Core.backend_route}" do
|
|
15
|
+
resources :<%= plural_name %> do <% if include_spam? %>
|
|
16
|
+
collection do
|
|
17
|
+
get :spam
|
|
18
|
+
end
|
|
19
|
+
member do
|
|
20
|
+
get :toggle_spam
|
|
21
|
+
end <% end %>
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
scope :path => '<%= plural_name %>' do
|
|
25
|
+
resources :settings, :only => [:edit, :update]
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
class Create<%= class_name.pluralize %> < ActiveRecord::Migration
|
|
2
|
+
|
|
3
|
+
def up
|
|
4
|
+
create_table :refinery_<%= table_name %> do |t|
|
|
5
|
+
<% attributes.each do |attribute| -%>
|
|
6
|
+
t.<%= attribute.type %> :<%= attribute.column_name %>
|
|
7
|
+
<% end -%>
|
|
8
|
+
<% if include_spam? %>
|
|
9
|
+
t.boolean :spam, :default => false
|
|
10
|
+
<% end %>
|
|
11
|
+
t.timestamps
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
add_index :refinery_<%= table_name %>, :id
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def down
|
|
18
|
+
if defined?(::Refinery::UserPlugin)
|
|
19
|
+
::Refinery::UserPlugin.destroy_all({:name => "<%= plural_name %>"})
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
if defined?(::Refinery::Page)
|
|
23
|
+
::Refinery::Page.delete_all({:link_url => "/<%= plural_name %>"})
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
drop_table :refinery_<%= table_name %>
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
end
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
Refinery::I18n.frontend_locales.each do |lang|
|
|
2
|
+
I18n.locale = lang
|
|
3
|
+
|
|
4
|
+
if defined?(Refinery::User)
|
|
5
|
+
Refinery::User.all.each do |user|
|
|
6
|
+
if user.plugins.find_by_name('<%= plural_name %>').nil?
|
|
7
|
+
user.plugins.create(:name => "<%= plural_name %>",
|
|
8
|
+
:position => (user.plugins.maximum(:position) || -1) +1)
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
if defined?(Refinery::Page)
|
|
14
|
+
url = "/<%= [(namespacing.underscore if namespacing.underscore != plural_name), plural_name].compact.join('/') %>"
|
|
15
|
+
|
|
16
|
+
page = Refinery::Page.where(:link_url => "#{url}/new").first_or_create!(
|
|
17
|
+
:title => "<%= class_name.pluralize.underscore.titleize %>",
|
|
18
|
+
:deletable => false,
|
|
19
|
+
:menu_match => "^#{url}(\/|\/.+?|)$"
|
|
20
|
+
)
|
|
21
|
+
thank_you_page = Refinery::Page.where(:link_url => "#{url}/thank_you").first_or_create!(
|
|
22
|
+
:title => "Thank You",
|
|
23
|
+
:deletable => false,
|
|
24
|
+
:show_in_menu => false
|
|
25
|
+
)
|
|
26
|
+
thank_you_page.update_attribute(:parent, page)
|
|
27
|
+
Refinery::Pages.default_parts.each do |default_page_part|
|
|
28
|
+
page.parts.where(:title => default_page_part).first_or_create!(:body => nil)
|
|
29
|
+
thank_you_page.parts.where(:title => default_page_part).first_or_create!(:body => nil)
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
(Refinery::<%= namespacing %>::Setting.methods.sort - Refinery::Setting.methods).each do |setting|
|
|
35
|
+
|
|
36
|
+
Refinery::<%= namespacing %>::Setting.send(setting) unless setting.to_s =~ /=$/
|
|
37
|
+
|
|
38
|
+
end
|
|
39
|
+
|
data/lib/generators/refinery/form/templates/lib/generators/refinery/plural_name_generator.rb.erb
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
module Refinery
|
|
2
|
+
class <%= extension_plural_class_name %>Generator < Rails::Generators::Base
|
|
3
|
+
|
|
4
|
+
def rake_db
|
|
5
|
+
rake "refinery_<%= extension_plural_name %>:install:migrations"
|
|
6
|
+
rake "refinery_settings:install:migrations"
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
def append_load_seed_data
|
|
10
|
+
create_file 'db/seeds.rb' unless File.exists?(File.join(destination_root, 'db', 'seeds.rb'))
|
|
11
|
+
append_file 'db/seeds.rb', :verbose => true do
|
|
12
|
+
<<-EOH
|
|
13
|
+
|
|
14
|
+
Refinery::<%= namespacing %>::Engine.load_seed
|
|
15
|
+
EOH
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
end
|
|
20
|
+
end
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
module Refinery
|
|
2
|
+
module <%= namespacing %>
|
|
3
|
+
class Engine < Rails::Engine
|
|
4
|
+
extend Refinery::Engine
|
|
5
|
+
isolate_namespace Refinery::<%= namespacing %>
|
|
6
|
+
|
|
7
|
+
engine_name :refinery_<%= extension_plural_name %>
|
|
8
|
+
|
|
9
|
+
before_inclusion do
|
|
10
|
+
Refinery::Plugin.register do |plugin|
|
|
11
|
+
plugin.name = "<%= plural_name %>"
|
|
12
|
+
plugin.url = proc { Refinery::Core::Engine.routes.url_helpers.<%= namespacing.underscore %>_admin_<%= plural_name %>_path }
|
|
13
|
+
plugin.pathname = root
|
|
14
|
+
<% unless namespacing.underscore == plural_name -%>plugin.menu_match = %r{refinery/<%= namespacing.underscore %>/<%= plural_name %>(/.*)?$}<% end %>
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
config.after_initialize do
|
|
19
|
+
Refinery.register_extension(Refinery::<%= class_name.pluralize %>)
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
require 'refinerycms-settings'
|
|
2
|
+
require 'refinerycms-core'
|
|
3
|
+
|
|
4
|
+
module Refinery
|
|
5
|
+
module <%= class_name.pluralize %><%= 'Engine' if plural_name == singular_name %>
|
|
6
|
+
require 'refinery/<%= plural_name %>/engine'
|
|
7
|
+
|
|
8
|
+
class << self
|
|
9
|
+
def root
|
|
10
|
+
@root ||= Pathname.new(File.expand_path('../../../', __FILE__))
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def factory_paths
|
|
14
|
+
@factory_paths ||= [ root.join("spec/factories").to_s ]
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
require 'refinery/<%= plural_name %>'
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# <%= extension_plural_name.titleize %> form extension for Refinery CMS.
|
|
2
|
+
|
|
3
|
+
## How to build this extension as a gem (not required)
|
|
4
|
+
|
|
5
|
+
cd vendor/extensions/<%= extension_plural_name %>
|
|
6
|
+
gem build refinerycms-<%= extension_plural_name %>.gemspec
|
|
7
|
+
gem install refinerycms-<%= extension_plural_name %>.gem
|
|
8
|
+
|
|
9
|
+
# Sign up for a https://rubygems.org/ account and publish the gem
|
|
10
|
+
gem push refinerycms-<%= extension_plural_name %>.gem
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# Encoding: UTF-8
|
|
2
|
+
|
|
3
|
+
Gem::Specification.new do |s|
|
|
4
|
+
s.platform = Gem::Platform::RUBY
|
|
5
|
+
s.name = "refinerycms-<%= plural_name %>"
|
|
6
|
+
s.version = "1.0.0"
|
|
7
|
+
s.description = "Ruby on Rails <%= plural_name.titleize %> forms-extension for Refinery CMS"
|
|
8
|
+
s.date = "<%= Time.now.strftime('%Y-%m-%d') %>"
|
|
9
|
+
s.summary = "<%= plural_name.titleize %> forms-extension for Refinery CMS"
|
|
10
|
+
s.require_paths = %w(lib)
|
|
11
|
+
s.files = Dir["{app,config,db,lib}/**/*"] + ["readme.md"]
|
|
12
|
+
s.authors = ["Your Name Here"]
|
|
13
|
+
|
|
14
|
+
# Runtime dependencies
|
|
15
|
+
s.add_dependency "refinerycms-core", "~> <%= Refinery::Version %>"
|
|
16
|
+
s.add_dependency "refinerycms-settings", "~> <%= [Refinery::Version.major, Refinery::Version.minor, 0].join(".") %>"
|
|
17
|
+
s.add_dependency "filters_spam", "~> 0.3"
|
|
18
|
+
s.add_dependency "actionmailer"
|
|
19
|
+
|
|
20
|
+
# Development dependencies (usually used for testing)
|
|
21
|
+
s.add_development_dependency "refinerycms-testing", "~> <%= Refinery::Version %>"
|
|
22
|
+
end
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
# This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
|
|
3
|
+
|
|
4
|
+
ENGINE_PATH = File.expand_path('../..', __FILE__)
|
|
5
|
+
dummy_rails_path = File.expand_path('../../spec/dummy/script/rails', __FILE__)
|
|
6
|
+
if File.exist?(dummy_rails_path)
|
|
7
|
+
load dummy_rails_path
|
|
8
|
+
else
|
|
9
|
+
puts "Please first run 'rake refinery:testing:dummy_app' to create a dummy Refinery CMS application."
|
|
10
|
+
end
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
require "spec_helper"
|
|
2
|
+
|
|
3
|
+
module Refinery
|
|
4
|
+
module <%= namespacing %>
|
|
5
|
+
describe <%= class_name.pluralize %>Controller, type: :controller do
|
|
6
|
+
|
|
7
|
+
before do
|
|
8
|
+
@route = Refinery::<%= namespacing %>::Engine.routes
|
|
9
|
+
Refinery::<%= namespacing %>::Engine::load_seed
|
|
10
|
+
|
|
11
|
+
@new_page = Refinery::Page.new
|
|
12
|
+
allow(Refinery::Page).to receive_messages(:where => [ @new_page ])
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
describe "GET new" do
|
|
16
|
+
it "before_filter assigns a new <%= singular_name %>" do
|
|
17
|
+
get :new
|
|
18
|
+
expect(assigns(:<%= singular_name %>)).to be_a_new(<%= class_name %>)
|
|
19
|
+
end
|
|
20
|
+
it "before_filter assigns page to <%= plural_name %>/new" do
|
|
21
|
+
get :new
|
|
22
|
+
expect(assigns(:page)).to eq @new_page
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
describe "POST create" do
|
|
27
|
+
|
|
28
|
+
before{
|
|
29
|
+
allow_any_instance_of(<%= class_name %>).to receive(:save).and_return( true )
|
|
30
|
+
}
|
|
31
|
+
<% @creationParams = singular_name + ": {" +
|
|
32
|
+
attributes.map { |attribute|
|
|
33
|
+
case attribute.type
|
|
34
|
+
when :image, :resource, :integer
|
|
35
|
+
attribute.name + ": " + "1"
|
|
36
|
+
when :string, :radio, :select
|
|
37
|
+
attribute.name + ": " + '"foo"'
|
|
38
|
+
when :boolean, :checkbox
|
|
39
|
+
attribute.name + ": " + "false"
|
|
40
|
+
end
|
|
41
|
+
}.join(", ") + "}"
|
|
42
|
+
%>
|
|
43
|
+
|
|
44
|
+
it "before_filter assigns page to <%= plural_name %>/new" do
|
|
45
|
+
post :create, <%= @creationParams %>
|
|
46
|
+
expect(assigns(:page)).to eq @new_page
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
it "before_filter assigns a new <%= singular_name %>" do
|
|
50
|
+
post :create, <%= @creationParams %>
|
|
51
|
+
expect(assigns(:<%= singular_name %>)).to be_a_new(<%= class_name %>)
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
it "redirects to thank_you" do
|
|
55
|
+
post :create, <%= @creationParams %>
|
|
56
|
+
expect(response).to redirect_to "/<%= plural_name %>/thank_you"
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
describe "when it can't save the <%= singular_name %>" do
|
|
60
|
+
|
|
61
|
+
before {
|
|
62
|
+
allow_any_instance_of(<%= class_name %>).to receive(:save).and_return( false )
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
it "redirects to new if it can't save" do
|
|
66
|
+
post :create, <%= @creationParams %>
|
|
67
|
+
|
|
68
|
+
expect(response).to render_template(:new)
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
end
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
require "spec_helper"
|
|
3
|
+
|
|
4
|
+
module Refinery
|
|
5
|
+
module <%= namespacing %>
|
|
6
|
+
module Admin
|
|
7
|
+
describe <%= class_name %>, type: :feature do
|
|
8
|
+
refinery_login_with :refinery_user
|
|
9
|
+
<% if (title = attributes.detect { |a| a.type.to_s == "string" }).present? %>
|
|
10
|
+
describe "<%= plural_name %> list" do
|
|
11
|
+
before do
|
|
12
|
+
FactoryGirl.create(:<%= singular_name %>, :<%= title.name %> => "UniqueTitleOne")
|
|
13
|
+
FactoryGirl.create(:<%= singular_name %>, :<%= title.name %> => "UniqueTitleTwo")
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
it "shows two items" do
|
|
17
|
+
visit refinery.<%= namespacing.underscore %>_admin_<%= plural_name %>_path
|
|
18
|
+
expect(page).to have_content("UniqueTitleOne")
|
|
19
|
+
expect(page).to have_content("UniqueTitleTwo")
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
describe "show" do
|
|
24
|
+
let!(:<%= singular_name %>) do
|
|
25
|
+
FactoryGirl.create(:<%= singular_name %>, :<%= title.name %> => "UniqueTitleOne")
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
it "has expected text and menu" do
|
|
29
|
+
visit refinery.<%= namespacing.underscore %>_admin_<%= plural_name %>_path
|
|
30
|
+
|
|
31
|
+
click_link "Read the <%= singular_name %>"
|
|
32
|
+
|
|
33
|
+
expect(page).to have_content("UniqueTitleOne")
|
|
34
|
+
expect(page).not_to have_content("UniqueTitleTwo")
|
|
35
|
+
|
|
36
|
+
within "#actions" do
|
|
37
|
+
expect(page).to have_content("Age")
|
|
38
|
+
expect(page).to have_content("Back to all <%= plural_name %>")
|
|
39
|
+
expect(page).to have_selector("a[href='/#{Refinery::Core.backend_route}/<%= plural_name %>']")
|
|
40
|
+
expect(page).to have_content("Remove this <%= singular_name %> forever")
|
|
41
|
+
expect(page).to have_selector("a[href='/#{Refinery::Core.backend_route}/<%= plural_name %>/#{<%= singular_name %>.id}']")
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
describe "when no " do
|
|
47
|
+
before { Refinery::<%= namespacing %>::<%= class_name %>.destroy_all }
|
|
48
|
+
|
|
49
|
+
context "<%= plural_name %>" do
|
|
50
|
+
it "shows expected message" do
|
|
51
|
+
visit refinery.<%= plural_name %>_admin_<%= plural_name %>_path
|
|
52
|
+
|
|
53
|
+
expect(page).to have_content("You have not received any <%= plural_name %> yet.")
|
|
54
|
+
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
<% if include_spam? %>
|
|
58
|
+
context "spam <%= plural_name %>" do
|
|
59
|
+
it "shows expected message" do
|
|
60
|
+
visit refinery.spam_<%= plural_name %>_admin_<%= plural_name %>_path
|
|
61
|
+
|
|
62
|
+
expect(page).to have_content("Hooray! You don't have any spam.")
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
<% end %>
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
describe "action links" do
|
|
69
|
+
before { visit refinery.<%= plural_name %>_admin_<%= plural_name %>_path }
|
|
70
|
+
|
|
71
|
+
specify "in the side pane" do
|
|
72
|
+
within "#actions" do
|
|
73
|
+
expect(page).to have_content("Inbox")
|
|
74
|
+
expect(page).to have_selector("a[href='/#{Refinery::Core.backend_route}/<%= plural_name %>']")
|
|
75
|
+
<% if include_spam? %>
|
|
76
|
+
expect(page).to have_content("Spam")
|
|
77
|
+
expect(page).to have_selector("a[href='/#{Refinery::Core.backend_route}/<%= plural_name %>/spam']")
|
|
78
|
+
<% end %>
|
|
79
|
+
expect(page).to have_content("Update who gets notified")
|
|
80
|
+
expect(page).to have_selector("a[href*='/#{Refinery::Core.backend_route}/<%= plural_name %>/settings/<%= singular_name %>_notification_recipients/edit']")
|
|
81
|
+
expect(page).to have_content("Edit confirmation email")
|
|
82
|
+
expect(page).to have_selector("a[href*='/#{Refinery::Core.backend_route}/<%= plural_name %>/settings/<%= singular_name %>_confirmation_message/edit']")
|
|
83
|
+
end
|
|
84
|
+
end
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
<% if include_spam? %>
|
|
88
|
+
describe "mark as ham" do
|
|
89
|
+
before { FactoryGirl.create(:<%= singular_name %>, :<%= title.name %> => "UniqueTitleOne") }
|
|
90
|
+
|
|
91
|
+
it "should succeed" do
|
|
92
|
+
visit refinery.<%= namespacing.underscore %>_admin_<%= plural_name %>_path
|
|
93
|
+
|
|
94
|
+
within ".actions" do
|
|
95
|
+
click_link ::I18n.t('mark_as_spam', :scope => "refinery.<%= namespacing.underscore %>.admin.<%= plural_name %>.<%= singular_name %>")
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
expect(Refinery::<%= namespacing %>::<%= class_name %>.count).to eq 1
|
|
99
|
+
expect(Refinery::<%= namespacing %>::<%= class_name %>.ham.count).to eq 0
|
|
100
|
+
expect(Refinery::<%= namespacing %>::<%= class_name %>.spam.count).to eq 1
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
visit refinery.spam_<%= namespacing.underscore %>_admin_<%= plural_name %>_path
|
|
104
|
+
|
|
105
|
+
within ".actions" do
|
|
106
|
+
click_link ::I18n.t('mark_as_ham', :scope => "refinery.<%= namespacing.underscore %>.admin.<%= plural_name %>.<%= singular_name %>")
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
expect(Refinery::<%= namespacing %>::<%= class_name %>.count).to eq 1
|
|
110
|
+
expect(Refinery::<%= namespacing %>::<%= class_name %>.ham.count).to eq 1
|
|
111
|
+
expect(Refinery::<%= namespacing %>::<%= class_name %>.spam.count).to eq 0
|
|
112
|
+
end
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
describe "mark as spam" do
|
|
116
|
+
before { FactoryGirl.create(:<%= singular_name %>, :<%= title.name %> => "A <%= title.name %>") }
|
|
117
|
+
|
|
118
|
+
it "should succeed" do
|
|
119
|
+
visit refinery.<%= namespacing.underscore %>_admin_<%= plural_name %>_path
|
|
120
|
+
|
|
121
|
+
expect(Refinery::<%= namespacing %>::<%= class_name %>.count).to eq 1
|
|
122
|
+
expect(Refinery::<%= namespacing %>::<%= class_name %>.ham.count).to eq 1
|
|
123
|
+
expect(Refinery::<%= namespacing %>::<%= class_name %>.spam.count).to eq 0
|
|
124
|
+
|
|
125
|
+
within ".actions" do
|
|
126
|
+
click_link ::I18n.t('mark_as_spam', :scope => "refinery.<%= namespacing.underscore %>.admin.<%= plural_name %>.<%= singular_name %>")
|
|
127
|
+
|
|
128
|
+
end
|
|
129
|
+
|
|
130
|
+
expect(Refinery::<%= namespacing %>::<%= class_name %>.count).to eq 1
|
|
131
|
+
expect(Refinery::<%= namespacing %>::<%= class_name %>.ham.count).to eq 0
|
|
132
|
+
expect(Refinery::<%= namespacing %>::<%= class_name %>.spam.count).to eq 1
|
|
133
|
+
end
|
|
134
|
+
end
|
|
135
|
+
<% end %>
|
|
136
|
+
|
|
137
|
+
describe "destroy" do
|
|
138
|
+
before { FactoryGirl.create(:<%= singular_name %>, :<%= title.name %> => "UniqueTitleOne") }
|
|
139
|
+
|
|
140
|
+
it "should succeed" do
|
|
141
|
+
visit refinery.<%= namespacing.underscore %>_admin_<%= plural_name %>_path
|
|
142
|
+
|
|
143
|
+
click_link "Remove this <%= singular_name.titleize.downcase %> forever"
|
|
144
|
+
|
|
145
|
+
expect(page).to have_content("'UniqueTitleOne' was successfully removed.")
|
|
146
|
+
expect(Refinery::<%= namespacing %>::<%= class_name %>.count).to eq 0
|
|
147
|
+
end
|
|
148
|
+
end
|
|
149
|
+
|
|
150
|
+
describe "destroy from <%= singular_name %> show page" do
|
|
151
|
+
before { FactoryGirl.create(:<%= singular_name %>, :<%= title.name %> => "UniqueTitleOne") }
|
|
152
|
+
|
|
153
|
+
it "should succeed" do
|
|
154
|
+
visit refinery.<%= namespacing.underscore %>_admin_<%= singular_name %>_path( :id => '1')
|
|
155
|
+
|
|
156
|
+
click_link "Remove this <%= singular_name.titleize.downcase %> forever"
|
|
157
|
+
|
|
158
|
+
expect(page).to have_content("'UniqueTitleOne' was successfully removed.")
|
|
159
|
+
expect(Refinery::<%= namespacing %>::<%= class_name %>.count).to eq 0
|
|
160
|
+
end
|
|
161
|
+
end
|
|
162
|
+
<% end %>
|
|
163
|
+
end
|
|
164
|
+
end
|
|
165
|
+
end
|
|
166
|
+
end
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
require "spec_helper"
|
|
3
|
+
|
|
4
|
+
module Refinery
|
|
5
|
+
module <%= namespacing %>
|
|
6
|
+
describe "Settings", type: :feature do
|
|
7
|
+
refinery_login_with :refinery_user
|
|
8
|
+
<% if (title = attributes.detect { |a| a.type.to_s == "string" }).present? %>
|
|
9
|
+
describe "update who gets notified" do
|
|
10
|
+
before do
|
|
11
|
+
Rails.cache.clear
|
|
12
|
+
Refinery::<%= namespacing %>::Setting.notification_recipients
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
it "sets receiver", :js => true do
|
|
16
|
+
visit refinery.<%= plural_name %>_admin_<%= plural_name %>_path
|
|
17
|
+
|
|
18
|
+
click_link ::I18n.t('update_notified', scope: 'refinery.<%= namespacing.underscore %>.admin.<%= plural_name %>.submenu')
|
|
19
|
+
|
|
20
|
+
within_frame "dialog_iframe" do
|
|
21
|
+
fill_in ::I18n.t('<%= singular_name %>_settings_value_name', scope: 'refinery.<%= namespacing.underscore %>.admin.settings.notification_recipients_form'), :with => "phil@refinerycms.com"
|
|
22
|
+
click_button "submit_button"
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
expect(page).to have_content("Notification Recipients was successfully updated.")
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
describe "updating confirmation email copy" do
|
|
30
|
+
before do
|
|
31
|
+
Rails.cache.clear
|
|
32
|
+
Refinery::<%= namespacing %>::Setting.confirmation_message
|
|
33
|
+
Refinery::<%= namespacing %>::Setting.confirmation_subject
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
it "sets subject and message", :js => true do
|
|
37
|
+
visit refinery.<%= plural_name %>_admin_<%= plural_name %>_path
|
|
38
|
+
|
|
39
|
+
click_link ::I18n.t('edit_confirmation_email', scope: 'refinery.<%= namespacing.underscore %>.admin.<%= plural_name %>.submenu')
|
|
40
|
+
|
|
41
|
+
within_frame "dialog_iframe" do
|
|
42
|
+
fill_in ::I18n.t('subject', scope: 'refinery.<%= namespacing.underscore %>.admin.settings.confirmation_email_form'), :with => "subject"
|
|
43
|
+
fill_in ::I18n.t('message', scope: 'refinery.<%= namespacing.underscore %>.admin.settings.confirmation_email_form'), :with => "message"
|
|
44
|
+
|
|
45
|
+
click_button "submit_button"
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
expect(page).to have_content("Confirmation Message was successfully updated.")
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
<% end %>
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
end
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
require "spec_helper"
|
|
3
|
+
|
|
4
|
+
module Refinery
|
|
5
|
+
module <%= namespacing %>
|
|
6
|
+
describe "<%= plural_name %>", type: :feature do
|
|
7
|
+
|
|
8
|
+
before(:each) do
|
|
9
|
+
Refinery::<%= namespacing %>::Engine::load_seed
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
describe "Create <%= singular_name %>" do
|
|
13
|
+
|
|
14
|
+
before do
|
|
15
|
+
visit refinery.new_<%= plural_name %>_<%= singular_name %>_path
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
it "should create a new item" do
|
|
19
|
+
<% attributes.each do |a| -%><% if a.type == :string -%>
|
|
20
|
+
fill_in "<%= singular_name %>_<%= a.name %>", :with => "Test"
|
|
21
|
+
<% elsif a.type == :text -%>
|
|
22
|
+
fill_in "<%= singular_name %>_<%= a.name %>", :with => "Test"
|
|
23
|
+
<% end -%><% end -%>
|
|
24
|
+
|
|
25
|
+
click_button ::I18n.t('.refinery.<%= plural_name %>.<%= plural_name %>.new.send')
|
|
26
|
+
|
|
27
|
+
expect(page).to have_content("Thank You")
|
|
28
|
+
expect(Refinery::<%= namespacing %>::<%= class_name %>.count).to eq(1)
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
module Refinery
|
|
4
|
+
module <%= namespacing %>
|
|
5
|
+
describe Setting, :type => :model do
|
|
6
|
+
describe ".confirmation_message=" do
|
|
7
|
+
it "delegates to Refinery::Setting#set" do
|
|
8
|
+
expect(Refinery::Setting).to receive(:set).
|
|
9
|
+
with(:<%= singular_name %>_confirmation_message, "some value")
|
|
10
|
+
|
|
11
|
+
Refinery::<%= namespacing %>::Setting.confirmation_message = "some value"
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
describe ".confirmation_subject=" do
|
|
16
|
+
it "delegates to Refinery::Setting#set" do
|
|
17
|
+
expect(Refinery::Setting).to receive(:set).
|
|
18
|
+
with(:<%= singular_name %>_confirmation_subject, "some value")
|
|
19
|
+
|
|
20
|
+
Refinery::<%= namespacing %>::Setting.confirmation_subject = "some value"
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
describe ".notification_recipients=" do
|
|
25
|
+
it "delegates to Refinery::Setting#set" do
|
|
26
|
+
expect(Refinery::Setting).to receive(:set).
|
|
27
|
+
with(:<%= singular_name %>_notification_recipients, "some value")
|
|
28
|
+
|
|
29
|
+
Refinery::<%= namespacing %>::Setting.notification_recipients = "some value"
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|