sharp_admin 1.1 → 1.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 52114ce6b82a6330e94300dfc8fab7bf8707a5b8
4
- data.tar.gz: 57c9ebb861063a136aa8b51db83d7fe64d429a69
3
+ metadata.gz: c4e3c8abbc1860c7c5a8c17d42ababd5b35631a4
4
+ data.tar.gz: 9c3910137ff18ac23708abe83565074b25a3b38e
5
5
  SHA512:
6
- metadata.gz: 2c636e4fd03e66813c45eda0ad2cda6fbaa212a595338a5edf915c479fb5e75f5d591757f893179de35bac892cc25044ed106f6e0ec03697adc5aee5e5504164
7
- data.tar.gz: a28773397d3fb624ce5b175d5c614c8febf5bb8e95f9f65e48b8f748ca2e49030861cf621943c703d010f71e9f2e875941e3b0c6101c893cfa6b22d0fc23e25a
6
+ metadata.gz: 1ab66a9dbee912cfb78512faa0105a11741ec1032a7f2a9276113e780bdd818ffb5c225dbe2912d9719e3c3c018ecbe8210ca74e3e46d990ba7af83abda23cd2
7
+ data.tar.gz: 6671f557b12d5fbea3847bb247b9e3c193e98c2da051f1770959e59b9aedacba39dc0dcaf5f6f65f58b4d57ea4c8969450db34f4efb05811d5e97f56555abe73
@@ -31,10 +31,6 @@ class SharpAdminGenerator < Rails::Generators::NamedBase
31
31
  template "controller.rb", File.join("app/controllers/#{options[:ns]}", "#{controller_file_name}_controller.rb")
32
32
  end
33
33
 
34
- def create_controller_rspec
35
- template "controller_spec.rb", File.join("spec/controllers/#{options[:ns]}", "#{controller_file_name}_controller_spec.rb")
36
- end
37
-
38
34
  def create_helper
39
35
  empty_directory "app/helpers/#{options[:ns]}"
40
36
  template "base_helper.rb", File.join("app/helpers/#{options[:ns]}", "base_helper.rb")
@@ -17,7 +17,7 @@ class <%= options[:ns].classify %>::<%= controller_class_name %>Controller < <%=
17
17
  def create
18
18
  @<%= singular_table_name %> = <%= class_name %>.new(<%= singular_table_name %>_params)
19
19
  if @<%= singular_table_name %>.save
20
- redirect_to admin_<%= plural_table_name %>_path, :notice => "Successfully created <%= human_name.downcase %>."
20
+ redirect_to <%= options[:ns] %>_<%= plural_table_name %>_path, :notice => "Successfully created <%= human_name.downcase %>."
21
21
  else
22
22
  render :new
23
23
  end
@@ -33,7 +33,7 @@ class <%= options[:ns].classify %>::<%= controller_class_name %>Controller < <%=
33
33
 
34
34
  def update
35
35
  if @<%= singular_table_name %>.update_attributes(<%= singular_table_name %>_params)
36
- redirect_to admin_<%= plural_table_name %>_path, :notice => "Successfully updated <%= human_name.downcase %>."
36
+ redirect_to <%= options[:ns] %>_<%= plural_table_name %>_path, :notice => "Successfully updated <%= human_name.downcase %>."
37
37
  else
38
38
  render :edit
39
39
  end
@@ -42,7 +42,7 @@ class <%= options[:ns].classify %>::<%= controller_class_name %>Controller < <%=
42
42
 
43
43
  def destroy
44
44
  @<%= singular_table_name %>.destroy
45
- redirect_to admin_<%= plural_table_name %>_path, :notice => "<%= human_name %> deleted."
45
+ redirect_to <%= options[:ns] %>_<%= plural_table_name %>_path, :notice => "<%= human_name %> deleted."
46
46
  end
47
47
 
48
48
  protected
@@ -1,17 +1,12 @@
1
1
  - if @<%= singular_table_name %>.errors.any?
2
2
  %ul.errors
3
- @<%= singular_table_name %>.errors.full_messages.each do |msg|
3
+ - @<%= singular_table_name %>.errors.full_messages.each do |msg|
4
4
  %li= msg
5
5
 
6
- - @attributes.each do |attribute|
6
+ <%- @attributes.each do |attribute| %>
7
7
  <% next if ["id", "created_at", "updated_at"].include?(attribute.name) -%>
8
- .form-group
9
- = f.label :<%= attribute.name %>, :class => "col-sm-2 control-label"
10
- .col-sm-4
11
- = f.text_field :<%= attribute.name %>, :class => "form-control", :placeholder => "<%= attribute.name.capitalize %>"
12
-
8
+ = f.input :<%= attribute.name %>, placeholder: "<%= attribute.name.capitalize %>"
9
+ <% end %>
13
10
 
14
11
  - label = @<%= singular_table_name %>.new_record? ? "Create" : "Update"
15
- .form-group
16
- .col-sm-offset-2 col-sm-4
17
- = f.submit label, class: 'btn btn-default'
12
+ = f.submit label, class: 'btn btn-default'
@@ -1,7 +1,7 @@
1
1
  .page-header
