common_core_js 0.1.1 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1 +1 @@
1
- = render partial: "common/common_edit_form", locals: {singular: '<%= @singular %>', object: <%= @singular %>, url: <%= path_helper %>(<%= path_arity %>), colspan: colspan}
1
+ = render partial: "common/common_edit_form", locals: {singular: '<%= @singular %>', object: <%= @singular %>, url: <%= path_helper_singular %>(<%= path_arity %>), colspan: colspan}
@@ -0,0 +1 @@
1
+ <%= all_form_fields %>
@@ -0,0 +1,3 @@
1
+ <%= all_line_fields %>
2
+ %td
3
+ = link_to "Edit <i class='fa fa-1x fa-list-alt'></i>".html_safe, edit_<%= path_helper_singular %>(<%= singular %>), remote: true , disable_with: "Loading...", class: "edit-<%= singular %>-button btn btn-primary pull-right "
@@ -1,5 +1,5 @@
1
1
 
2
- = link_to "New <%= singular.gsub('_',' ') %>", new_<%= path_helper %>(<%= nested_arity_for_path %>), disable_with: "Loading...", remote: true, class: "new-<%= singular %>-button btn btn-primary pull-right"
2
+ = link_to "New <%= singular.gsub('_',' ') %>", new_<%= path_helper_singular %>(<%= nested_arity_for_path %>), disable_with: "Loading...", remote: true, class: "new-<%= singular %>-button btn btn-primary pull-right"
3
3
 
4
4
  .clearfix
5
5
  .new-<%= singular %>-form{style: "display: none; position: relative;"}
@@ -1,3 +1,3 @@
1
- = render partial: "common/common_new_form", locals: {singular: '<%= singular %>', plural: "<%= plural %>", object: @<%= singular %>, url: new_<%= path_helper %>(<%= nested_objects_arity %>)}
1
+ = render partial: "common/common_new_form", locals: {singular: '<%= singular %>', plural: "<%= plural %>", object: @<%= singular %>, url: <%= path_helper_plural %>(<%= nested_objects_arity %>)}
2
2
 
3
3
 
@@ -0,0 +1,4 @@
1
+ .container-fluid
2
+ .row
3
+ .col-md-12
4
+ = render partial: "<%= namespace_with_trailing_dash %><%= plural %>/list", locals: {<%= plural %>: <%= all_objects_root %>.order("created_at DESC").page(1)}
@@ -28,7 +28,7 @@ class <%= controller_class_name %> < ApplicationController
28
28
 
29
29
  respond_to do |format|
30
30
  format.js<% if @with_index %>
31
- format.html {render 'all_<%=plural_name %>.haml'}<% end %>
31
+ format.html {render 'all.haml'}<% end %>
32
32
  end
33
33
  end
34
34
 
@@ -58,16 +58,14 @@ class <%= controller_class_name %> < ApplicationController
58
58
  end
59
59
 
60
60
  def edit
61
-
62
61
  respond_to do |format|
63
62
  format.js
64
63
  end
65
64
  end
66
65
 
67
66
  def update
68
-
69
67
  respond_to do |format|
70
- if !@<%=singular_name %>.save
68
+ if !@<%=singular_name %>.update(<%= singular %>_params)
71
69
  flash[:alert] = "<%=singular_name.titlecase %> could not be saved"
72
70
  end
73
71
  format.js {}
