slim-rails 3.3.0 → 3.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (35) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +5 -0
  3. data/lib/generators/slim/scaffold/scaffold_generator.rb +5 -2
  4. data/lib/generators/slim/scaffold/templates/_form.html.slim.tt +28 -0
  5. data/lib/generators/slim/scaffold/templates/edit.html.slim.tt +10 -0
  6. data/lib/generators/slim/scaffold/templates/index.html.slim.tt +11 -0
  7. data/lib/generators/slim/scaffold/templates/new.html.slim.tt +8 -0
  8. data/lib/generators/slim/scaffold/templates/partial.html.slim.tt +14 -0
  9. data/lib/generators/slim/scaffold/templates/show.html.slim.tt +10 -0
  10. data/lib/slim-rails/version.rb +1 -1
  11. metadata +10 -35
  12. data/.gitignore +0 -20
  13. data/.travis.yml +0 -45
  14. data/Appraisals +0 -25
  15. data/Gemfile +0 -3
  16. data/Rakefile +0 -12
  17. data/gemfiles/rails_5.0.gemfile +0 -8
  18. data/gemfiles/rails_5.1.gemfile +0 -8
  19. data/gemfiles/rails_5.2.gemfile +0 -7
  20. data/gemfiles/rails_6.0.gemfile +0 -7
  21. data/gemfiles/rails_6.1.gemfile +0 -7
  22. data/gemfiles/rails_edge.gemfile +0 -7
  23. data/lib/generators/slim/scaffold/templates/_form.html.slim +0 -14
  24. data/lib/generators/slim/scaffold/templates/edit.html.slim +0 -7
  25. data/lib/generators/slim/scaffold/templates/index.html.slim +0 -25
  26. data/lib/generators/slim/scaffold/templates/new.html.slim +0 -5
  27. data/lib/generators/slim/scaffold/templates/show.html.slim +0 -11
  28. data/slim-rails.gemspec +0 -35
  29. data/test/fixtures/routes.rb +0 -58
  30. data/test/lib/generators/slim/controller_generator_test.rb +0 -25
  31. data/test/lib/generators/slim/mailer_generator_test.rb +0 -78
  32. data/test/lib/generators/slim/scaffold_generator_test.rb +0 -34
  33. data/test/lib/generators/slim/testing_helper.rb +0 -11
  34. data/test/lib/slim-rails_assets_test.rb +0 -72
  35. data/test/test_helper.rb +0 -66
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4c09a72b540b1eeeb00a3fa4a3a35fa6cb34d064104a9a7155f14ecee5e7e39d
4
- data.tar.gz: 2210937c961529642a2fc5ff485dd13de10f46694259d74d0521593182e095c0
3
+ metadata.gz: 9d672f03fbbe43effd0e993addabdd6ab61bbda0038edee278359483363caa98
4
+ data.tar.gz: 98e150a881b76c14f4304728124366b44ce3d4335b9cb732cd6bbe6668c6011f
5
5
  SHA512:
6
- metadata.gz: ef5677b920c4a940df436fbad90dbf8e6e97b074f4c6b498a6b9f2b323588280ba5fc6f708dddf4459cb5cb609ea4af0fad03350fd1a013b3bb25b55fa468638
7
- data.tar.gz: f77d561a26be9f8967ebd2e7ead43e01c9b9219c1445d88c9c09ca0f271326ca30ab920cb202ecf3cdc90f21edd5d51089f60c2d4d9c739d05ebcf45d186846e
6
+ metadata.gz: e4e81e2fe65f34fb318c40bf799dff4498010699a4721014f0b9c2e648c7e14ea6e19c1dd95c7e12aade2d82e7043cb1885560759874efd4e15f19a006109b55
7
+ data.tar.gz: db4ed0ed081659fdd329345054bcdf1252437b69c8433aa045a1ede11211d0cda09e8754cca43a4a929226ba802637eccbc9fbb3988738761960d28ae8690a0d
data/CHANGELOG.md CHANGED
@@ -1,3 +1,8 @@
1
+ ## 3.4.0 (March 2022)
2
+
3
+ * Updated templates to Rails 7 style (thanks github.com/viktorianer) (#178)
4
+
5
+
1
6
  ## 3.3.0 (July 19, 2021)
2
7
 
3
8
  * Enabled asset helpers in precompiled templates (#135)
@@ -2,7 +2,7 @@ require 'rails/generators/erb/scaffold/scaffold_generator'
2
2
 
3
3
  module Slim
4
4
  module Generators
5
- class ScaffoldGenerator < Erb::Generators::ScaffoldGenerator
5
+ class ScaffoldGenerator < Erb::Generators::ScaffoldGenerator # :nodoc:
6
6
  source_root File.expand_path(File.join('..', 'templates'), __FILE__)
7
7
 
8
8
  def copy_view_files
@@ -10,13 +10,16 @@ module Slim
10
10
  filename = filename_with_extensions view
11
11
  template "#{view}.html.slim", File.join('app', 'views', controller_file_path, filename)
12
12
  end
13
+
14
+ template 'partial.html.slim', File.join('app/views', controller_file_path, "_#{singular_name}.html.slim")
13
15
  end
14
16
 
15
17
  hook_for :form_builder, as: :scaffold
16
18
 
17
19
  protected
20
+
18
21
  def available_views
19
- ['index', 'edit', 'show', 'new', '_form']
22
+ %w[index edit show new _form]
20
23
  end
21
24
 
22
25
  def handler
@@ -0,0 +1,28 @@
1
+ = form_with(model: @<%= model_resource_name %>) do |form|
2
+ - if @<%= singular_table_name %>.errors.any?
3
+ div style="color: red"
4
+ h2 = "#{pluralize(@<%= singular_table_name %>.errors.count, 'error')} prohibited this <%= singular_table_name %> from being saved:"
5
+ ul
6
+ - @<%= singular_table_name %>.errors.each do |error|
7
+ li = error.full_message
8
+
9
+ <% attributes.each do |attribute| -%>
10
+ div
11
+ <% if attribute.password_digest? -%>
12
+ = form.label :password, style: "display: block"
13
+ = form.password_field :password
14
+
15
+ div
16
+ = form.label :password_confirmation, style: "display: block"
17
+ = form.password_field :password_confirmation
18
+ <% elsif attribute.attachments? -%>
19
+ = form.label :<%= attribute.column_name %>, style: "display: block"
20
+ = form.<%= attribute.field_type %> :<%= attribute.column_name %>, multiple: true
21
+ <% else -%>
22
+ = form.label :<%= attribute.column_name %>, style: "display: block"
23
+ = form.<%= attribute.field_type %> :<%= attribute.column_name %>
24
+ <% end -%>
25
+
26
+ <% end -%>
27
+ div
28
+ = form.submit
@@ -0,0 +1,10 @@
1
+ h1 Editing <%= human_name.downcase %>
2
+
3
+ == render "form", <%= singular_table_name %>: @<%= singular_table_name %>
4
+
5
+ br
6
+
7
+ div
8
+ => link_to "Show this <%= human_name.downcase %>", <%= model_resource_name(prefix: "@") %>
9
+ '|
10
+ =< link_to "Back to <%= human_name.pluralize.downcase %>", <%= index_helper(type: :path) %>
@@ -0,0 +1,11 @@
1
+ p style="color: green" = notice
2
+
3
+ h1 <%= human_name.pluralize %>
4
+
5
+ #<%= plural_table_name %>
6
+ - @<%= plural_table_name %>.each do |<%= singular_table_name %>|
7
+ == render <%= singular_table_name %>
8
+ p
9
+ = link_to "Show this <%= human_name.downcase %>", <%= model_resource_name(singular_table_name) %>
10
+
11
+ = link_to "New <%= human_name.downcase %>", <%= new_helper(type: :path) %>
@@ -0,0 +1,8 @@
1
+ h1 New <%= human_name.downcase %>
2
+
3
+ == render "form", <%= singular_table_name %>: @<%= singular_table_name %>
4
+
5
+ br
6
+
7
+ div
8
+ = link_to "Back to <%= human_name.pluralize.downcase %>", <%= index_helper(type: :path) %>
@@ -0,0 +1,14 @@
1
+ div id="#{dom_id <%= singular_name %>}"
2
+ <% attributes.reject(&:password_digest?).each do |attribute| -%>
3
+ p
4
+ strong <%= attribute.human_name %>:
5
+ <% if attribute.attachment? -%>
6
+ = link_to <%= singular_name %>.<%= attribute.column_name %>.filename, <%= singular_name %>.<%= attribute.column_name %> if <%= singular_name %>.<%= attribute.column_name %>.attached?
7
+ <% elsif attribute.attachments? -%>
8
+ - <%= singular_name %>.<%= attribute.column_name %>.each do |<%= attribute.singular_name %>|
9
+ div
10
+ = link_to <%= attribute.singular_name %>.filename, <%= attribute.singular_name %>
11
+ <% else -%>
12
+ =< <%= singular_name %>.<%= attribute.column_name %>
13
+ <% end -%>
14
+ <% end -%>
@@ -0,0 +1,10 @@
1
+ p style="color: green" = notice
2
+
3
+ == render @<%= singular_table_name %>
4
+
5
+ div
6
+ => link_to "Edit this <%= human_name.downcase %>", <%= edit_helper(type: :path) %>
7
+ '|
8
+ =< link_to "Back to <%= human_name.pluralize.downcase %>", <%= index_helper(type: :path) %>
9
+
10
+ = button_to "Destroy this <%= human_name.downcase %>", <%= model_resource_name(prefix: "@") %>, method: :delete
@@ -1,5 +1,5 @@
1
1
  module Slim
2
2
  module Rails
3
- VERSION = '3.3.0'
3
+ VERSION = '3.4.0'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: slim-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.3.0
4
+ version: 3.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Leonardo Almeida
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2021-07-19 00:00:00.000000000 Z
12
+ date: 2022-03-15 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: actionpack
@@ -165,20 +165,9 @@ executables: []
165
165
  extensions: []
166
166
  extra_rdoc_files: []
167
167
  files:
168
- - ".gitignore"
169
- - ".travis.yml"
170
- - Appraisals
171
168
  - CHANGELOG.md
172
- - Gemfile
173
169
  - LICENSE
174
170
  - README.md
175
- - Rakefile
176
- - gemfiles/rails_5.0.gemfile
177
- - gemfiles/rails_5.1.gemfile
178
- - gemfiles/rails_5.2.gemfile
179
- - gemfiles/rails_6.0.gemfile
180
- - gemfiles/rails_6.1.gemfile
181
- - gemfiles/rails_edge.gemfile
182
171
  - lib/generators/slim/controller/controller_generator.rb
183
172
  - lib/generators/slim/controller/templates/view.html.slim
184
173
  - lib/generators/slim/mailer/mailer_generator.rb
@@ -187,22 +176,15 @@ files:
187
176
  - lib/generators/slim/mailer/templates/view.html.slim
188
177
  - lib/generators/slim/mailer/templates/view.text.slim
189
178
  - lib/generators/slim/scaffold/scaffold_generator.rb
190
- - lib/generators/slim/scaffold/templates/_form.html.slim
191
- - lib/generators/slim/scaffold/templates/edit.html.slim
192
- - lib/generators/slim/scaffold/templates/index.html.slim
193
- - lib/generators/slim/scaffold/templates/new.html.slim
194
- - lib/generators/slim/scaffold/templates/show.html.slim
179
+ - lib/generators/slim/scaffold/templates/_form.html.slim.tt
180
+ - lib/generators/slim/scaffold/templates/edit.html.slim.tt
181
+ - lib/generators/slim/scaffold/templates/index.html.slim.tt
182
+ - lib/generators/slim/scaffold/templates/new.html.slim.tt
183
+ - lib/generators/slim/scaffold/templates/partial.html.slim.tt
184
+ - lib/generators/slim/scaffold/templates/show.html.slim.tt
195
185
  - lib/slim-rails.rb
196
186
  - lib/slim-rails/register_engine.rb
197
187
  - lib/slim-rails/version.rb
198
- - slim-rails.gemspec
199
- - test/fixtures/routes.rb
200
- - test/lib/generators/slim/controller_generator_test.rb
201
- - test/lib/generators/slim/mailer_generator_test.rb
202
- - test/lib/generators/slim/scaffold_generator_test.rb
203
- - test/lib/generators/slim/testing_helper.rb
204
- - test/lib/slim-rails_assets_test.rb
205
- - test/test_helper.rb
206
188
  homepage: https://github.com/slim-template/slim-rails
207
189
  licenses:
208
190
  - MIT
@@ -222,15 +204,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
222
204
  - !ruby/object:Gem::Version
223
205
  version: '0'
224
206
  requirements: []
225
- rubygems_version: 3.1.6
207
+ rubygems_version: 3.3.7
226
208
  signing_key:
227
209
  specification_version: 4
228
210
  summary: Slim templates generator for Rails
229
- test_files:
230
- - test/fixtures/routes.rb
231
- - test/lib/generators/slim/controller_generator_test.rb
232
- - test/lib/generators/slim/mailer_generator_test.rb
233
- - test/lib/generators/slim/scaffold_generator_test.rb
234
- - test/lib/generators/slim/testing_helper.rb
235
- - test/lib/slim-rails_assets_test.rb
236
- - test/test_helper.rb
211
+ test_files: []
data/.gitignore DELETED
@@ -1,20 +0,0 @@
1
- *.gem
2
- *.rbc
3
- .bundle
4
- .config
5
- .yardoc
6
- Gemfile.lock
7
- InstalledFiles
8
- _yardoc
9
- coverage
10
- doc/
11
- lib/bundler/man
12
- pkg
13
- rdoc
14
- spec/reports
15
- test/tmp
16
- test/version_tmp
17
- tmp/
18
- .ruby-version
19
- .ruby-gemset
20
- gemfiles/*.gemfile.lock
data/.travis.yml DELETED
@@ -1,45 +0,0 @@
1
- dist: focal
2
-
3
- os: linux
4
-
5
- language: ruby
6
-
7
- cache:
8
- bundler: true
9
-
10
- before_install:
11
- - gem uninstall -v '>= 2' -i $(rvm gemdir)@global -ax bundler || true
12
- - gem install bundler -v '< 2'
13
-
14
- rvm:
15
- - ruby-head
16
- - 3.0
17
- - 2.7
18
- - 2.6
19
-
20
- gemfile:
21
- - gemfiles/rails_edge.gemfile
22
- - gemfiles/rails_6.1.gemfile
23
- - gemfiles/rails_6.0.gemfile
24
- - gemfiles/rails_5.2.gemfile
25
- - gemfiles/rails_5.1.gemfile
26
- - gemfiles/rails_5.0.gemfile
27
-
28
- jobs:
29
- allow_failures:
30
- - rvm: ruby-head
31
- - gemfile: gemfiles/rails_edge.gemfile
32
-
33
- exclude:
34
- - rvm: 3.0
35
- gemfile: gemfiles/rails_5.2.gemfile
36
- - rvm: 3.0
37
- gemfile: gemfiles/rails_5.1.gemfile
38
- - rvm: 3.0
39
- gemfile: gemfiles/rails_5.0.gemfile
40
-
41
- fast_finish: true
42
-
43
- addons:
44
- code_climate:
45
- repo_token: 294f0ec8183176c0259b75eb21b38414508616985a7b39fc48fec9dfcf40a52e
data/Appraisals DELETED
@@ -1,25 +0,0 @@
1
- appraise "rails-5.0" do
2
- gem "rails", "~> 5.0.0"
3
- gem "sprockets", "~> 3.7"
4
- end
5
-
6
- appraise "rails-5.1" do
7
- gem "rails", "~> 5.1.0"
8
- gem "sprockets", "~> 3.7"
9
- end
10
-
11
- appraise "rails-5.2" do
12
- gem "rails", "~> 5.2.0"
13
- end
14
-
15
- appraise "rails-6.0" do
16
- gem "rails", "~> 6.0.3"
17
- end
18
-
19
- appraise "rails-6.1" do
20
- gem "rails", "~> 6.1.3"
21
- end
22
-
23
- appraise "rails-edge" do
24
- gem "rails", github: 'rails/rails'
25
- end
data/Gemfile DELETED
@@ -1,3 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- gemspec
data/Rakefile DELETED
@@ -1,12 +0,0 @@
1
- #!/usr/bin/env rake
2
- require 'bundler'
3
- Bundler::GemHelper.install_tasks
4
-
5
- require 'rake/testtask'
6
- Rake::TestTask.new(:test) do |test|
7
- test.libs << 'lib' << 'test'
8
- test.pattern = 'test/**/*_test.rb'
9
- test.verbose = true
10
- end
11
-
12
- task :default => :test
@@ -1,8 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "https://rubygems.org"
4
-
5
- gem "rails", "~> 5.0.0"
6
- gem "sprockets", "~> 3.7"
7
-
8
- gemspec path: "../"
@@ -1,8 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "https://rubygems.org"
4
-
5
- gem "rails", "~> 5.1.0"
6
- gem "sprockets", "~> 3.7"
7
-
8
- gemspec path: "../"
@@ -1,7 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "https://rubygems.org"
4
-
5
- gem "rails", "~> 5.2.0"
6
-
7
- gemspec path: "../"
@@ -1,7 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "https://rubygems.org"
4
-
5
- gem "rails", "~> 6.0.3"
6
-
7
- gemspec path: "../"
@@ -1,7 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "https://rubygems.org"
4
-
5
- gem "rails", "~> 6.1.3"
6
-
7
- gemspec path: "../"
@@ -1,7 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "https://rubygems.org"
4
-
5
- gem "rails", github: "rails/rails"
6
-
7
- gemspec path: "../"
@@ -1,14 +0,0 @@
1
- = form_for @<%= singular_table_name %> do |f|
2
- - if @<%= singular_table_name %>.errors.any?
3
- #error_explanation
4
- h2 = "#{pluralize(@<%= singular_table_name %>.errors.count, 'error')} prohibited this <%= singular_table_name %> from being saved:"
5
- ul
6
- - @<%= singular_table_name %>.errors.full_messages.each do |message|
7
- li = message
8
-
9
- <% attributes.each do |attribute| -%>
10
- .field
11
- = f.label :<%= attribute.name %>
12
- = f.<%= attribute.field_type %> :<%= attribute.name %>
13
- <% end -%>
14
- .actions = f.submit
@@ -1,7 +0,0 @@
1
- h1 Editing <%= singular_table_name %>
2
-
3
- == render 'form'
4
-
5
- => link_to 'Show', @<%= singular_table_name %>
6
- '|
7
- =< link_to 'Back', <%= index_helper %>_path
@@ -1,25 +0,0 @@
1
- h1 Listing <%= plural_table_name %>
2
-
3
- table
4
- thead
5
- tr
6
- <% attributes.each do |attribute| -%>
7
- th <%= attribute.human_name %>
8
- <% end -%>
9
- th
10
- th
11
- th
12
-
13
- tbody
14
- - @<%= plural_table_name %>.each do |<%= singular_table_name %>|
15
- tr
16
- <% attributes.each do |attribute| -%>
17
- td = <%= singular_table_name %>.<%= attribute.name %>
18
- <% end -%>
19
- td = link_to 'Show', <%= singular_table_name %>
20
- td = link_to 'Edit', edit_<%= singular_table_name %>_path(<%= singular_table_name %>)
21
- td = link_to 'Destroy', <%= singular_table_name %>, data: { confirm: 'Are you sure?' }, method: :delete
22
-
23
- br
24
-
25
- = link_to 'New <%= human_name %>', new_<%= singular_table_name %>_path
@@ -1,5 +0,0 @@
1
- h1 New <%= singular_table_name %>
2
-
3
- == render 'form'
4
-
5
- = link_to 'Back', <%= index_helper %>_path
@@ -1,11 +0,0 @@
1
- p#notice = notice
2
- <% attributes.each do |attribute| -%>
3
-
4
- p
5
- strong <%= attribute.human_name %>:
6
- = @<%= singular_table_name %>.<%= attribute.name %>
7
- <% end -%>
8
-
9
- => link_to 'Edit', edit_<%= singular_table_name %>_path(@<%= singular_table_name %>)
10
- '|
11
- =< link_to 'Back', <%= index_helper %>_path
data/slim-rails.gemspec DELETED
@@ -1,35 +0,0 @@
1
- # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
3
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require 'slim-rails/version'
5
-
6
- Gem::Specification.new do |spec|
7
- spec.name = 'slim-rails'
8
- spec.version = Slim::Rails::VERSION
9
- spec.authors = ["Leonardo Almeida", "Janusz Mordarski"]
10
- spec.email = ["lalmeida08@gmail.com", "janusz.m@gmail.com"]
11
-
12
- spec.summary = 'Slim templates generator for Rails'
13
- spec.description = 'Provides the generator settings required for Rails to use Slim'
14
- spec.homepage = 'https://github.com/slim-template/slim-rails'
15
- spec.license = 'MIT'
16
-
17
- spec.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
18
- spec.files = `git ls-files`.split("\n")
19
- spec.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
20
- spec.require_paths = ['lib']
21
-
22
- spec.required_ruby_version = '>= 2.0.0'
23
-
24
- spec.add_runtime_dependency 'actionpack', ['>= 3.1']
25
- spec.add_runtime_dependency 'railties', ['>= 3.1']
26
- spec.add_runtime_dependency 'slim', ['>= 3.0', '< 5.0']
27
-
28
- spec.add_development_dependency 'sprockets-rails'
29
- spec.add_development_dependency 'slim_lint', '~> 0.21.0'
30
- spec.add_development_dependency 'rocco'
31
- spec.add_development_dependency 'redcarpet'
32
- spec.add_development_dependency 'awesome_print'
33
- spec.add_development_dependency 'actionmailer', ['>= 3.1']
34
- spec.add_development_dependency 'appraisal'
35
- end
@@ -1,58 +0,0 @@
1
- TestApp.routes.draw do
2
- # The priority is based upon order of creation:
3
- # first created -> highest priority.
4
-
5
- # Sample of regular route:
6
- # match 'products/:id' => 'catalog#view'
7
- # Keep in mind you can assign values other than :controller and :action
8
-
9
- # Sample of named route:
10
- # match 'products/:id/purchase' => 'catalog#purchase', as: :purchase
11
- # This route can be invoked with purchase_url(id: product.id)
12
-
13
- # Sample resource route (maps HTTP verbs to controller actions automatically):
14
- # resources :products
15
-
16
- # Sample resource route with options:
17
- # resources :products do
18
- # member do
19
- # get :short
20
- # post :toggle
21
- # end
22
- #
23
- # collection do
24
- # get :sold
25
- # end
26
- # end
27
-
28
- # Sample resource route with sub-resources:
29
- # resources :products do
30
- # resources :comments, :sales
31
- # resource :seller
32
- # end
33
-
34
- # Sample resource route with more complex sub-resources
35
- # resources :products do
36
- # resources :comments
37
- # resources :sales do
38
- # get :recent, on: :collection
39
- # end
40
- # end
41
-
42
- # Sample resource route within a namespace:
43
- # namespace :admin do
44
- # # Directs /admin/products/* to Admin::ProductsController
45
- # # (app/controllers/admin/products_controller.rb)
46
- # resources :products
47
- # end
48
-
49
- # You can have the root of your site routed with "root"
50
- # just remember to delete public/index.html.
51
- # root to: "welcome#index"
52
-
53
- # See how all your routes lay out with "rake routes"
54
-
55
- # This is a legacy wild controller route that's not recommended for RESTful applications.
56
- # Note: This route will make all actions in every controller accessible via GET requests.
57
- # match ':controller(/:action(/:id(.:format)))'
58
- end
@@ -1,25 +0,0 @@
1
- require 'test_helper'
2
- require 'lib/generators/slim/testing_helper'
3
-
4
- class Slim::Generators::ControllerGeneratorTest < Rails::Generators::TestCase
5
- include SlimLintHelpers
6
-
7
- destination File.join(Rails.root)
8
- tests Rails::Generators::ControllerGenerator
9
- arguments %w(Account foo bar --template-engine slim)
10
-
11
- setup :prepare_destination
12
- setup :copy_routes
13
-
14
- test "should invoke template engine" do
15
- run_generator
16
- assert_file File.join("app", "views", "account", "foo.html.slim"), %r(app/views/account/foo\.html\.slim)
17
- assert_file File.join("app", "views", "account", "bar.html.slim"), %r(app/views/account/bar\.html\.slim)
18
- end
19
-
20
- test "should generate SlimLint valid templates" do
21
- run_generator
22
- templates = Dir[File.join(Rails.root, 'app', 'views', '**', '*.slim')]
23
- assert_empty lint(templates)
24
- end
25
- end
@@ -1,78 +0,0 @@
1
- require 'test_helper'
2
- require 'lib/generators/slim/testing_helper'
3
-
4
- class Slim::Generators::MailerGeneratorTest < Rails::Generators::TestCase
5
- include SlimLintHelpers
6
-
7
- destination File.join(Rails.root)
8
- tests Rails::Generators::MailerGenerator
9
- arguments %w(notifier foo bar --template-engine slim)
10
-
11
- setup :prepare_destination
12
- setup :copy_routes
13
-
14
- test "should invoke template engine" do
15
- run_generator
16
-
17
- rails_version = ::Rails.version.to_s
18
-
19
- if rails_version >= '5.0'
20
- assert_file "app/views/notifier_mailer/foo.html.slim" do |view|
21
- assert_match %r(app/views/notifier_mailer/foo\.html\.slim), view
22
- assert_match(/\#\{@greeting/, view)
23
- end
24
-
25
- assert_file "app/views/notifier_mailer/bar.html.slim" do |view|
26
- assert_match %r(app/views/notifier_mailer/bar\.html\.slim), view
27
- assert_match(/\#\{@greeting/, view)
28
- end
29
-
30
- assert_file "app/views/notifier_mailer/foo.text.slim" do |view|
31
- assert_match %r(app/views/notifier_mailer/foo\.text\.slim), view
32
- assert_match(/@greeting/, view)
33
- end
34
-
35
- assert_file "app/views/notifier_mailer/bar.text.slim" do |view|
36
- assert_match %r(app/views/notifier_mailer/bar\.text\.slim), view
37
- assert_match(/@greeting/, view)
38
- end
39
- else
40
- if rails_version >= '4.2'
41
- assert_file "app/views/layouts/mailer.text.slim" do |view|
42
- assert_match(/\= yield/, view)
43
- end
44
-
45
- assert_file "app/views/layouts/mailer.html.slim" do |view|
46
- assert_match(/\= yield/, view)
47
- end
48
-
49
- assert_file "app/views/notifier/foo.html.slim" do |view|
50
- assert_match %r(app/views/notifier/foo\.html\.slim), view
51
- assert_match(/\#\{@greeting/, view)
52
- end
53
-
54
- assert_file "app/views/notifier/bar.html.slim" do |view|
55
- assert_match %r(app/views/notifier/bar\.html\.slim), view
56
- assert_match(/\#\{@greeting/, view)
57
- end
58
-
59
- end
60
-
61
- assert_file "app/views/notifier/foo.text.slim" do |view|
62
- assert_match %r(app/views/notifier/foo\.text\.slim), view
63
- assert_match(/@greeting/, view)
64
- end
65
-
66
- assert_file "app/views/notifier/bar.text.slim" do |view|
67
- assert_match %r(app/views/notifier/bar\.text\.slim), view
68
- assert_match(/@greeting/, view)
69
- end
70
- end
71
- end
72
-
73
- test "should generate SlimLint valid templates" do
74
- run_generator
75
- templates = Dir[File.join(Rails.root, 'app', 'views', '**', '*.slim')]
76
- assert_empty lint(templates)
77
- end
78
- end
@@ -1,34 +0,0 @@
1
- require 'test_helper'
2
- require 'lib/generators/slim/testing_helper'
3
-
4
- class Slim::Generators::ScaffoldGeneratorTest < Rails::Generators::TestCase
5
- include SlimLintHelpers
6
-
7
- destination File.join(Rails.root)
8
- tests Rails::Generators::ScaffoldGenerator
9
- arguments %w(product_line title:string price:integer --template-engine slim --orm active-record)
10
-
11
- setup :prepare_destination
12
- setup :copy_routes
13
-
14
- test "should invoke template engine" do
15
- run_generator
16
-
17
- %w(index edit new show _form).each { |view| assert_file File.join "app", "views", "product_lines", "#{view}.html.slim" }
18
- assert_no_file File.join "app", "views", "layouts", "product_lines.html.slim"
19
- end
20
-
21
- test "should revoke template engine" do
22
- run_generator
23
- run_generator ["product_line", "--orm", "active-record"], behavior: :revoke
24
-
25
- assert_no_file File.join "app", "views", "product_lines"
26
- assert_no_file File.join "app", "views", "layouts", "product_lines.html.slim"
27
- end
28
-
29
- test "should generate SlimLint valid templates" do
30
- run_generator
31
- templates = Dir[File.join(Rails.root, 'app', 'views', '**', '*.slim')]
32
- assert_empty lint(templates)
33
- end
34
- end
@@ -1,11 +0,0 @@
1
- require 'slim_lint'
2
-
3
- module SlimLintHelpers
4
- EXCLUDED_LINTERS = %w[LineLength]
5
-
6
- def lint(templates)
7
- SlimLint::Runner.new.run(files: templates, excluded_linters: EXCLUDED_LINTERS).lints.map(&:message)
8
- end
9
- end
10
-
11
- require_generators slim: ['scaffold', 'controller', 'mailer']
@@ -1,72 +0,0 @@
1
- require 'sprockets'
2
- require 'test_helper'
3
- require 'tmpdir'
4
-
5
- class Slim::Rails::AssetsTest < ActiveSupport::TestCase
6
- def with_app(use_sprockets, code)
7
- Dir.mktmpdir do |dir|
8
- manifest_path = File.join(dir, 'app', 'assets', 'config', 'manifest.js')
9
- FileUtils.mkdir_p(File.dirname(manifest_path))
10
- File.write(manifest_path, '//= link_tree ../html .slim')
11
-
12
- app_path = File.join(dir, 'app.rb')
13
- File.write(app_path, <<-APP)
14
- require 'rails'
15
- require 'sprockets/railtie' if #{use_sprockets}
16
- require 'slim-rails'
17
- class DummyApp < ::Rails::Application
18
- config.root = #{dir.inspect}
19
- config.assets.enabled = true if #{use_sprockets}
20
- config.eager_load = false
21
- end
22
- DummyApp.initialize!
23
- #{code}
24
- APP
25
-
26
- if use_sprockets && Sprockets::VERSION.to_i >= 4
27
- manifest_path = File.join(dir, 'app', 'assets', 'config', 'manifest.js')
28
- FileUtils.mkdir_p(File.dirname(manifest_path))
29
- File.write(manifest_path, '')
30
- end
31
-
32
- asset_path = File.join(dir, 'app', 'assets', 'html', 'test.slim')
33
- FileUtils.mkdir_p(File.dirname(asset_path))
34
- File.write(asset_path, ".test\n | hi")
35
-
36
- asset_path = File.join(dir, 'app', 'assets', 'html', 'test_helpers.slim')
37
- File.write(asset_path, '= logical_path')
38
-
39
- `BUNDLE_GEMFILE=#{ENV['BUNDLE_GEMFILE']} bundle exec ruby #{app_path}`
40
- end
41
- end
42
-
43
- test "should work without Sprockets" do
44
- assert_equal '', with_app(false, 'DummyApp.assets')
45
- end
46
-
47
- test "should return HTML version when passing 'text/html' content type" do
48
- assert_equal '<div class="test">hi</div>', with_app(true, 'print DummyApp.assets["test", accept: "text/html"]')
49
- end
50
-
51
- if Sprockets::VERSION.to_i < 4
52
- test "should return HTML version when passing '.slim' extension" do
53
- assert_equal '<div class="test">hi</div>', with_app(true, 'print DummyApp.assets["test.slim"]')
54
- end
55
- end
56
-
57
- if Sprockets::VERSION.to_i >= 3
58
- test "should return HTML version when passing '.html' extension" do
59
- assert_equal '<div class="test">hi</div>', with_app(true, 'print DummyApp.assets["test.html"]')
60
- end
61
- end
62
-
63
- if Sprockets::VERSION.to_i >= 4
64
- test "should return Slim version when passing '.slim' extension" do
65
- assert_equal ".test\n | hi", with_app(true, 'print DummyApp.assets["test.slim"]')
66
- end
67
- end
68
-
69
- test "should work with asset helpers" do
70
- assert_equal 'test_helpers', with_app(true, 'print DummyApp.assets["test_helpers", accept: "text/html"]')
71
- end
72
- end
data/test/test_helper.rb DELETED
@@ -1,66 +0,0 @@
1
- require 'rubygems'
2
- require 'minitest/autorun'
3
- require 'rails'
4
- require 'rails/test_help'
5
- require 'rails/generators'
6
- require 'rails/generators/test_case'
7
- require 'slim-rails'
8
-
9
- class TestApp < Rails::Application
10
- config.root = File.dirname(__FILE__)
11
- end
12
- Rails.application = TestApp
13
-
14
- module Rails
15
- def self.root
16
- @root ||= File.expand_path(File.join(File.dirname(__FILE__), '..', 'tmp', 'rails'))
17
- end
18
- end
19
- Rails.application.config.root = Rails.root
20
-
21
- Rails::Generators.configure! Rails.application.config.generators
22
-
23
- Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
24
-
25
- def copy_routes
26
- routes = File.expand_path(File.join(File.dirname(__FILE__), 'fixtures', 'routes.rb'))
27
- destination = File.join(Rails.root, "config")
28
- FileUtils.mkdir_p(destination)
29
- FileUtils.cp File.expand_path(routes), destination
30
- end
31
-
32
- def assert_class(klass, content)
33
- assert content =~ /class #{klass}(\(.+\))?(.*?)\nend/m, "Expected to have class #{klass}"
34
- yield $2.strip if block_given?
35
- end
36
-
37
- def generator_list
38
- {
39
- rails: ['scaffold', 'controller', 'mailer'],
40
- slim: ['scaffold', 'controller', 'mailer']
41
- }
42
- end
43
-
44
- def path_prefix(name)
45
- case name
46
- when :rails
47
- 'rails/generators'
48
- else
49
- 'generators'
50
- end
51
- end
52
-
53
- def require_generators(generator_list)
54
- generator_list.each do |name, generators|
55
- generators.each do |generator_name|
56
- if name.to_s == 'rails' && generator_name.to_s == 'mailer'
57
- require File.join(path_prefix(name), generator_name.to_s, "#{generator_name}_generator")
58
- else
59
- require File.join(path_prefix(name), name.to_s, generator_name.to_s, "#{generator_name}_generator")
60
- end
61
- end
62
- end
63
- end
64
- alias :require_generator :require_generators
65
-
66
- require_generators generator_list