2
2
  %h3
3
3
  Editing
4
- = link_to "<%= human_name.downcase %> #{@<%= singular_table_name %>.id}", admin_<%= singular_table_name %>_path(@<%= singular_table_name %>) %>
4
+ = link_to "<%= human_name.downcase %> #{@<%= singular_table_name %>.id}", <%= options[:ns] %>_<%= singular_table_name %>_path(@<%= singular_table_name %>)
5
5
 
6
- = form_for [<%= options[:ns] %>, @<%= singular_table_name %>], :html => { :class => "form-horizontal", :role => "form" } do |f|
6
+ = simple_form_for [:<%= options[:ns] %>, @<%= singular_table_name %>], :html => { :class => "form-horizontal", :role => "form" } do |f|
7
7
  = render "form", { :f => f }
@@ -1,7 +1,7 @@
1
1
  %h3
2
2
  <%= human_name.pluralize %>
3
3
 
4
- <% if options[:search_by].present? -%>
4
+ <%- if options[:search_by].present? -%>
5
5
  = search_form_for @q, :url => <%= options[:ns] %>_<%= plural_table_name %>_path, :html => { :method => :get, :class => "well form-inline" } do |f|
6
6
  .class.form-group
7
7
  = f.text_field :<%= options[:search_by] %>_cont, :type => "search", :class => "form-control", :placeholder => "Search by <%= options[:search_by] %>"
@@ -9,12 +9,12 @@
9
9
  = f.submit "Search", :class => "btn btn-default"
10
10
  <% end %>
11
11
 
12
- <% unless options[:no_create] || options[:read_only] %>
12
+ <%- unless options[:no_create] || options[:read_only] %>
13
13
  %p
14
14
  = link_to("Create a new <%= human_name %>", new_<%= options[:ns] %>_<%= singular_table_name %>_path)
15
15
  <% end -%>
16
16
 
17
- %table.sortable.table.table-striped.table-bordered.table-condensed
17
+ %table.sortable.table
18
18
  %thead
19
19
  %tr
20
20
  <% @attributes.each do |attribute| -%>
@@ -2,5 +2,5 @@
2
2
  %h3
3
3
  Create new <%= human_name.downcase %>
4
4
 
5
- = form_for [<%= options[:ns] %>, @<%= singular_table_name %>], :html => { :class => "form-horizontal", :role => "form" } do |f|
5
+ = simple_form_for [:<%= options[:ns] %>, @<%= singular_table_name %>], :html => { :class => "form-horizontal", :role => "form" } do |f|
6
6
  = render "form", { :f => f }
@@ -1,3 +1,3 @@
1
1
  module EasyAdmin
2
- VERSION = "1.1"
2
+ VERSION = "1.1.2"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sharp_admin
3
3
  version: !ruby/object:Gem::Version
4
- version: '1.1'
4
+ version: 1.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - sharp
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-12-22 00:00:00.000000000 Z
11
+ date: 2016-03-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -67,7 +67,6 @@ files:
67
67
  - lib/sharp_admin/templates/base_controller_spec.rb
68
68
  - lib/sharp_admin/templates/base_helper.rb
69
69
  - lib/sharp_admin/templates/controller.rb
70
- - lib/sharp_admin/templates/controller_spec.rb
71
70
  - lib/sharp_admin/templates/views/_form.html.erb
72
71
  - lib/sharp_admin/templates/views/edit.html.erb
73
72
  - lib/sharp_admin/templates/views/index.html.erb