@@ -0,0 +1,110 @@
1
+ require 'rails_helper'
2
+
3
+ describe <%= controller_class_name %> do
4
+ render_views
5
+ let(:<%= @auth %>) {create(:<%= @auth.gsub('current_', '') %>)}
6
+ let(:<%= singular %>) {create(:<%= singular %><%= object_parent_mapping_as_argument_for_specs %> )}
7
+
8
+ <%= objest_nest_factory_setup %>
9
+
10
+ before(:each) do
11
+ @request.env["devise.mapping"] = Devise.mappings[:account]
12
+
13
+ sign_in <%= @auth %>, scope: :<%= @auth_identifier %>
14
+ end
15
+
16
+ describe "index" do
17
+ it "should respond" do
18
+ get :index, xhr: true, format: 'js', params: {
19
+ <%= objest_nest_params_by_id_for_specs %>
20
+ }
21
+ end
22
+ end
23
+
24
+ describe "new" do
25
+ it "should show form" do
26
+ get :new, xhr: true, format: 'js', params: {
27
+ <%= objest_nest_params_by_id_for_specs %>
28
+ }
29
+ end
30
+ end
31
+
32
+ describe "create" do
33
+ it "should create a new <%= singular %>" do
34
+ expect {
35
+ post :create, xhr: true, format: 'js', params: {
36
+ <%= (@nested_args.empty? ? "" : objest_nest_params_by_id_for_specs + ",") %>
37
+ <%= singular %>: {
38
+ <%= columns_spec_with_sample_data %>
39
+ }}
40
+ }.to change { <%= @singular_class %>.all.count }.by(1)
41
+ assert_response :ok
42
+ end
43
+
44
+ # it "should not create if there are errors" do
45
+ # post :create, xhr: true, format: 'js', params: {id: <%= singular %>.id,
46
+ # <%= singular %>: {skin_id: nil}}
47
+ #
48
+ # expect(controller).to set_flash.now[:alert].to(/Oops, your <%= singular %> could not be saved/)
49
+ # end
50
+ end
51
+
52
+ describe "edit" do
53
+ it "should return an editable form" do
54
+ get :edit, xhr: true, format: 'js', params: {
55
+ <%= (@nested_args.empty? ? "" : objest_nest_params_by_id_for_specs + ",") %>
56
+ id: <%= singular %>.id
57
+ }
58
+ assert_response :ok
59
+ end
60
+ end
61
+
62
+ describe "show" do
63
+ it "should return a view form" do
64
+ get :show, xhr: true, format: 'js', params: {
65
+ <%= (@nested_args.empty? ? "" : objest_nest_params_by_id_for_specs + ",") %>
66
+ id: <%= singular %>.id
67
+ }
68
+ assert_response :ok
69
+ end
70
+ end
71
+
72
+ describe "update" do
73
+ it "should update" do
74
+ put :update, xhr: true, format: 'js',
75
+ params: {
76
+ <%= (@nested_args.empty? ? "" : objest_nest_params_by_id_for_specs + ",") %>
77
+ id: <%= singular %>.id,
78
+ <%= singular %>: {
79
+ <%= columns_spec_with_sample_data %>
80
+ }}
81
+
82
+ assert_response :ok
83
+ end
84
+
85
+ # it "should not update if invalid" do
86
+ # put :update, xhr: true, format: 'js',
87
+ # params: {
88
+ # id: <%= singular %>.id,
89
+ # <%= singular %>: {
90
+ # <%= columns_spec_with_sample_data %>
91
+ # }}
92
+ #
93
+ # assert_response :ok
94
+ #
95
+ # expect(controller).to set_flash.now[:alert].to(/Oops, your <%= singular %> could not be saved/)
96
+ # end
97
+ end
98
+
99
+ describe "#destroy" do
100
+ it "should destroy" do
101
+ post :destroy, format: 'js', params: {
102
+ <%= (@nested_args.empty? ? "" : objest_nest_params_by_id_for_specs + ",") %>
103
+ id: <%= singular %>.id
104
+ }
105
+ assert_response :ok
106
+ expect(<%= @singular_class %>.count).to be(0)
107
+ end
108
+ end
109
+ end
110
+
@@ -1 +1 @@
1
- <%%= render partial: 'common/common_edit', locals: {object: @<%= singular_name %>, singular: "<%= singular_name %>", plural: "<%= plural_name %>", url: <%= path_helper %>(<%= path_arity %>)} %>
1
+ <%%= render partial: 'common/common_edit', locals: {object: @<%= singular_name %>, singular: "<%= singular_name %>", plural: "<%= plural_name %>", url: <%= path_helper_singular %>(<%= path_arity %>)} %>
@@ -1,6 +1,6 @@
1
1
  <%%= render partial: 'common/common_update', locals: {object: @<%= singular %>, singular: "<%= singular %>",
2
2
  plural: "<%= plural %>",
3
- url: <%= path_helper %>(<%= path_arity %>),
3
+ url: <%= path_helper_singular %>(<%= path_arity %>),
4
4
  pass_through_locals: {
5
5
  <%= nested_assignments %>
6
6
  }} %>
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: common_core_js
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jason Fleetwood-Boldt
@@ -14,95 +14,122 @@ dependencies:
14
14
  name: rails
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
18
- - !ruby/object:Gem::Version
19
- version: 6.0.3
20
17
  - - ">="
