trusty-cms 4.1.7 → 4.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +131 -128
- data/INSTALL.md +2 -0
- data/LICENSE.md +1 -1
- data/app/controllers/admin/pages_controller.rb +1 -1
- data/app/controllers/admin/preferences_controller.rb +1 -1
- data/app/controllers/admin/resource_controller.rb +1 -1
- data/app/controllers/admin/users_controller.rb +1 -1
- data/app/helpers/admin/node_helper.rb +1 -1
- data/app/models/asset.rb +3 -3
- data/app/models/page.rb +3 -3
- data/app/models/standard_tags.rb +3 -3
- data/app/models/user.rb +1 -1
- data/config/database.mysql.yml +10 -2
- data/config/environments/development.rb +2 -0
- data/db/migrate/20210331134718_create_active_storage_tables.active_storage.rb +36 -0
- data/lib/generators/extension/USAGE +30 -0
- data/lib/generators/extension/extension_generator.rb +97 -0
- data/lib/generators/extension/templates/README.md +6 -0
- data/lib/generators/extension/templates/RSpecRakefile +109 -0
- data/lib/generators/extension/templates/Rakefile +25 -0
- data/lib/generators/extension/templates/cucumber.yml +1 -0
- data/lib/generators/extension/templates/cucumber_env.rb +11 -0
- data/lib/generators/extension/templates/cucumber_paths.rb +22 -0
- data/lib/generators/extension/templates/en.yml +3 -0
- data/lib/generators/extension/templates/extension.rb +21 -0
- data/lib/generators/extension/templates/functional_test.rb +15 -0
- data/lib/generators/extension/templates/gemspec.rb +29 -0
- data/lib/generators/extension/templates/lib.rb +8 -0
- data/lib/generators/extension/templates/migration.rb +9 -0
- data/lib/generators/extension/templates/radiant_config.rb +3 -0
- data/lib/generators/extension/templates/routes.rb +5 -0
- data/lib/generators/extension/templates/spec.opts +6 -0
- data/lib/generators/extension/templates/spec_helper.rb +42 -0
- data/lib/generators/extension/templates/tasks.rake +47 -0
- data/lib/generators/extension/templates/test_helper.rb +24 -0
- data/lib/generators/extension_controller/USAGE +36 -0
- data/lib/generators/extension_controller/extension_controller_generator.rb +84 -0
- data/lib/generators/extension_controller/templates/controller.rb +10 -0
- data/lib/generators/extension_controller/templates/controller_spec.rb +23 -0
- data/lib/generators/extension_controller/templates/functional_test.rb +11 -0
- data/lib/generators/extension_controller/templates/helper.rb +2 -0
- data/lib/generators/extension_controller/templates/helper_spec.rb +11 -0
- data/lib/generators/extension_controller/templates/helper_test.rb +4 -0
- data/lib/generators/extension_controller/templates/view.html.erb +2 -0
- data/lib/generators/extension_controller/templates/view_spec.rb +12 -0
- data/lib/generators/extension_mailer/USAGE +17 -0
- data/lib/generators/extension_mailer/extension_mailer_generator.rb +68 -0
- data/lib/generators/extension_mailer/templates/fixture.erb +3 -0
- data/lib/generators/extension_mailer/templates/mailer.rb +15 -0
- data/lib/generators/extension_mailer/templates/unit_test.rb +21 -0
- data/lib/generators/extension_mailer/templates/view.erb +3 -0
- data/lib/generators/extension_migration/USAGE +34 -0
- data/lib/generators/extension_migration/extension_migration_generator.rb +25 -0
- data/lib/generators/extension_migration/templates/migration.rb +11 -0
- data/lib/generators/extension_model/USAGE +35 -0
- data/lib/generators/extension_model/extension_model_generator.rb +68 -0
- data/lib/generators/extension_model/templates/fixtures.yml +19 -0
- data/lib/generators/extension_model/templates/migration.rb +16 -0
- data/lib/generators/extension_model/templates/model.rb +2 -0
- data/lib/generators/extension_model/templates/model_spec.rb +11 -0
- data/lib/generators/extension_model/templates/unit_test.rb +8 -0
- data/lib/generators/generator_base_extension.rb +18 -0
- data/lib/generators/instance/instance_generator.rb +148 -0
- data/lib/generators/instance/templates/databases/db2.yml +40 -0
- data/lib/generators/instance/templates/databases/mysql.yml +47 -0
- data/lib/generators/instance/templates/databases/postgresql.yml +44 -0
- data/lib/generators/instance/templates/databases/sqlite3.yml +16 -0
- data/lib/generators/instance/templates/databases/sqlserver.yml +21 -0
- data/lib/generators/instance/templates/instance_boot.rb +122 -0
- data/lib/generators/instance/templates/instance_config.ru +2 -0
- data/lib/generators/instance/templates/instance_environment.rb +93 -0
- data/lib/generators/instance/templates/instance_gemfile +78 -0
- data/lib/generators/instance/templates/instance_generate +6 -0
- data/lib/generators/instance/templates/instance_radiant_config.rb +16 -0
- data/lib/generators/instance/templates/instance_rakefile +3 -0
- data/lib/generators/instance/templates/instance_routes.rb +1 -0
- data/lib/generators/language_extension/USAGE +27 -0
- data/lib/generators/language_extension/language_extension_generator.rb +71 -0
- data/lib/generators/language_extension/templates/README +3 -0
- data/lib/generators/language_extension/templates/RSpecRakefile +123 -0
- data/lib/generators/language_extension/templates/Rakefile +25 -0
- data/lib/generators/language_extension/templates/available_tags.yml +553 -0
- data/lib/generators/language_extension/templates/cucumber.yml +1 -0
- data/lib/generators/language_extension/templates/cucumber_env.rb +16 -0
- data/lib/generators/language_extension/templates/cucumber_paths.rb +14 -0
- data/lib/generators/language_extension/templates/extension.rb +12 -0
- data/lib/generators/language_extension/templates/functional_test.rb +15 -0
- data/lib/generators/language_extension/templates/gemspec.rb +24 -0
- data/lib/generators/language_extension/templates/lang.yml +181 -0
- data/lib/generators/language_extension/templates/lib.rb +8 -0
- data/lib/generators/language_extension/templates/spec.opts +6 -0
- data/lib/generators/language_extension/templates/spec_helper.rb +36 -0
- data/lib/generators/language_extension/templates/tasks.rake +28 -0
- data/lib/generators/language_extension/templates/test_helper.rb +26 -0
- data/lib/generators/trusty_cms/USAGE +8 -0
- data/lib/generators/trusty_cms/templates/Rakefile.erb +7 -0
- data/lib/generators/trusty_cms/templates/application.rb.erb +149 -0
- data/lib/generators/trusty_cms/templates/boot.rb.erb +9 -0
- data/lib/generators/trusty_cms/templates/config.ru.erb +4 -0
- data/lib/generators/trusty_cms/templates/database.yml.erb +28 -0
- data/lib/generators/trusty_cms/templates/environment.rb.erb +5 -0
- data/lib/generators/trusty_cms/templates/environments/development.rb.erb +24 -0
- data/lib/generators/trusty_cms/templates/environments/production.rb.erb +26 -0
- data/lib/generators/trusty_cms/templates/environments/test.rb.erb +35 -0
- data/lib/generators/trusty_cms/templates/initializers/secret_token.rb.erb +13 -0
- data/lib/generators/trusty_cms/templates/initializers/session_store.rb.erb +8 -0
- data/lib/generators/trusty_cms/templates/initializers/trusty_cms_config.rb.erb +16 -0
- data/lib/generators/trusty_cms/templates/preinitializer.rb.erb +18 -0
- data/lib/generators/trusty_cms/templates/routes.rb.erb +0 -0
- data/lib/generators/trusty_cms/trusty_cms_generator.rb +32 -0
- data/lib/login_system.rb +1 -1
- data/lib/trusty_cms.rb +1 -1
- data/lib/trusty_cms/setup.rb +8 -8
- data/spec/dummy/config/database.yml +6 -2
- data/trusty_cms.gemspec +4 -5
- data/vendor/extensions/clipped-extension/lib/asset_tags.rb +4 -4
- data/yarn.lock +3 -3
- metadata +144 -84
- data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/core.js +0 -126
- data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/failsafe/index.js +0 -4
- data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/failsafe/map.js +0 -56
- data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/failsafe/seq.js +0 -43
- data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/failsafe/string.js +0 -28
- data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/index.js +0 -36
- data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/json.js +0 -76
- data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/options.js +0 -23
- data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/yaml-1.1/binary.js +0 -87
- data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/yaml-1.1/index.js +0 -157
- data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/yaml-1.1/omap.js +0 -142
- data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/yaml-1.1/pairs.js +0 -81
- data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/yaml-1.1/set.js +0 -114
- data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/yaml-1.1/timestamp.js +0 -97
- data/spec/spec/dummy/node_modules/yaml/dist/tags/core.js +0 -114
- data/spec/spec/dummy/node_modules/yaml/dist/tags/failsafe/index.js +0 -17
- data/spec/spec/dummy/node_modules/yaml/dist/tags/failsafe/map.js +0 -37
- data/spec/spec/dummy/node_modules/yaml/dist/tags/failsafe/seq.js +0 -34
- data/spec/spec/dummy/node_modules/yaml/dist/tags/failsafe/string.js +0 -40
- data/spec/spec/dummy/node_modules/yaml/dist/tags/index.js +0 -62
- data/spec/spec/dummy/node_modules/yaml/dist/tags/json.js +0 -60
- data/spec/spec/dummy/node_modules/yaml/dist/tags/options.js +0 -35
- data/spec/spec/dummy/node_modules/yaml/dist/tags/yaml-1.1/binary.js +0 -97
- data/spec/spec/dummy/node_modules/yaml/dist/tags/yaml-1.1/index.js +0 -131
- data/spec/spec/dummy/node_modules/yaml/dist/tags/yaml-1.1/omap.js +0 -105
- data/spec/spec/dummy/node_modules/yaml/dist/tags/yaml-1.1/pairs.js +0 -80
- data/spec/spec/dummy/node_modules/yaml/dist/tags/yaml-1.1/set.js +0 -91
- data/spec/spec/dummy/node_modules/yaml/dist/tags/yaml-1.1/timestamp.js +0 -93
data/LICENSE.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# MIT License
|
2
2
|
|
3
|
-
Copyright (c) 2006-
|
3
|
+
Copyright (c) 2006-2021, John W. Long and Sean D. Cribbs.
|
4
4
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
6
|
of this software and associated documentation files (the "Software"), to deal
|
@@ -75,7 +75,7 @@ class Admin::PagesController < Admin::ResourceController
|
|
75
75
|
if request.referer =~ %r{/admin/pages/(\d+)/edit}
|
76
76
|
page = Page.find($1).becomes(page_class)
|
77
77
|
layout_id = page.layout_id
|
78
|
-
page.
|
78
|
+
page.update(params[:page])
|
79
79
|
page.published_at ||= Time.now
|
80
80
|
else
|
81
81
|
page = page_class.new(params[:page])
|
@@ -11,7 +11,7 @@ class Admin::PreferencesController < ApplicationController
|
|
11
11
|
end
|
12
12
|
|
13
13
|
def update
|
14
|
-
if @user.
|
14
|
+
if @user.update(preferences_params)
|
15
15
|
redirect_to admin_configuration_path
|
16
16
|
else
|
17
17
|
flash[:error] = t('preferences_controller.error_updating')
|
@@ -59,7 +59,7 @@ class Admin::ResourceController < ApplicationController
|
|
59
59
|
%i[create update].each do |action|
|
60
60
|
class_eval %{
|
61
61
|
def #{action} # def create
|
62
|
-
model.
|
62
|
+
model.update!(permitted_params[model_symbol]) # model.update!(params[model_symbol])
|
63
63
|
response_for :#{action} # response_for :create
|
64
64
|
end # end
|
65
65
|
}, __FILE__, __LINE__
|
@@ -29,7 +29,7 @@ class Admin::UsersController < Admin::ResourceController
|
|
29
29
|
announce_cannot_remove_self_from_admin_role
|
30
30
|
end
|
31
31
|
model.skip_password_validation = true unless user_params[:password_confirmation].present?
|
32
|
-
if model.
|
32
|
+
if model.update(user_params)
|
33
33
|
response_for :update
|
34
34
|
else
|
35
35
|
flash[:error] = 'There was an error saving the user. Please try again.'
|
@@ -10,7 +10,7 @@ module Admin::NodeHelper
|
|
10
10
|
|
11
11
|
@rendered_html += (render partial: 'admin/pages/node',
|
12
12
|
locals: { level: index, index: index, parent_index: parent_index,
|
13
|
-
page: page, simple: simple, branch: (page.children.count
|
13
|
+
page: page, simple: simple, branch: (page.children.count.positive?) })
|
14
14
|
index
|
15
15
|
end
|
16
16
|
|
data/app/models/asset.rb
CHANGED
@@ -74,12 +74,12 @@ class Asset < ActiveRecord::Base
|
|
74
74
|
|
75
75
|
def thumbnail(style_name = 'original')
|
76
76
|
return asset.url if style_name.to_sym == :original
|
77
|
-
return asset.url(style_name.to_sym) if
|
77
|
+
return asset.url(style_name.to_sym) if style?(style_name)
|
78
78
|
|
79
79
|
asset_type.icon(style_name)
|
80
80
|
end
|
81
81
|
|
82
|
-
def
|
82
|
+
def style?(style_name = 'original')
|
83
83
|
style_name == 'original' || paperclip_styles.keys.include?(style_name.to_sym)
|
84
84
|
end
|
85
85
|
|
@@ -110,7 +110,7 @@ class Asset < ActiveRecord::Base
|
|
110
110
|
end
|
111
111
|
|
112
112
|
def geometry(style_name = 'original')
|
113
|
-
raise Paperclip::StyleError, "Requested style #{style_name} is not defined for this asset." unless
|
113
|
+
raise Paperclip::StyleError, "Requested style #{style_name} is not defined for this asset." unless style?(style_name)
|
114
114
|
|
115
115
|
@geometry ||= {}
|
116
116
|
begin
|
data/app/models/page.rb
CHANGED
@@ -76,16 +76,16 @@ class Page < ActiveRecord::Base
|
|
76
76
|
end
|
77
77
|
end
|
78
78
|
|
79
|
-
def
|
79
|
+
def part?(name)
|
80
80
|
!part(name).nil?
|
81
81
|
end
|
82
82
|
|
83
83
|
def has_or_inherits_part?(name)
|
84
|
-
|
84
|
+
part?(name) || inherits_part?(name)
|
85
85
|
end
|
86
86
|
|
87
87
|
def inherits_part?(name)
|
88
|
-
!
|
88
|
+
!part?(name) && ancestors.any? { |page| page.part?(name) }
|
89
89
|
end
|
90
90
|
|
91
91
|
def field(name)
|
data/app/models/standard_tags.rb
CHANGED
@@ -312,7 +312,7 @@ module StandardTags
|
|
312
312
|
}
|
313
313
|
tag 'if_children' do |tag|
|
314
314
|
children = tag.locals.page.children.where(children_find_options(tag)[:conditions]).count
|
315
|
-
tag.expand if children
|
315
|
+
tag.expand if children.positive?
|
316
316
|
end
|
317
317
|
|
318
318
|
desc %{
|
@@ -327,7 +327,7 @@ module StandardTags
|
|
327
327
|
}
|
328
328
|
tag 'unless_children' do |tag|
|
329
329
|
children = tag.locals.page.children.where(children_find_options(tag)[:conditions]).count
|
330
|
-
tag.expand unless children
|
330
|
+
tag.expand unless children.positive?
|
331
331
|
end
|
332
332
|
|
333
333
|
desc %{
|
@@ -961,7 +961,7 @@ module StandardTags
|
|
961
961
|
page_path = remove_trailing_slash(path)
|
962
962
|
hash[:title] = title
|
963
963
|
hash[:path] = path
|
964
|
-
tag.locals.first_child = i
|
964
|
+
tag.locals.first_child = i.zero?
|
965
965
|
tag.locals.last_child = i == pairs.length - 1
|
966
966
|
result << case page_path
|
967
967
|
when compare_path
|
data/app/models/user.rb
CHANGED
data/config/database.mysql.yml
CHANGED
@@ -2,6 +2,9 @@
|
|
2
2
|
# This is only an example configuration. Please see the Rails
|
3
3
|
# documentation for more details.
|
4
4
|
#
|
5
|
+
defaults: &defaults
|
6
|
+
adapter: mysql
|
7
|
+
db: localhost
|
5
8
|
|
6
9
|
development:
|
7
10
|
adapter: mysql2
|
@@ -10,10 +13,15 @@ development:
|
|
10
13
|
password:
|
11
14
|
|
12
15
|
test: &TEST
|
13
|
-
adapter:
|
16
|
+
adapter: mysql2
|
14
17
|
database: trusty_cms_test
|
15
18
|
username: root
|
16
|
-
password:
|
19
|
+
password: ''
|
20
|
+
db: '127.0.0.1'
|
21
|
+
port: 0
|
22
|
+
encoding: utf8mb4
|
23
|
+
charset: utf8mb4
|
24
|
+
collation: utf8mb4_bin
|
17
25
|
|
18
26
|
production:
|
19
27
|
adapter: mysql2
|
@@ -0,0 +1,36 @@
|
|
1
|
+
# This migration comes from active_storage (originally 20170806125915)
|
2
|
+
class CreateActiveStorageTables < ActiveRecord::Migration[5.2]
|
3
|
+
def change
|
4
|
+
create_table :active_storage_blobs do |t|
|
5
|
+
t.string :key, null: false
|
6
|
+
t.string :filename, null: false
|
7
|
+
t.string :content_type
|
8
|
+
t.text :metadata
|
9
|
+
t.string :service_name, null: false
|
10
|
+
t.bigint :byte_size, null: false
|
11
|
+
t.string :checksum, null: false
|
12
|
+
t.datetime :created_at, null: false
|
13
|
+
|
14
|
+
t.index [ :key ], unique: true
|
15
|
+
end
|
16
|
+
|
17
|
+
create_table :active_storage_attachments do |t|
|
18
|
+
t.string :name, null: false
|
19
|
+
t.references :record, null: false, polymorphic: true, index: false
|
20
|
+
t.references :blob, null: false
|
21
|
+
|
22
|
+
t.datetime :created_at, null: false
|
23
|
+
|
24
|
+
t.index [ :record_type, :record_id, :name, :blob_id ], name: "index_active_storage_attachments_uniqueness", unique: true
|
25
|
+
t.foreign_key :active_storage_blobs, column: :blob_id
|
26
|
+
end
|
27
|
+
|
28
|
+
create_table :active_storage_variant_records do |t|
|
29
|
+
t.belongs_to :blob, null: false, index: false
|
30
|
+
t.string :variation_digest, null: false
|
31
|
+
|
32
|
+
t.index %i[ blob_id variation_digest ], name: "index_active_storage_variant_records_uniqueness", unique: true
|
33
|
+
t.foreign_key :active_storage_blobs, column: :blob_id
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
Description:
|
2
|
+
The extension generator creates stubs for a new TrustyCms extension.
|
3
|
+
|
4
|
+
The generator takes an extension name as its argument. The extension name may be
|
5
|
+
given in CamelCase or under_score and should not be suffixed with 'Extension'.
|
6
|
+
|
7
|
+
The generator creates an extension directory in vendor/extensions that includes
|
8
|
+
<extension_name>_extension.rb, README and Rakefile files as well as db, lib, task,
|
9
|
+
and test directories.
|
10
|
+
|
11
|
+
Example:
|
12
|
+
./script/generate extension AssetManagement
|
13
|
+
|
14
|
+
This will create:
|
15
|
+
vendor/extensions/asset_management/app/controllers
|
16
|
+
vendor/extensions/asset_management/app/helpers
|
17
|
+
vendor/extensions/asset_management/app/models
|
18
|
+
vendor/extensions/asset_management/app/views
|
19
|
+
vendor/extensions/asset_management/db/migrate
|
20
|
+
vendor/extensions/asset_management/lib/tasks
|
21
|
+
vendor/extensions/asset_management/README
|
22
|
+
vendor/extensions/asset_management/asset_management_extension.rb
|
23
|
+
vendor/extensions/asset_management/lib/tasks/asset_management_extension_tasks.rake
|
24
|
+
vendor/extensions/asset_management/spec/controllers
|
25
|
+
vendor/extensions/asset_management/spec/models
|
26
|
+
vendor/extensions/asset_management/spec/views
|
27
|
+
vendor/extensions/asset_management/spec/helpers
|
28
|
+
vendor/extensions/asset_management/Rakefile
|
29
|
+
vendor/extensions/asset_management/spec/spec_helper.rb
|
30
|
+
vendor/extensions/asset_management/spec/spec.opts
|
@@ -0,0 +1,97 @@
|
|
1
|
+
begin
|
2
|
+
require 'git'
|
3
|
+
rescue LoadError
|
4
|
+
end
|
5
|
+
|
6
|
+
class ExtensionGenerator < Rails::Generator::NamedBase
|
7
|
+
default_options :with_test_unit => false
|
8
|
+
|
9
|
+
attr_reader :extension_path, :extension_file_name
|
10
|
+
|
11
|
+
def initialize(runtime_args, runtime_options = {})
|
12
|
+
super
|
13
|
+
@extension_file_name = "#{file_name}_extension"
|
14
|
+
@extension_path = "vendor/extensions/#{file_name}"
|
15
|
+
end
|
16
|
+
|
17
|
+
def manifest
|
18
|
+
record do |m|
|
19
|
+
m.directory "#{extension_path}/app/controllers"
|
20
|
+
m.directory "#{extension_path}/app/helpers"
|
21
|
+
m.directory "#{extension_path}/app/models"
|
22
|
+
m.directory "#{extension_path}/app/views"
|
23
|
+
m.directory "#{extension_path}/config/locales"
|
24
|
+
m.directory "#{extension_path}/config/initializers"
|
25
|
+
m.directory "#{extension_path}/db/migrate"
|
26
|
+
m.directory "#{extension_path}/lib/tasks"
|
27
|
+
|
28
|
+
m.template 'README.md', "#{extension_path}/README.md"
|
29
|
+
m.template 'extension.rb', "#{extension_path}/#{extension_file_name}.rb"
|
30
|
+
m.template 'tasks.rake', "#{extension_path}/lib/tasks/#{extension_file_name}_tasks.rake"
|
31
|
+
m.template 'en.yml', "#{extension_path}/config/locales/en.yml"
|
32
|
+
m.template 'routes.rb', "#{extension_path}/config/routes.rb"
|
33
|
+
m.template 'radiant_config.rb', "#{extension_path}/config/initializers/radiant_config.rb"
|
34
|
+
m.template 'lib.rb', "#{extension_path}/lib/radiant-#{file_name}-extension.rb"
|
35
|
+
m.template 'gemspec.rb', "#{extension_path}/radiant-#{file_name}-extension.gemspec"
|
36
|
+
|
37
|
+
if options[:with_test_unit]
|
38
|
+
m.directory "#{extension_path}/test/fixtures"
|
39
|
+
m.directory "#{extension_path}/test/functional"
|
40
|
+
m.directory "#{extension_path}/test/unit"
|
41
|
+
|
42
|
+
m.template 'Rakefile', "#{extension_path}/Rakefile"
|
43
|
+
m.template 'test_helper.rb', "#{extension_path}/test/test_helper.rb"
|
44
|
+
m.template 'functional_test.rb', "#{extension_path}/test/functional/#{extension_file_name}_test.rb"
|
45
|
+
else
|
46
|
+
m.directory "#{extension_path}/spec/controllers"
|
47
|
+
m.directory "#{extension_path}/spec/models"
|
48
|
+
m.directory "#{extension_path}/spec/views"
|
49
|
+
m.directory "#{extension_path}/spec/helpers"
|
50
|
+
m.directory "#{extension_path}/features/support"
|
51
|
+
m.directory "#{extension_path}/features/step_definitions/admin"
|
52
|
+
|
53
|
+
m.template 'RSpecRakefile', "#{extension_path}/Rakefile"
|
54
|
+
m.template 'spec_helper.rb', "#{extension_path}/spec/spec_helper.rb"
|
55
|
+
m.file 'spec.opts', "#{extension_path}/spec/spec.opts"
|
56
|
+
m.file 'cucumber.yml', "#{extension_path}/cucumber.yml"
|
57
|
+
m.template 'cucumber_env.rb', "#{extension_path}/features/support/env.rb"
|
58
|
+
m.template 'cucumber_paths.rb', "#{extension_path}/features/support/paths.rb"
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
def class_name
|
64
|
+
super.to_name.gsub(' ', '') + 'Extension'
|
65
|
+
end
|
66
|
+
|
67
|
+
def extension_name
|
68
|
+
class_name.to_name('Extension')
|
69
|
+
end
|
70
|
+
|
71
|
+
def author_info
|
72
|
+
@author_info ||= begin
|
73
|
+
Git.global_config
|
74
|
+
rescue NameError
|
75
|
+
{}
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
def homepage
|
80
|
+
author_info['github.user'] ? "http://github.com/#{author_info['github.user']}/radiant-#{file_name}-extension" : "http://example.com/#{file_name}"
|
81
|
+
end
|
82
|
+
|
83
|
+
def author_email
|
84
|
+
author_info['user.email'] || 'your email'
|
85
|
+
end
|
86
|
+
|
87
|
+
def author_name
|
88
|
+
author_info['user.name'] || 'Your Name'
|
89
|
+
end
|
90
|
+
|
91
|
+
def add_options!(opt)
|
92
|
+
opt.separator ''
|
93
|
+
opt.separator 'Options:'
|
94
|
+
opt.on("--with-test-unit",
|
95
|
+
"Use Test::Unit for this extension instead of RSpec") { |v| options[:with_test_unit] = v }
|
96
|
+
end
|
97
|
+
end
|
@@ -0,0 +1,6 @@
|
|
1
|
+
# <%= extension_name %>
|
2
|
+
|
3
|
+
TrustyCms is _so_ freaking awesome, but I made it better through this extension.
|
4
|
+
|
5
|
+
Created by <%= author_name %>. <%- if author_email.include?('@') -%>If I don't update this content with real details,
|
6
|
+
please contact me at <%= author_email %> with annoying messages telling me to do it.<%- end -%>
|
@@ -0,0 +1,109 @@
|
|
1
|
+
# Determine where the RSpec plugin is by loading the boot
|
2
|
+
unless defined? TRUSTY_CMS_ROOT
|
3
|
+
ENV["Rails.env"] = "test"
|
4
|
+
case
|
5
|
+
when ENV["RADIANT_ENV_FILE"]
|
6
|
+
require File.dirname(ENV["RADIANT_ENV_FILE"]) + "/boot"
|
7
|
+
when File.dirname(__FILE__) =~ %r{vendor/trusty_cms/vendor/extensions}
|
8
|
+
require "#{File.expand_path(File.dirname(__FILE__) + "/../../../../../")}/config/boot"
|
9
|
+
else
|
10
|
+
require "#{File.expand_path(File.dirname(__FILE__) + "/../../../")}/config/boot"
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
require 'rake'
|
15
|
+
require 'rdoc/task'
|
16
|
+
require 'rake/testtask'
|
17
|
+
|
18
|
+
rspec_base = File.expand_path(TRUSTY_CMS_ROOT + '/vendor/plugins/rspec/lib')
|
19
|
+
$LOAD_PATH.unshift(rspec_base) if File.exist?(rspec_base)
|
20
|
+
require 'spec/rake/spectask'
|
21
|
+
require 'cucumber'
|
22
|
+
require 'cucumber/rake/task'
|
23
|
+
|
24
|
+
# Cleanup the TRUSTY_CMS_ROOT constant so specs will load the environment
|
25
|
+
Object.send(:remove_const, :TRUSTY_CMS_ROOT)
|
26
|
+
|
27
|
+
extension_root = File.expand_path(File.dirname(__FILE__))
|
28
|
+
|
29
|
+
task :default => [:spec, :features]
|
30
|
+
task :stats => "spec:statsetup"
|
31
|
+
|
32
|
+
desc "Run all specs in spec directory"
|
33
|
+
Spec::Rake::SpecTask.new(:spec) do |t|
|
34
|
+
t.spec_opts = ['--options', "\"#{extension_root}/spec/spec.opts\""]
|
35
|
+
t.spec_files = FileList['spec/**/*_spec.rb']
|
36
|
+
end
|
37
|
+
|
38
|
+
task :features => 'spec:integration'
|
39
|
+
|
40
|
+
namespace :spec do
|
41
|
+
desc "Run all specs in spec directory with RCov"
|
42
|
+
Spec::Rake::SpecTask.new(:rcov) do |t|
|
43
|
+
t.spec_opts = ['--options', "\"#{extension_root}/spec/spec.opts\""]
|
44
|
+
t.spec_files = FileList['spec/**/*_spec.rb']
|
45
|
+
t.rcov = true
|
46
|
+
t.rcov_opts = ['--exclude', 'spec', '--rails']
|
47
|
+
end
|
48
|
+
|
49
|
+
desc "Print Specdoc for all specs"
|
50
|
+
Spec::Rake::SpecTask.new(:doc) do |t|
|
51
|
+
t.spec_opts = ["--format", "specdoc", "--dry-run"]
|
52
|
+
t.spec_files = FileList['spec/**/*_spec.rb']
|
53
|
+
end
|
54
|
+
|
55
|
+
[:models, :controllers, :views, :helpers].each do |sub|
|
56
|
+
desc "Run the specs under spec/#{sub}"
|
57
|
+
Spec::Rake::SpecTask.new(sub) do |t|
|
58
|
+
t.spec_opts = ['--options', "\"#{extension_root}/spec/spec.opts\""]
|
59
|
+
t.spec_files = FileList["spec/#{sub}/**/*_spec.rb"]
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
desc "Run the Cucumber features"
|
64
|
+
Cucumber::Rake::Task.new(:integration) do |t|
|
65
|
+
t.fork = true
|
66
|
+
t.cucumber_opts = ['--format', (ENV['CUCUMBER_FORMAT'] || 'pretty')]
|
67
|
+
# t.feature_pattern = "#{extension_root}/features/**/*.feature"
|
68
|
+
t.profile = "default"
|
69
|
+
end
|
70
|
+
|
71
|
+
# Setup specs for stats
|
72
|
+
task :statsetup do
|
73
|
+
require 'code_statistics'
|
74
|
+
::STATS_DIRECTORIES << %w(Model\ specs spec/models)
|
75
|
+
::STATS_DIRECTORIES << %w(View\ specs spec/views)
|
76
|
+
::STATS_DIRECTORIES << %w(Controller\ specs spec/controllers)
|
77
|
+
::STATS_DIRECTORIES << %w(Helper\ specs spec/views)
|
78
|
+
::CodeStatistics::TEST_TYPES << "Model specs"
|
79
|
+
::CodeStatistics::TEST_TYPES << "View specs"
|
80
|
+
::CodeStatistics::TEST_TYPES << "Controller specs"
|
81
|
+
::CodeStatistics::TEST_TYPES << "Helper specs"
|
82
|
+
::STATS_DIRECTORIES.delete_if {|a| a[0] =~ /test/}
|
83
|
+
end
|
84
|
+
|
85
|
+
namespace :db do
|
86
|
+
namespace :fixtures do
|
87
|
+
desc "Load fixtures (from spec/fixtures) into the current environment's database. Load specific fixtures using FIXTURES=x,y"
|
88
|
+
task :load => :environment do
|
89
|
+
require 'active_record/fixtures'
|
90
|
+
ActiveRecord::Base.establish_connection(Rails.env.to_sym)
|
91
|
+
(ENV['FIXTURES'] ? ENV['FIXTURES'].split(/,/) : Dir.glob(File.join(Rails.root, 'spec', 'fixtures', '*.{yml,csv}'))).each do |fixture_file|
|
92
|
+
Fixtures.create_fixtures('spec/fixtures', File.basename(fixture_file, '.*'))
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
desc 'Generate documentation for the <%= file_name %> extension.'
|
100
|
+
RDoc::Task.new(:rdoc) do |rdoc|
|
101
|
+
rdoc.rdoc_dir = 'rdoc'
|
102
|
+
rdoc.title = '<%= class_name %>'
|
103
|
+
rdoc.options << '--line-numbers' << '--inline-source'
|
104
|
+
rdoc.rdoc_files.include('README')
|
105
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
106
|
+
end
|
107
|
+
|
108
|
+
# Load any custom rakefiles for extension
|
109
|
+
Dir[File.dirname(__FILE__) + '/tasks/*.rake'].sort.each { |f| require f }
|