model_base_generators 0.2.1 → 0.2.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: 65fb2cefa6cc166f62ba47b20ccf5df5b2bf5687
4
- data.tar.gz: 27276688d944fb3c4c21b8eda9de168780f29882
3
+ metadata.gz: 377e6ba19f399cf524fa5c25a8fa56c983724462
4
+ data.tar.gz: c7a89884e9ab54a5e4edacf078aa25f2ad9a28eb
5
5
  SHA512:
6
- metadata.gz: bf568ccd463e4b74f7ab9eb29e7b0468ae68a222e617e151f8ba6e47ecb5f7866bd72da091b1fc58499a3ba21041d29d16feb7015a08f219aba368965bd03816
7
- data.tar.gz: d29d93ff17c153ef31f642bda1267466e191a49ee5045cf0ba4781f37a04f9472c7e1e6a24b7841ed636b05d1a8b7f10d678f3c85d52bc185b3b7b31100be0b0
6
+ metadata.gz: 7c67f7275d7db7d492b66c2b825909f8bc3933088a4b66caf16f7af5491fd63a33484c19bfae33fbd0c1e1a5151848d2ca52dabf3bb8a25b82bc4da2805d848c
7
+ data.tar.gz: e3fcc7532cc2ea27e36b7c49b2f1ac9fa828b878d634e70e9739f1d2124caa7ed62b11cbec3c9f96bf5d345c8cf23702f0e85782f5f2a48ad3ec137527d1ea4e
@@ -57,6 +57,6 @@ class ProjectsController < ApplicationController
57
57
 
58
58
  # Only allow a trusted parameter "white list" through.
59
59
  def project_params
60
- params.require(:project).permit(:owner_id, :name)
60
+ params.require(:project).permit(:owner_id, :name, :closed)
61
61
  end
62
62
  end
@@ -29,6 +29,13 @@
29
29
  </div>
30
30
  <%=f.error_span(:name) %>
31
31
  </div>
32
+ <div class="form-group">
33
+ <%= f.label :closed, :class => 'control-label col-lg-2' %>
34
+ <div class="col-lg-10">
35
+ <%= f.check_box :closed, :class => 'form-control' %>
36
+ </div>
37
+ <%=f.error_span(:closed) %>
38
+ </div>
32
39
 
33
40
  <div class="form-group">
34
41
  <div class="col-lg-offset-2 col-lg-10">
@@ -4,6 +4,7 @@
4
4
  <tr>
5
5
  <th><%= model_class.human_attribute_name(:owner_id) %></th>
6
6
  <th><%= model_class.human_attribute_name(:name) %></th>
7
+ <th><%= model_class.human_attribute_name(:closed) %></th>
7
8
  <th><%=t '.actions', :default => t("helpers.actions") %></th>
8
9
  </tr>
9
10
  </thead>
@@ -12,6 +13,7 @@
12
13
  <tr>
13
14
  <td><%= project.owner.email %></td>
14
15
  <td><%= link_to project.name, project_path(project) %></td>
16
+ <td><%= project.closed %></td>
15
17
  <td>
16
18
  <%= link_to t('.edit', :default => t("helpers.links.edit")),
17
19
  edit_project_path(project), :class => 'btn btn-default btn-xs' %>
@@ -8,6 +8,8 @@
8
8
  <dd><%= @project.owner.email %></dd>
9
9
  <dt><strong><%= model_class.human_attribute_name(:name) %>:</strong></dt>
10
10
  <dd><%= @project.name %></dd>
11
+ <dt><strong><%= model_class.human_attribute_name(:closed) %>:</strong></dt>
12
+ <dd><%= @project.closed %></dd>
11
13
  </dl>
12
14
 
13
15
  <%= link_to t('.back', :default => t("helpers.links.back")),
data/example/db/schema.rb CHANGED
@@ -19,6 +19,7 @@ ActiveRecord::Schema.define(version: 20161013025452) do
19
19
  create_table :projects do |t|
20
20
  t.references :owner, null: false
21
21
  t.string :name , null: false
22
+ t.boolean :closed, null: false, default: false
22
23
  end
23
24
  add_foreign_key :projects, :users, column: 'owner_id'
24
25
 