21
18
  - !ruby/object:Gem::Version
22
- version: 6.0.3.2
19
+ version: '0'
23
20
  type: :runtime
24
21
  prerelease: false
25
22
  version_requirements: !ruby/object:Gem::Requirement
26
23
  requirements:
27
- - - "~>"
28
- - !ruby/object:Gem::Version
29
- version: 6.0.3
30
24
  - - ">="
31
25
  - !ruby/object:Gem::Version
32
- version: 6.0.3.2
26
+ version: '0'
33
27
  - !ruby/object:Gem::Dependency
34
28
  name: kaminari
35
29
  requirement: !ruby/object:Gem::Requirement
36
30
  requirements:
37
- - - ">"
38
- - !ruby/object:Gem::Version
39
- version: '1'
40
31
  - - ">="
41
32
  - !ruby/object:Gem::Version
42
- version: 1.2.1
33
+ version: '0'
43
34
  type: :runtime
44
35
  prerelease: false
45
36
  version_requirements: !ruby/object:Gem::Requirement
46
37
  requirements:
47
- - - ">"
48
- - !ruby/object:Gem::Version
49
- version: '1'
50
38
  - - ">="
51
39
  - !ruby/object:Gem::Version
52
- version: 1.2.1
40
+ version: '0'
53
41
  - !ruby/object:Gem::Dependency
54
42
  name: haml-rails
55
43
  requirement: !ruby/object:Gem::Requirement
56
44
  requirements:
57
- - - ">"
58
- - !ruby/object:Gem::Version
59
- version: '2'
60
45
  - - ">="
61
46
  - !ruby/object:Gem::Version
62
- version: 2.0.1
47
+ version: '0'
63
48
  type: :runtime
64
49
  prerelease: false
65
50
  version_requirements: !ruby/object:Gem::Requirement
66
51
  requirements:
67
- - - ">"
52
+ - - ">="
68
53
  - !ruby/object:Gem::Version
69
- version: '2'
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: sass-rails
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
70
59
  - - ">="
71
60
  - !ruby/object:Gem::Version
72
- version: 2.0.1
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
73
69
  - !ruby/object:Gem::Dependency
74
- name: simplecov
70
+ name: bootsnap
75
71
  requirement: !ruby/object:Gem::Requirement
76
72
  requirements:
77
- - - ">"
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
78
81
  - !ruby/object:Gem::Version
79
- version: '0.17'
80
- - - "~>"
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: bootstrap
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
81
88
  - !ruby/object:Gem::Version
82
- version: '0.17'
83
- type: :development
89
+ version: '0'
90
+ type: :runtime
84
91
  prerelease: false
85
92
  version_requirements: !ruby/object:Gem::Requirement
86
93
  requirements:
87
- - - ">"
94
+ - - ">="
88
95
  - !ruby/object:Gem::Version
89
- version: '0.17'
90
- - - "~>"
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: font-awesome-rails
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
91
109
  - !ruby/object:Gem::Version
92
- version: '0.17'
110
+ version: '0'
93
111
  description: Simple, plug & play Rails scaffolding with really simple Javascript
94
112
  email: jason.fb@datatravels.com
95
113
  executables: []
96
114
  extensions: []
97
115
  extra_rdoc_files: []
98
116
  files:
117
+ - ".generators"
118
+ - ".gitignore"
119
+ - ".rakeTasks"
120
+ - Gemfile
121
+ - Gemfile.lock
99
122
  - LICENSE
100
123
  - README.md
101
124
  - Rakefile
125
+ - app/.DS_Store
102
126
  - app/assets/config/common_core_js_manifest.js
127
+ - app/assets/images/common_core_js/.keep
103
128
  - app/assets/stylesheets/common_core_js/application.css
129
+ - app/assets/stylesheets/common_core_js/common_core.scss
104
130
  - app/controllers/common_core_js/application_controller.rb
