ember-appkit-rails 0.1.2 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/MIT-LICENSE +1 -1
- data/Rakefile +31 -6
- data/app/assets/javascripts/templates/application.hbs +7 -0
- data/app/controllers/landing_controller.rb +5 -0
- data/lib/ember-appkit-rails.rb +9 -0
- data/lib/ember/appkit.rb +5 -0
- data/lib/ember/appkit/rails.rb +4 -4
- data/lib/ember/appkit/rails/engine.rb +37 -9
- data/lib/ember/appkit/rails/resource_override.rb +14 -0
- data/lib/ember/appkit/rails/sprockets.rb +4 -0
- data/lib/ember/appkit/rails/sprockets/directive_processor.rb +9 -0
- data/lib/ember/appkit/rails/sprockets/processed_asset.rb +27 -0
- data/lib/ember/appkit/rails/version.rb +1 -1
- data/lib/generators/ember/bootstrap_generator.rb +58 -19
- data/lib/generators/ember/component_generator.rb +2 -4
- data/lib/generators/ember/controller_generator.rb +1 -3
- data/lib/generators/ember/generator_helpers.rb +18 -10
- data/lib/generators/ember/helper_generator.rb +17 -0
- data/lib/generators/ember/model_generator.rb +3 -4
- data/lib/generators/ember/resource_generator.rb +13 -1
- data/lib/generators/ember/route_generator.rb +1 -2
- data/lib/generators/ember/scaffold_generator.rb +52 -0
- data/lib/generators/ember/template_generator.rb +1 -2
- data/lib/generators/ember/view_generator.rb +1 -4
- data/lib/generators/templates/adapter.js +3 -0
- data/lib/generators/templates/application.js.erb +11 -0
- data/lib/generators/templates/array_controller.js.es6 +1 -3
- data/lib/generators/templates/component.js.es6 +1 -1
- data/lib/generators/templates/controller.js.es6 +1 -2
- data/{test/dummy/app/utils → lib/generators/templates}/csrf.js +0 -0
- data/lib/generators/templates/environment.js +12 -0
- data/{test/dummy/app/views/application/show.html → lib/generators/templates/environments/development.js} +0 -0
- data/lib/generators/templates/environments/production.js +0 -0
- data/lib/generators/templates/environments/test.js +0 -0
- data/lib/generators/templates/helper.js +2 -0
- data/lib/generators/templates/model.js.es6 +1 -1
- data/lib/generators/templates/object_controller.js.es6 +1 -3
- data/lib/generators/templates/route.js.es6 +1 -2
- data/lib/generators/templates/router.js.es6 +1 -2
- data/lib/generators/templates/scaffold/route/edit.js.es6 +22 -0
- data/lib/generators/templates/scaffold/route/index.js.es6 +5 -0
- data/lib/generators/templates/scaffold/route/new.js.es6 +23 -0
- data/lib/generators/templates/scaffold/route/show.js.es6 +14 -0
- data/lib/generators/templates/scaffold/template.hbs +3 -0
- data/lib/generators/templates/scaffold/template/edit.hbs +3 -0
- data/lib/generators/templates/scaffold/template/form.hbs +9 -0
- data/lib/generators/templates/scaffold/template/index.hbs +20 -0
- data/lib/generators/templates/scaffold/template/new.hbs +3 -0
- data/lib/generators/templates/scaffold/template/show.hbs +9 -0
- data/lib/generators/templates/template.hbs +0 -5
- data/lib/generators/templates/view.js.es6 +1 -2
- data/test/dummy/Gemfile +40 -0
- data/test/dummy/config/adapter.js +3 -0
- data/test/dummy/config/application.js +11 -0
- data/test/dummy/config/application.rb +24 -8
- data/test/dummy/config/boot.rb +1 -2
- data/test/dummy/config/environment.js +12 -0
- data/test/dummy/config/environments/development.js +0 -0
- data/test/dummy/config/environments/development.rb +1 -3
- data/test/dummy/config/environments/production.js +0 -0
- data/test/dummy/config/environments/test.js +0 -0
- data/test/dummy/config/environments/test.rb +1 -1
- data/test/dummy/config/initializers/csrf.js +9 -0
- data/test/dummy/config/initializers/secret_token.rb +1 -1
- data/test/dummy/config/initializers/wrap_parameters.rb +0 -5
- data/test/dummy/{app/assets/javascripts → config}/router.js.es6 +1 -2
- data/test/dummy/config/routes.rb +55 -2
- data/test/dummy/log/test.log +14 -175
- data/test/dummy/public/robots.txt +5 -0
- data/test/dummy/tmp/Gemfile +45 -0
- data/test/dummy/{app → tmp/app}/assets/javascripts/application.js +3 -1
- data/test/dummy/tmp/app/assets/javascripts/custom/application.js +16 -0
- data/test/dummy/tmp/app/templates/post.hbs +0 -0
- data/test/dummy/tmp/app/views/layouts/application.html.erb +14 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/07afa5d8ceda557642e2330ab45eb203 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/13fe41fee1fe35b49d145bcc06610705 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/1f15c49a05b13c3a7ee50d2ac3900f38 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/357970feca3ac29060c1e3861e2c0953 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/4a1d4e32cd7b9fd1c62bfd553ae56051 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/660bc633c8899c6c1b20514637fa0169 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/67afcba9807cd5e57b80b5fdf9f26758 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/6870da13c3305651063dc22ccce27d5c +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/7ca4966e0a480430a858a7ab74518c75 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/827fafc13575b345cc572fd041ef1fba +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/83af35bb6b852de883a26a9458fd4e3a +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/8ebc8c58233ab12eee6edfc0feca2492 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/9160f792acb62d1f7721c714681fcfe6 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/a2f615309ade94c14ae81d7ebc94fd67 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/a9648a765fed0738b076bd24099109a3 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/ae884a1acda0e6f9bb27a856a22bb08d +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/bb4a2293175928af3e23c47488077098 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/bf689240392e7355c0de5cfd47272146 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/c8c4c1b316845f30168739b5795846d6 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/{2f5173deea6c795b8fdde723bb4b63af → d5a48c6656341c56cac8a8e42bb925a5} +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/d771ace226fc8215a3572e0aa35bb0d6 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/{cffd775d018f68ce5dba1ee0d951a994 → de0932670a6c856bc6eda1586fd29061} +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/de94a60b438eb5bf57653f3a220acd80 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/e22019b3c13c20bc08e899fb2b7248ea +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/e9abb671d48f6ff2be6ffb463ea652bf +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/eeb5bd38d1dad0d908461fd114f702bc +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/fde9e78f8d55a70f4ef757638fc6cde0 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/fdfac6623944c5a23737724cbd90e58e +0 -0
- data/test/dummy/tmp/ember-rails/ember-data.js +3787 -5850
- data/test/dummy/tmp/generator_test_output/Gemfile +45 -0
- data/test/dummy/tmp/generator_test_output/app/assets/javascripts/application.js +16 -0
- data/test/dummy/tmp/generator_test_output/app/assets/javascripts/custom/application.js +16 -0
- data/test/dummy/tmp/generator_test_output/app/views/layouts/application.html.erb +14 -0
- data/test/dummy/tmp/generator_test_output/app/views/post.js.es6 +2 -0
- data/test/fixtures/rails_4-0-0_Gemfile +45 -0
- data/test/fixtures/rails_4-0-0_application.js +16 -0
- data/test/fixtures/rails_4-0-0_application_layout +14 -0
- data/test/generators/bootstrap_generator_test.rb +72 -17
- data/test/generators/component_generator_test.rb +13 -20
- data/test/generators/controller_generator_test.rb +7 -18
- data/test/generators/helper_generator_test.rb +16 -0
- data/test/generators/model_generator_test.rb +7 -14
- data/test/generators/resource_generator_test.rb +12 -11
- data/test/generators/resource_override_test.rb +29 -0
- data/test/generators/route_generator_test.rb +1 -9
- data/test/generators/scaffold_generator_test.rb +48 -0
- data/test/generators/template_generator_test.rb +4 -10
- data/test/generators/view_generator_test.rb +11 -18
- data/test/integration/navigation_test.rb +11 -3
- data/test/support/generator_test_support.rb +59 -18
- data/test/support/integration_test_support.rb +12 -0
- data/vendor/assets/javascripts/app.js.es6.erb +27 -0
- data/vendor/assets/javascripts/ember-appkit/index.js +1 -0
- data/vendor/assets/javascripts/ember-appkit/resolver.js +13 -9
- metadata +133 -90
- data/lib/generators/templates/application.js +0 -2
- data/lib/generators/templates/ember-app.js.es6 +0 -15
- data/test/dummy/app/assets/javascripts/components/my-component.js.es6 +0 -4
- data/test/dummy/app/assets/javascripts/controllers/index.js.es6 +0 -7
- data/test/dummy/app/assets/javascripts/ember-app.js +0 -9
- data/test/dummy/app/assets/javascripts/models/person.js.es6 +0 -3
- data/test/dummy/app/assets/javascripts/routes/index.js.es6 +0 -13
- data/test/dummy/app/assets/javascripts/templates/application.hbs +0 -2
- data/test/dummy/app/assets/javascripts/templates/components/my-component.hbs +0 -1
- data/test/dummy/app/assets/javascripts/templates/index.hbs +0 -6
- data/test/dummy/tmp/app/assets/javascripts/templates/post.hbs +0 -5
- data/test/dummy/tmp/cache/assets/test/sprockets/19c9bc7dbf67a891e93c7a663a62ff1c +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/22d5df6f378a04858f2123ee6e176ff1 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/30e6b42a491dc4952ff020137405d502 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/331122f2f78d79778408023cf5bad1e3 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/34b3026e7f937c6a19a0aee7f8451aad +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/36b770b8db4bb47ce9c524d7104be2e9 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/4bde569e155e5abfc2bc79bb61721688 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/720ee922899be7948cc2a8b27660ce0b +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/7689ffe6d7c831ee178e07106482b2cc +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/7bf1770d3a1c8bc1b59a4bc89d5c4bca +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/7d008b32a16b10ea72ea849f47d9a095 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/8e9feb35d7e388f760d17aaf89b32731 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/b3a5b51571520b61f892c51e979b9f53 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/c0bb6b15bdd48873e96974816e18abe9 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/e2a67ad17895f7711966ca1a5ff7af86 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/e44f5ebcd8f42995512e64b96b63c9cf +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/e8aa57b28c86586b8b7344feb891c43f +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/ed5238112abbfd6a794a100804365903 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/f7cbd26ba1d28d48de824f0e94586655 +0 -0
- data/test/dummy/tmp/generator_test_output/app/assets/javascripts/views/post.js.es6 +0 -3
- data/vendor/assets/javascripts/app.js.es6 +0 -13
@@ -6,38 +6,39 @@ class ResourceGeneratorTest < Rails::Generators::TestCase
|
|
6
6
|
|
7
7
|
tests Ember::Generators::ResourceGenerator
|
8
8
|
destination File.join(Rails.root, "tmp")
|
9
|
-
setup :prepare_destination
|
10
|
-
|
9
|
+
setup :prepare_destination, :copy_router
|
11
10
|
|
12
11
|
test "create template" do
|
13
12
|
run_generator ["post"]
|
14
|
-
assert_file "
|
13
|
+
assert_file "#{app_path}/templates/post.hbs"
|
15
14
|
end
|
16
15
|
|
17
16
|
test "create controller" do
|
18
17
|
run_generator ["post"]
|
19
|
-
assert_file "
|
18
|
+
assert_file "#{app_path}/controllers/post.js.es6"
|
20
19
|
end
|
21
20
|
|
22
21
|
test "create route" do
|
23
22
|
run_generator ["post"]
|
24
|
-
assert_file "
|
23
|
+
assert_file "#{app_path}/routes/post.js.es6"
|
24
|
+
assert_file "#{config_path}/router.js.es6" do |content|
|
25
|
+
assert_match(%r{this.resource\('posts'\);}, content)
|
26
|
+
end
|
25
27
|
end
|
26
28
|
|
27
29
|
test "skip route" do
|
28
30
|
run_generator ["post", "--skip-route"]
|
29
|
-
assert_no_file "
|
31
|
+
assert_no_file "#{app_path}/routes/post.js.es6"
|
30
32
|
end
|
31
33
|
|
32
|
-
test "Uses config.ember.
|
33
|
-
custom_path =
|
34
|
+
test "Uses config.ember.appkit.paths.app" do
|
35
|
+
custom_path = app_path("custom")
|
36
|
+
copy_router(custom_path)
|
34
37
|
|
35
|
-
with_config
|
38
|
+
with_config paths: {app: custom_path} do
|
36
39
|
run_generator ["post"]
|
37
40
|
assert_file "#{custom_path}/controllers/post.js.es6"
|
38
41
|
assert_file "#{custom_path}/routes/post.js.es6"
|
39
42
|
end
|
40
43
|
end
|
41
44
|
end
|
42
|
-
|
43
|
-
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
require 'ember/appkit/rails/resource_override'
|
3
|
+
|
4
|
+
class ResourceOverrideTest < Rails::Generators::TestCase
|
5
|
+
include GeneratorTestSupport
|
6
|
+
|
7
|
+
tests Rails::Generators::ResourceGenerator
|
8
|
+
destination File.join(Rails.root, "tmp")
|
9
|
+
setup :prepare_destination, :copy_routes
|
10
|
+
|
11
|
+
test "create template without ember" do
|
12
|
+
run_generator ["post"]
|
13
|
+
assert_no_file "#{app_path}/templates/post.hbs"
|
14
|
+
end
|
15
|
+
|
16
|
+
test "create template with ember" do
|
17
|
+
run_generator ["post", '--ember']
|
18
|
+
assert_file "#{app_path}/templates/post.hbs"
|
19
|
+
end
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
def copy_routes
|
24
|
+
routes = File.expand_path("../../dummy/config/routes.rb", __FILE__)
|
25
|
+
destination = File.expand_path('../../dummy/tmp/config', __FILE__)
|
26
|
+
FileUtils.mkdir_p(destination)
|
27
|
+
FileUtils.cp routes, destination
|
28
|
+
end
|
29
|
+
end
|
@@ -12,14 +12,6 @@ class RouteGeneratorTest < Rails::Generators::TestCase
|
|
12
12
|
test "Assert files are properly created" do
|
13
13
|
run_generator %w(index)
|
14
14
|
|
15
|
-
assert_file "#{
|
16
|
-
end
|
17
|
-
|
18
|
-
test "Assert files are properly created with custom path" do
|
19
|
-
custom_path = ember_path("custom")
|
20
|
-
run_generator [ "index", "-d", custom_path ]
|
21
|
-
|
22
|
-
assert_file "#{custom_path}/routes/index.js.es6"
|
15
|
+
assert_file "#{app_path}/routes/index.js.es6"
|
23
16
|
end
|
24
17
|
end
|
25
|
-
|
@@ -0,0 +1,48 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
require 'generators/ember/scaffold_generator'
|
3
|
+
|
4
|
+
class ScaffoldGeneratorTest < Rails::Generators::TestCase
|
5
|
+
include GeneratorTestSupport
|
6
|
+
|
7
|
+
tests Ember::Generators::ScaffoldGenerator
|
8
|
+
destination File.join(Rails.root, "tmp", "generator_test_output")
|
9
|
+
setup :prepare_destination, :copy_router
|
10
|
+
|
11
|
+
test "create template" do
|
12
|
+
run_generator ["post"]
|
13
|
+
|
14
|
+
assert_files
|
15
|
+
assert_inject_into_router
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
def assert_files
|
21
|
+
assert_file "#{app_path}/models/post.js.es6"
|
22
|
+
|
23
|
+
assert_file "#{app_path}/routes/posts/edit.js.es6"
|
24
|
+
assert_file "#{app_path}/routes/posts/index.js.es6"
|
25
|
+
assert_file "#{app_path}/routes/posts/new.js.es6"
|
26
|
+
assert_file "#{app_path}/routes/posts/show.js.es6"
|
27
|
+
|
28
|
+
assert_file "#{app_path}/templates/posts.hbs"
|
29
|
+
assert_file "#{app_path}/templates/posts/edit.hbs"
|
30
|
+
assert_file "#{app_path}/templates/posts/form.hbs"
|
31
|
+
assert_file "#{app_path}/templates/posts/index.hbs"
|
32
|
+
assert_file "#{app_path}/templates/posts/new.hbs"
|
33
|
+
assert_file "#{app_path}/templates/posts/show.hbs"
|
34
|
+
end
|
35
|
+
|
36
|
+
def assert_inject_into_router
|
37
|
+
js = <<-JS
|
38
|
+
this.resource('posts', function() {
|
39
|
+
this.route('new');
|
40
|
+
this.route('show', {path: ':post_id'});
|
41
|
+
this.route('edit', {path: ':post_id/edit'});
|
42
|
+
});
|
43
|
+
JS
|
44
|
+
assert_file "#{config_path}/router.js.es6" do |content|
|
45
|
+
assert_match(/#{Regexp.escape(js.rstrip)}/m, content)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -11,19 +11,13 @@ class TemplateGeneratorTest < Rails::Generators::TestCase
|
|
11
11
|
|
12
12
|
test "generates template" do
|
13
13
|
run_generator ["post"]
|
14
|
-
assert_file "
|
14
|
+
assert_file "#{app_path}/templates/post.hbs"
|
15
15
|
end
|
16
16
|
|
17
|
-
test "
|
18
|
-
custom_path =
|
19
|
-
run_generator [ "post", "-d", custom_path ]
|
20
|
-
assert_file "#{custom_path}/templates/post.hbs"
|
21
|
-
end
|
22
|
-
|
23
|
-
test "Uses config.ember.ember_path" do
|
24
|
-
custom_path = ember_path("custom")
|
17
|
+
test "Uses config.ember.appkit.paths.app" do
|
18
|
+
custom_path = app_path("custom")
|
25
19
|
|
26
|
-
with_config
|
20
|
+
with_config paths: {app: custom_path} do
|
27
21
|
run_generator ["post"]
|
28
22
|
assert_file "#{custom_path}/templates/post.hbs"
|
29
23
|
end
|
@@ -11,45 +11,38 @@ class ViewGeneratorTest < Rails::Generators::TestCase
|
|
11
11
|
|
12
12
|
test "create view with template by default" do
|
13
13
|
run_generator ["post"]
|
14
|
-
assert_file "
|
15
|
-
assert_file "
|
14
|
+
assert_file "#{app_path}/views/post.js.es6"
|
15
|
+
assert_file "#{app_path}/templates/post.hbs"
|
16
16
|
end
|
17
17
|
|
18
18
|
test "create view without a template" do
|
19
19
|
run_generator ["post", "--without-template"]
|
20
|
-
assert_file "
|
21
|
-
assert_no_file "
|
20
|
+
assert_file "#{app_path}/views/post.js.es6"
|
21
|
+
assert_no_file "#{app_path}/templates/post.hbs"
|
22
22
|
end
|
23
23
|
|
24
24
|
test "create view and template (using ember-rails flags)" do
|
25
25
|
run_generator ["post", "--with-template"]
|
26
|
-
assert_file "
|
27
|
-
assert_file "
|
26
|
+
assert_file "#{app_path}/views/post.js.es6"
|
27
|
+
assert_file "#{app_path}/templates/post.hbs"
|
28
28
|
end
|
29
29
|
|
30
30
|
test "create namespaced view" do
|
31
31
|
run_generator ["post/index"]
|
32
|
-
assert_file "
|
32
|
+
assert_file "#{app_path}/views/post/index.js.es6"
|
33
33
|
end
|
34
34
|
|
35
35
|
test "Assert files are properly created" do
|
36
36
|
run_generator %w(ember)
|
37
|
-
assert_file "#{
|
37
|
+
assert_file "#{app_path}/views/ember.js.es6"
|
38
38
|
end
|
39
39
|
|
40
|
-
test "
|
41
|
-
custom_path =
|
42
|
-
run_generator [ "ember", "-d", custom_path ]
|
43
|
-
assert_file "#{custom_path}/views/ember.js.es6"
|
44
|
-
end
|
45
|
-
|
46
|
-
test "Uses config.ember.ember_path" do
|
47
|
-
custom_path = ember_path("custom")
|
40
|
+
test "Uses config.ember.appkit.paths.app" do
|
41
|
+
custom_path = app_path("custom")
|
48
42
|
|
49
|
-
with_config
|
43
|
+
with_config paths: {app: custom_path} do
|
50
44
|
run_generator [ "ember"]
|
51
45
|
assert_file "#{custom_path}/views/ember.js.es6"
|
52
46
|
end
|
53
47
|
end
|
54
48
|
end
|
55
|
-
|
@@ -1,9 +1,17 @@
|
|
1
1
|
require 'test_helper'
|
2
2
|
|
3
3
|
class NavigationTest < ActionDispatch::IntegrationTest
|
4
|
-
|
5
|
-
|
6
|
-
|
4
|
+
include IntegrationTestSupport
|
5
|
+
|
6
|
+
test 'can render default landing page' do
|
7
|
+
visit '/'
|
8
|
+
assert page.has_text? "That was easy, wasn't it?"
|
9
|
+
end
|
10
|
+
|
11
|
+
test 'can using simple "ember magic"' do
|
12
|
+
visit '/'
|
13
|
+
fill_in 'sampleInput', with: 'EMBER ROCKS!'
|
14
|
+
assert page.has_text? "EMBER ROCKS!"
|
7
15
|
end
|
8
16
|
end
|
9
17
|
|
@@ -1,47 +1,88 @@
|
|
1
|
+
require 'pathname'
|
2
|
+
|
1
3
|
module GeneratorTestSupport
|
4
|
+
# def run_generator(args=self.default_arguments, config={})
|
5
|
+
# # capture(:stdout) do
|
6
|
+
# args += ['--skip-bundle'] unless args.include? '--dev'
|
7
|
+
# self.generator_class.start(args, config.reverse_merge(destination_root: destination_root))
|
8
|
+
# # end
|
9
|
+
# end
|
10
|
+
|
2
11
|
def prepare_destination
|
3
12
|
super
|
4
13
|
|
5
|
-
|
6
|
-
|
14
|
+
tmp_destination = Pathname.new(destination_root)
|
15
|
+
javascript_destination = tmp_destination.join('app','assets','javascripts')
|
16
|
+
|
17
|
+
FileUtils.mkdir_p javascript_destination
|
18
|
+
FileUtils.cp "test/fixtures/rails_4-0-0_application.js", javascript_destination.join('application.js')
|
19
|
+
|
20
|
+
FileUtils.mkdir_p tmp_destination.join(app_path)
|
21
|
+
FileUtils.mkdir_p tmp_destination.join(config_path)
|
7
22
|
|
8
|
-
FileUtils.mkdir_p
|
9
|
-
|
23
|
+
FileUtils.mkdir_p javascript_destination.join('custom')
|
24
|
+
FileUtils.cp "test/fixtures/rails_4-0-0_application.js", javascript_destination.join('custom', 'application.js')
|
10
25
|
|
11
|
-
FileUtils.
|
12
|
-
|
26
|
+
FileUtils.cp 'test/fixtures/rails_4-0-0_Gemfile', tmp_destination.join('Gemfile')
|
27
|
+
|
28
|
+
FileUtils.mkdir_p tmp_destination.join('app','views', 'layouts')
|
29
|
+
FileUtils.cp 'test/fixtures/rails_4-0-0_application_layout', tmp_destination.join('app','views','layouts', 'application.html.erb')
|
13
30
|
end
|
14
31
|
|
15
32
|
def with_config(options = {})
|
16
|
-
original_values = ::Rails.configuration.ember.
|
33
|
+
original_values = ::Rails.configuration.ember.appkit.clone
|
34
|
+
original_values.paths = original_values.paths.clone
|
35
|
+
original_values.paths.app = original_values.paths.app.clone
|
36
|
+
original_values.paths.config = original_values.paths.config.clone
|
17
37
|
|
18
|
-
options.each do |
|
19
|
-
|
38
|
+
options.each do |key, value|
|
39
|
+
if Hash === value
|
40
|
+
value.each do |k, v|
|
41
|
+
::Rails.configuration.ember.appkit[key][k] = v
|
42
|
+
end
|
43
|
+
else
|
44
|
+
::Rails.configuration.ember.appkit[key] = value
|
45
|
+
end
|
20
46
|
end
|
21
47
|
|
22
48
|
yield
|
23
49
|
ensure
|
24
|
-
::Rails.configuration.ember.clear
|
25
|
-
|
26
|
-
::Rails.configuration.ember[key] = value
|
27
|
-
end
|
50
|
+
::Rails.configuration.ember.appkit.clear
|
51
|
+
::Rails.configuration.ember.appkit = original_values
|
28
52
|
end
|
29
53
|
|
30
54
|
def assert_new_dirs(options = {})
|
31
|
-
path = options[:in_path] ||
|
55
|
+
path = options[:in_path] || app_path
|
32
56
|
|
33
|
-
%W{
|
57
|
+
%W{components templates templates/components routes}.each do |dir|
|
34
58
|
assert_directory "#{path}/#{dir}"
|
35
59
|
assert_file "#{path}/#{dir}/.gitkeep"
|
36
60
|
end
|
37
|
-
|
38
61
|
end
|
39
62
|
|
40
63
|
def application_name
|
41
64
|
"App"
|
42
65
|
end
|
43
66
|
|
44
|
-
def
|
45
|
-
|
67
|
+
def app_path(path = 'app')
|
68
|
+
path
|
69
|
+
end
|
70
|
+
|
71
|
+
def config_path(path = 'config')
|
72
|
+
path
|
73
|
+
end
|
74
|
+
|
75
|
+
def copy_router(path = config_path)
|
76
|
+
source = File.expand_path("../../../lib/generators/templates/router.js.es6", __FILE__)
|
77
|
+
destination = File.join(destination_root, path)
|
78
|
+
FileUtils.mkdir_p(destination)
|
79
|
+
FileUtils.cp source, File.join(destination, 'router.js.es6')
|
80
|
+
end
|
81
|
+
|
82
|
+
def copy_application(path = config_path)
|
83
|
+
source = File.expand_path("../../dummy/config/application.rb", __FILE__)
|
84
|
+
destination = File.join(destination_root, path)
|
85
|
+
FileUtils.mkdir_p(destination)
|
86
|
+
copy_file source, File.join(destination, 'application.rb')
|
46
87
|
end
|
47
88
|
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
<% config = Rails.application.config.ember.appkit %>
|
2
|
+
import Resolver from 'resolver';
|
3
|
+
|
4
|
+
if (typeof Turbolinks !== 'undefined') {
|
5
|
+
throw new Error("Turbolinks has been detected. Ember Appkit Rails will not function properly alongside Turbolinks.");
|
6
|
+
}
|
7
|
+
|
8
|
+
<% unless config.enable_logging %>
|
9
|
+
Ember.LOG_VERSION = false;
|
10
|
+
<% end %>
|
11
|
+
|
12
|
+
var App = Ember.Application.extend({
|
13
|
+
|
14
|
+
<% if config.enable_logging %>
|
15
|
+
LOG_ACTIVE_GENERATION: true,
|
16
|
+
LOG_MODULE_RESOLVER: true,
|
17
|
+
LOG_TRANSITIONS: true,
|
18
|
+
LOG_TRANSITIONS_INTERNAL: true,
|
19
|
+
LOG_VIEW_LOOKUPS: true,
|
20
|
+
<% end %>
|
21
|
+
|
22
|
+
modulePrefix: '<%= config.namespaces.app %>',
|
23
|
+
configPrefix: '<%= config.namespaces.config %>',
|
24
|
+
Resolver: Resolver
|
25
|
+
});
|
26
|
+
|
27
|
+
export default App;
|
@@ -1,5 +1,5 @@
|
|
1
1
|
// Fetched from: https://raw.github.com/stefanpenner/ember-jj-abrams-resolver/master/dist/ember-resolver.js
|
2
|
-
// Fetched on: 2013-
|
2
|
+
// Fetched on: 2013-11-27T08:26:18
|
3
3
|
// ==========================================================================
|
4
4
|
// Project: Ember - JavaScript Application Framework
|
5
5
|
// Copyright: Copyright 2013 Stefan Penner and Ember App Kit Contributors
|
@@ -14,8 +14,8 @@
|
|
14
14
|
/*globals define registry requirejs */
|
15
15
|
|
16
16
|
define("resolver",
|
17
|
-
[
|
18
|
-
function(
|
17
|
+
[],
|
18
|
+
function() {
|
19
19
|
"use strict";
|
20
20
|
/*
|
21
21
|
* This module defines a subclass of Ember.DefaultResolver that adds two
|
@@ -83,14 +83,14 @@ define("resolver",
|
|
83
83
|
function resolveRouter(parsedName) {
|
84
84
|
/*jshint validthis:true */
|
85
85
|
|
86
|
-
var prefix = this.namespace.
|
86
|
+
var prefix = this.namespace.configPrefix,
|
87
87
|
routerModule;
|
88
88
|
|
89
89
|
if (parsedName.fullName === 'router:main') {
|
90
90
|
// for now, lets keep the router at app/router.js
|
91
91
|
if (requirejs._eak_seen[prefix + '/router']) {
|
92
92
|
routerModule = require(prefix + '/router');
|
93
|
-
if (routerModule
|
93
|
+
if (routerModule['default']) { routerModule = routerModule['default']; }
|
94
94
|
|
95
95
|
return routerModule;
|
96
96
|
}
|
@@ -115,7 +115,7 @@ define("resolver",
|
|
115
115
|
if (requirejs._eak_seen[normalizedModuleName]) {
|
116
116
|
var module = require(normalizedModuleName, null, null, true /* force sync */);
|
117
117
|
|
118
|
-
if (module
|
118
|
+
if (module['default']) { module = module['default']; }
|
119
119
|
|
120
120
|
if (module === undefined) {
|
121
121
|
throw new Error(" Expected to find: '" + parsedName.fullName + "' within '" + normalizedModuleName + "' but got 'undefined'. Did you forget to `export default` within '" + normalizedModuleName + "'?");
|
@@ -126,13 +126,13 @@ define("resolver",
|
|
126
126
|
}
|
127
127
|
|
128
128
|
if (Ember.ENV.LOG_MODULE_RESOLVER) {
|
129
|
-
Ember.Logger.info('
|
129
|
+
Ember.Logger.info('[✓]', parsedName.fullName, new Array(40 - parsedName.fullName.length).join('.'), moduleName);
|
130
130
|
}
|
131
131
|
|
132
132
|
return module;
|
133
133
|
} else {
|
134
134
|
if (Ember.ENV.LOG_MODULE_RESOLVER) {
|
135
|
-
Ember.Logger.info('
|
135
|
+
Ember.Logger.info('[ ]', parsedName.fullName, new Array(40 - parsedName.fullName.length).join('.'), moduleName);
|
136
136
|
}
|
137
137
|
return this._super(parsedName);
|
138
138
|
}
|
@@ -143,6 +143,9 @@ define("resolver",
|
|
143
143
|
resolveTemplate: resolveOther,
|
144
144
|
resolveOther: resolveOther,
|
145
145
|
resolveRouter: resolveRouter,
|
146
|
+
makeToString: function(factory, fullName) {
|
147
|
+
return '' + this.namespace.modulePrefix + '@' + fullName + ':';
|
148
|
+
},
|
146
149
|
parseName: parseName,
|
147
150
|
shouldWrapInClassFactory: function(module, parsedName){
|
148
151
|
return false;
|
@@ -156,7 +159,8 @@ define("resolver",
|
|
156
159
|
}
|
157
160
|
});
|
158
161
|
|
159
|
-
|
162
|
+
Resolver['default'] = Resolver;
|
163
|
+
return Resolver;
|
160
164
|
});
|
161
165
|
|
162
166
|
})();
|