Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
dc53fe92
R
rails
项目概览
张重言
/
rails
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
rails
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
dc53fe92
编写于
2月 28, 2013
作者:
J
José Valim
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Ensure plugins generated with plugin new can boot the dummy application
上级
8f6b70f1
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
51 addition
and
53 deletion
+51
-53
railties/lib/rails/generators/rails/plugin_new/plugin_new_generator.rb
...rails/generators/rails/plugin_new/plugin_new_generator.rb
+9
-3
railties/lib/rails/generators/rails/plugin_new/templates/%name%.gemspec
...ails/generators/rails/plugin_new/templates/%name%.gemspec
+0
-3
railties/lib/rails/generators/rails/plugin_new/templates/Gemfile
...s/lib/rails/generators/rails/plugin_new/templates/Gemfile
+0
-8
railties/lib/rails/generators/rails/plugin_new/templates/rails/javascripts.js
...enerators/rails/plugin_new/templates/rails/javascripts.js
+13
-0
railties/lib/rails/generators/rails/plugin_new/templates/rails/stylesheets.css
...nerators/rails/plugin_new/templates/rails/stylesheets.css
+13
-0
railties/test/generators/plugin_new_generator_test.rb
railties/test/generators/plugin_new_generator_test.rb
+16
-39
未找到文件。
railties/lib/rails/generators/rails/plugin_new/plugin_new_generator.rb
浏览文件 @
dc53fe92
...
...
@@ -94,6 +94,11 @@ def test_dummy_config
end
end
def
test_dummy_assets
template
"rails/javascripts.js"
,
"
#{
dummy_path
}
/app/assets/javascripts/application.js"
,
force:
true
template
"rails/stylesheets.css"
,
"
#{
dummy_path
}
/app/assets/stylesheets/application.css"
,
force:
true
end
def
test_dummy_clean
inside
dummy_path
do
remove_file
".gitignore"
...
...
@@ -112,7 +117,7 @@ def test_dummy_clean
def
stylesheets
if
mountable?
copy_file
"
#{
app_templates_dir
}
/app/assets/stylesheets/application
.css"
,
copy_file
"
rails/stylesheets
.css"
,
"app/assets/stylesheets/
#{
name
}
/application.css"
elsif
full?
empty_directory_with_keep_file
"app/assets/stylesheets/
#{
name
}
"
...
...
@@ -123,8 +128,8 @@ def javascripts
return
if
options
.
skip_javascript?
if
mountable?
template
"
#{
app_templates_dir
}
/app/assets/javascripts/application.js.tt
"
,
"app/assets/javascripts/
#{
name
}
/application.js"
template
"
rails/javascripts.js
"
,
"app/assets/javascripts/
#{
name
}
/application.js"
elsif
full?
empty_directory_with_keep_file
"app/assets/javascripts/
#{
name
}
"
end
...
...
@@ -263,6 +268,7 @@ def create_dummy_app(path = nil)
build
(
:generate_test_dummy
)
store_application_definition!
build
(
:test_dummy_config
)
build
(
:test_dummy_assets
)
build
(
:test_dummy_clean
)
# ensure that bin/rails has proper dummy_path
build
(
:bin
,
true
)
...
...
railties/lib/rails/generators/rails/plugin_new/templates/%name%.gemspec
浏览文件 @
dc53fe92
...
...
@@ -19,9 +19,6 @@
<% end -%>
<
%= '# ' if options.dev? || options.edge? -%>s.add_dependency "rails", "~> <%=
Rails
::
VERSION
::
STRING
%>"
<% if engine? && !options[:skip_javascript] -%>
# s.add_dependency "<%= "#{options[:javascript]}-rails" %>"
<
% end
-
%>
<% unless options[:skip_active_record] -%>
s
.
add_development_dependency
"<%= gem_for_database %>"
...
...
railties/lib/rails/generators/rails/plugin_new/templates/Gemfile
浏览文件 @
dc53fe92
...
...
@@ -2,9 +2,6 @@ source "https://rubygems.org"
<
% if
options
[
:skip_gemspec
]
-
%>
<%= '# ' if options.dev? || options.edge? -%>
gem
"rails"
,
"~> <%= Rails::VERSION::STRING %>"
<
% if
engine?
&&
!
options
[
:skip_javascript
]
-
%>
# gem "<%= "#{options[:javascript]}-rails" %>
"
<% end -%>
<
% else
-
%>
# Declare your gem's dependencies in <%= name %>
.
gemspec
.
# Bundler will treat runtime dependencies like base dependencies, and
...
...
@@ -12,11 +9,6 @@ source "https://rubygems.org"
gemspec
<
% end
-
%>
<% unless options[:javascript] == 'jquery' -%>
# jquery-rails is used by the dummy application
gem "
jquery
-
rails
"
<% end -%>
<% if options[:skip_gemspec] -%>
group
:development
do
gem
"<%= gem_for_database %>"
...
...
railties/lib/rails/generators/rails/plugin_new/templates/rails/javascripts.js
0 → 100644
浏览文件 @
dc53fe92
// This is a manifest file that'll be compiled into application.js, which will include all the files
// listed below.
//
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
//
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
// compiled file.
//
// WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD
// GO AFTER THE REQUIRES BELOW.
//
//= require_tree .
railties/lib/rails/generators/rails/plugin_new/templates/rails/stylesheets.css
0 → 100644
浏览文件 @
dc53fe92
/*
* This is a manifest file that'll be compiled into application.css, which will include all the files
* listed below.
*
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
* or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
*
* You're free to add application-wide styles to this file and they'll appear at the top of the
* compiled file, but it's generally better to create a new file per style scope.
*
*= require_self
*= require_tree .
*/
railties/test/generators/plugin_new_generator_test.rb
浏览文件 @
dc53fe92
...
...
@@ -63,13 +63,24 @@ def test_generating_test_files_in_full_mode_without_unit_test_files
assert_no_directory
"test/integration/"
assert_no_file
"test"
assert_no_match
(
/APP_RAKEFILE/
,
File
.
read
(
File
.
join
(
destination_root
,
"Rakefile"
)))
assert_file
"Rakefile"
do
|
contents
|
assert_no_match
(
/APP_RAKEFILE/
,
contents
)
end
end
def
test_generating_adds_dummy_app_rake_tasks_without_unit_test_files
run_generator
[
destination_root
,
"-T"
,
"--mountable"
,
'--dummy-path'
,
'my_dummy_app'
]
assert_file
"Rakefile"
,
/APP_RAKEFILE/
end
def
test_generating_adds_dummy_app_without_javascript_and_assets_deps
run_generator
[
destination_root
]
assert_file
"test/dummy/app/assets/stylesheets/application.css"
assert_match
(
/APP_RAKEFILE/
,
File
.
read
(
File
.
join
(
destination_root
,
"Rakefile"
)))
assert_file
"test/dummy/app/assets/javascripts/application.js"
do
|
contents
|
assert_no_match
(
/jquery/
,
contents
)
end
end
def
test_ensure_that_plugin_options_are_not_passed_to_app_generator
...
...
@@ -112,7 +123,9 @@ def test_active_record_is_removed_from_frameworks_if_skip_active_record_is_given
def
test_ensure_that_skip_active_record_option_is_passed_to_app_generator
run_generator
[
destination_root
,
"--skip_active_record"
]
assert_no_file
"test/dummy/config/database.yml"
assert_no_match
(
/ActiveRecord/
,
File
.
read
(
File
.
join
(
destination_root
,
"test/test_helper.rb"
)))
assert_file
"test/test_helper.rb"
do
|
contents
|
assert_no_match
/ActiveRecord/
,
contents
end
end
def
test_ensure_that_database_option_is_passed_to_app_generator
...
...
@@ -134,8 +147,6 @@ def test_generation_runs_bundle_install_with_full_and_mountable
def
test_skipping_javascripts_without_mountable_option
run_generator
assert_no_file
"app/assets/javascripts/bukkits/application.js"
assert_no_file
"vendor/assets/javascripts/jquery.js"
assert_no_file
"vendor/assets/javascripts/jquery_ujs.js"
end
def
test_javascripts_generation
...
...
@@ -143,33 +154,9 @@ def test_javascripts_generation
assert_file
"app/assets/javascripts/bukkits/application.js"
end
def
test_jquery_is_the_default_javascript_library
run_generator
[
destination_root
,
"--mountable"
]
assert_file
"app/assets/javascripts/bukkits/application.js"
do
|
contents
|
assert_match
%r{^//= require jquery}
,
contents
assert_match
%r{^//= require jquery_ujs}
,
contents
end
assert_file
'bukkits.gemspec'
do
|
contents
|
assert_match
(
/jquery-rails/
,
contents
)
end
end
def
test_other_javascript_libraries
run_generator
[
destination_root
,
"--mountable"
,
'-j'
,
'prototype'
]
assert_file
"app/assets/javascripts/bukkits/application.js"
do
|
contents
|
assert_match
%r{^//= require prototype}
,
contents
assert_match
%r{^//= require prototype_ujs}
,
contents
end
assert_file
'bukkits.gemspec'
do
|
contents
|
assert_match
(
/prototype-rails/
,
contents
)
end
end
def
test_skip_javascripts
run_generator
[
destination_root
,
"--skip-javascript"
,
"--mountable"
]
assert_no_file
"app/assets/javascripts/bukkits/application.js"
assert_no_file
"vendor/assets/javascripts/jquery.js"
assert_no_file
"vendor/assets/javascripts/jquery_ujs.js"
end
def
test_template_from_dir_pwd
...
...
@@ -318,16 +305,6 @@ def test_skipping_gemspec_in_full_mode
assert_no_match
(
'gemspec'
,
contents
)
assert_match
(
/gem "rails", "~>
#{
Rails
::
VERSION
::
STRING
}
"/
,
contents
)
assert_match
(
/group :development do\n gem "sqlite3"\nend/
,
contents
)
assert_match
(
/# gem "jquery-rails"/
,
contents
)
assert_no_match
(
/# jquery-rails is used by the dummy application\ngem "jquery-rails"/
,
contents
)
end
end
def
test_skipping_gemspec_in_full_mode_with_javascript_option
run_generator
[
destination_root
,
"--skip-gemspec"
,
"--full"
,
"--javascript=prototype"
]
assert_file
"Gemfile"
do
|
contents
|
assert_match
(
/# gem "prototype-rails"/
,
contents
)
assert_match
(
/# jquery-rails is used by the dummy application\ngem "jquery-rails"/
,
contents
)
end
end
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录