105
131
  - app/helpers/common_core_js/application_helper.rb
132
+ - app/javascript/common_core/xyz.js
106
133
  - app/jobs/common_core_js/application_job.rb
107
134
  - app/mailers/common_core_js/application_mailer.rb
108
135
  - app/models/common_core_js/application_record.rb
@@ -116,10 +143,14 @@ files:
116
143
  - app/views/common/_common_show_form.haml
117
144
  - app/views/common/_common_update.js.erb
118
145
  - app/views/layouts/common_core_js/application.html.erb
146
+ - bin/rails
147
+ - common_core_js.gemspec
119
148
  - config/routes.rb
149
+ - lib/.DS_Store
120
150
  - lib/common_core_js.rb
121
151
  - lib/common_core_js/engine.rb
122
152
  - lib/common_core_js/version.rb
153
+ - lib/generators/.DS_Store
123
154
  - lib/generators/common_core/USAGE
124
155
  - lib/generators/common_core/erb/scaffold/common_core_scaffold_generator.rb
125
156
  - lib/generators/common_core/scaffold_generator.rb
@@ -128,7 +159,9 @@ files:
128
159
  - lib/generators/common_core/templates/_line.haml
129
160
  - lib/generators/common_core/templates/_list.haml
130
161
  - lib/generators/common_core/templates/_new.haml
162
+ - lib/generators/common_core/templates/all.haml
131
163
  - lib/generators/common_core/templates/controller.rb
164
+ - lib/generators/common_core/templates/controller_spec.rb
132
165
  - lib/generators/common_core/templates/create.js.erb
133
166
  - lib/generators/common_core/templates/destroy.js.erb
134
167
  - lib/generators/common_core/templates/edit.js.erb
@@ -136,6 +169,7 @@ files:
136
169
  - lib/generators/common_core/templates/new.js.erb
137
170
  - lib/generators/common_core/templates/update.js.erb
138
171
  - lib/tasks/common_core_js_tasks.rake
172
+ - vendor/assets/stylesheets/common_core_js.scss
139
173
  homepage: https://blog.jasonfleetwoodboldt.com/common-core-js/
140
174
  licenses:
141
175
  - MIT
@@ -143,14 +177,24 @@ metadata:
143
177
  source_code_uri: https://github.com/jasonfb/common_core_js
144
178
  documentation_uri: https://github.com/jasonfb/common_core_js
145
179
  homepage_uri: https://blog.jasonfleetwoodboldt.com/common-core-js/
146
- mailing_list_uri: https://blog.jasonfleetwoodboldt.com
147
- post_install_message: "---------------------------------------------\nWelcome to Common
148
- Core\n\nrails generate common_score:scaffold Thing\n\n * Build plug-and-play
149
- scaffolding mixing HAML with jQuery-based Javascript\n * Automatically Reads
150
- Your Models (make them first!)\n * Excellent for CRUD, lists with pagination,
151
- searching, sorting.\n * Wonderful for prototyping\n * Plays with Devise, Kaminari,
152
- Haml-Rails\n * Nest your routes model-by-model for built-in poor man's authentication\n
153
- \ * Throw it away when you're done. \n\nsee README for complete instructions.\n---------------------------------------------\n"
180
+ mailing_list_uri: https://blog.jasonfleetwoodboldt.com/#sfba-form2-container
181
+ post_install_message: |
182
+ ---------------------------------------------
183
+ Welcome to Common Core
184
+
185
+ rails generate common_score:scaffold Thing
186
+
187
+ * Build plug-and-play scaffolding mixing HAML with jQuery-based Javascript
188
+ * Automatically Reads Your Models (make them before building your scaffolding!)
189
+ * Excellent for CRUD, lists with pagination, searching, sorting.
190
+ * Wonderful for prototyping.
191
+ * Plays nicely with Devise, Kaminari, Haml-Rails, Rspec.
192
+ * Create specs autoamatically along with the controllers.
193
+ * Nest your routes model-by-model for built-in poor man's authentication
194
+ * Throw the scaffolding away when your app is ready to graduate to its next phase.
195
+
196
+ see README for complete instructions.
197
+ ---------------------------------------------
154
198
  rdoc_options: []
155
199
  require_paths:
156
200
  - lib