@@ -1,136 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe <%= options[:ns].classify %>::<%= controller_class_name %>Controller do
4
-
5
- def mock_<%= singular_table_name %>(stubs={})
6
- (@mock_<%= singular_table_name %> ||= mock_model(<%= class_name %>).as_null_object).tap do |<%= singular_table_name %>|
7
- stubs.each_key do |method_name|
8
- allow(<%= singular_table_name %>).to receive(method_name).and_return(stubs[method_name])
9
- end
10
- end
11
- end
12
-
13
- before { allow(controller).to receive(:require_admin) }
14
-
15
- describe "GET index" do
16
- it "assigns all <%= plural_table_name %> as @<%= plural_table_name %>" do
17
- allow(controller).to receive(:find_<%= plural_table_name %>).and_return([mock_<%= singular_table_name %>])
18
- get :index
19
- expect(assigns(:<%= plural_table_name %>)).to eq([mock_<%= singular_table_name %>])
20
- end
21
- end
22
-
23
- describe "GET show" do
24
- it "assigns the requested <%= singular_table_name %> as @<%=singular_table_name %>" do
25
- allow(<%= class_name %>).to receive(:find).with("37") { mock_<%= singular_table_name %> }
26
- get :show, :id => "37"
27
- expect(assigns(:<%= singular_table_name %>)).to be(mock_<%= singular_table_name %>)
28
- end
29
- end
30
-
31
- <% unless options[:no_create] or options[:read_only] %>
32
- describe "GET new" do
33
- it "assigns a new <%= singular_table_name %> as @<%= singular_table_name %>" do
34
- allow(<%= class_name %>).to receive(:new) { mock_<%= singular_table_name %> }
35
- get :new
36
- expect(assigns(:<%= singular_table_name %>)).to be(mock_<%= singular_table_name %>)
37
- end
38
- end
39
-
40
- describe "POST create" do
41
-
42
- describe "with valid params" do
43
- it "assigns a newly created <%= singular_table_name %> as @<%= singular_table_name %>" do
44
- allow(<%= class_name %>).to receive(:new).with({'these' => 'params'}) { mock_<%= singular_table_name %>(:save => true) }
45
- post :create, :<%= singular_table_name %> => {'these' => 'params'}
46
- expect(assigns(:<%= singular_table_name %>)).to be(mock_<%= singular_table_name %>)
47
- end
48
-
49
- it "redirects to the created <%= singular_table_name %>" do
50
- allow(<%= class_name %>).to receive(:new) { mock_<%= singular_table_name %>(:save => true) }
51
- post :create, :<%= singular_table_name %> => {}
52
- expect(response).to redirect_to(<%= options[:ns] %>_<%= plural_table_name %>_url)
53
- end
54
- end
55
-
56
- describe "with invalid params" do
57
- it "assigns a newly created but unsaved <%= singular_table_name %> as @<%= singular_table_name %>" do
58
- allow(<%= class_name %>).to receive(:new).with({'these' => 'params'}) { mock_<%= singular_table_name %>(:save => false) }
59
- post :create, :<%= singular_table_name %> => {'these' => 'params'}
60
- expect(assigns(:<%= singular_table_name %>)).to be(mock_<%= singular_table_name %>)
61
- end
62
-
63
- it "re-renders the 'new' template" do
64
- allow(<%= class_name %>).to receive(:new) { mock_<%= singular_table_name %>(:save => false) }
65
- post :create, :<%= singular_table_name %> => {}
66
- expect(response).to render_template("new")
67
- end
68
- end
69
-
70
- end
71
- <% end -%>
72
-
73
- <% unless options[:read_only] %>
74
- describe "GET edit" do
75
- it "assigns the requested <%= singular_table_name %> as @<%= singular_table_name %>" do
76
- allow(<%= class_name %>).to receive(:find).with("37") { mock_<%= singular_table_name %> }
77
- get :edit, :id => "37"
78
- expect(assigns(:<%= singular_table_name %>)).to be(mock_<%= singular_table_name %>)
79
- end
80
- end
81
-
82
- describe "PUT update" do
83
-
84
- describe "with valid params" do
85
- it "updates the requested <%= singular_table_name %>" do
86
- expect(<%= class_name %>).to receive(:find).with("37") { mock_<%= singular_table_name %> }
87
- expect(mock_<%= singular_table_name %>).to receive(:update_attributes).with({'these' => 'params'})
88
- put :update, :id => "37", :<%= singular_table_name %> => {'these' => 'params'}
89
- end
90
-
91
- it "assigns the requested <%= singular_table_name %> as @<%= singular_table_name %>" do
92
- allow(<%= class_name %>).to receive(:find) { mock_<%= singular_table_name %>(:update_attributes => true) }
93
- put :update, :id => "1"
94
- expect(assigns(:<%= singular_table_name %>)).to be(mock_<%= singular_table_name %>)
95
- end
96
-
97
- it "redirects to the <%= singular_table_name %>" do
98
- allow(<%= class_name %>).to receive(:find) { mock_<%= singular_table_name %>(:update_attributes => true) }
99
- put :update, :id => "1"
100
- expect(response).to redirect_to(<%= options[:ns] %>_<%= plural_table_name %>_url)
101
- end
102
- end
103
-
104
- describe "with invalid params" do
105
- it "assigns the <%= singular_table_name %> as @<%= singular_table_name %>" do
106
- allow(<%= class_name %>).to receive(:find) { mock_<%= singular_table_name %>(:update_attributes => false) }
107
- put :update, :id => "1"
108
- expect(assigns(:<%= singular_table_name %>)).to be(mock_<%= singular_table_name %>)
109
- end
110
-
111
- it "re-renders the 'edit' template" do
112
- allow(<%= class_name %>).to receive(:find) { mock_<%= singular_table_name %>(:update_attributes => false) }
113
- put :update, :id => "1"
114
- expect(response).to render_template("edit")
115
- end
116
- end
117
-
118
- end
119
- <% end -%>
120
-
121
- describe "DELETE destroy" do
122
- it "destroys the requested <%= singular_table_name %>" do
123
- expect(<%= class_name %>).to receive(:find).with("37") { mock_<%= singular_table_name %> }
124
- expect(mock_<%= singular_table_name %>).to receive(:destroy)
125
- delete :destroy, :id => "37"
126
- end
127
-
128
- it "redirects to the <%= plural_table_name %> list" do
129
- allow(<%= class_name %>).to receive(:find) { mock_<%= singular_table_name %> }
130
- delete :destroy, :id => "1"
131
- expect(response).to redirect_to(<%= options[:ns] %>_<%= plural_table_name %>_url)
132
- end
133
- end
134
-
135
- end
136
-