@@ -107,9 +107,10 @@ RSpec.describe ProjectsController, type: :controller do
107
107
  describe "PUT #update" do
108
108
  context "with valid params" do
109
109
  let(:new_name){ valid_parameters[:name].succ }
110
+ let(:new_closed){ valid_parameters[:closed].! }
110
111
 
111
112
  let(:new_parameters) {
112
- valid_parameters.merge(name: new_name)
113
+ valid_parameters.merge(name: new_name, closed: new_closed)
113
114
  }
114
115
 
115
116
  it "updates the requested project" do
@@ -117,6 +118,7 @@ RSpec.describe ProjectsController, type: :controller do
117
118
  put :update, params: {:id => project.to_param, :project => new_parameters}, session: valid_session
118
119
  project.reload
119
120
  expect(project.name).to eq new_name
121
+ expect(project.closed).to eq new_closed
120
122
  end
121
123
 
122
124
  it "assigns the requested project as @project" do
@@ -2,5 +2,6 @@ FactoryGirl.define do
2
2
  factory :project do
3
3
  association :owner, factory: :user
4
4
  name "project1"
5
+ closed false
5
6
  end
6
7
  end
@@ -12,6 +12,7 @@ RSpec.describe "projects/edit", type: :view do
12
12
  assert_select "form[action=?][method=?]", project_path(@project), "post" do
13
13
  assert_select "select#project_owner_id[name=?]", "project[owner_id]"
14
14
  assert_select "input#project_name[name=?]", "project[name]"
15
+ assert_select "input#project_closed[name=?]", "project[closed]"
15
16
  end
16
17
  end
17
18
  end
@@ -14,5 +14,6 @@ RSpec.describe "projects/index", type: :view do
14
14
  assert_select "tr>td", :text => 'user1@example.com', :count => 2
15
15
  assert_select "tr>td", :text => 'project1', :count => 1
16
16
  assert_select "tr>td", :text => 'project2', :count => 1
17
+ assert_select "tr>td", :text => 'false', :count => 2
17
18
  end
18
19
  end
@@ -12,6 +12,7 @@ RSpec.describe "projects/new", type: :view do
12
12
  assert_select "form[action=?][method=?]", projects_path, "post" do
13
13
  assert_select "select#project_owner_id[name=?]", "project[owner_id]"
14
14
  assert_select "input#project_name[name=?]", "project[name]"
15
+ assert_select "input#project_closed[name=?]", "project[closed]"
15
16
  end
16
17
  end
17
18
  end
@@ -10,5 +10,6 @@ RSpec.describe "projects/show", type: :view do
10
10
  render
11
11
  expect(rendered).to match(/user1@example.com/)
12
12
  expect(rendered).to match(/project1/)
13
+ expect(rendered).to match(/false/)
13
14
  end
14
15
  end
@@ -98,6 +98,8 @@ module ModelBase
98
98
  def new_attribute_exp
99
99
  if enumerized?
100
100
  '%s.%s.values[%d]' % [model.name, name, 1] # 2nd value
101
+ elsif type == :boolean
102
+ "valid_parameters[:#{name}].!"
101
103
  else
102
104
  "valid_parameters[:#{name}].succ"
103
105
  end
@@ -1,3 +1,3 @@
1
1
  module ModelBase
2
- VERSION = "0.2.1"
2
+ VERSION = "0.2.2"
3
3
  end
@@ -18,7 +18,7 @@ RSpec.describe "<%= ns_table_name %>/index", <%= type_metatag(:view) %> do
18
18
  it "renders a list of <%= ns_table_name %>" do
19
19
  render
20
20
  <% model.columns_for(:spec_index).each do |attribute| -%>
21
- <%- if attribute.ref_model || attribute.enumerized? -%>
21
+ <%- if attribute.ref_model || attribute.enumerized? || attribute.type == :boolean -%>
22
22
  assert_select "tr>td", :text => <%= attribute.sample_string %>, :count => 2
23
23
  <%- else -%>
24
24
  assert_select "tr>td", :text => <%= attribute.sample_string(1) %>, :count => 1
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: model_base_generators
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - akm
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-10-21 00:00:00.000000000 Z
11
+ date: 2016-10-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails