model_base_generators 0.3.1 → 0.3.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/example/app/controllers/issue_comments_controller.rb +62 -0
- data/example/app/helpers/issue_comments_helper.rb +2 -0
- data/example/app/models/issue.rb +2 -0
- data/example/app/models/issue_comment.rb +4 -0
- data/example/app/views/issue_comments/_form.html.erb +55 -0
- data/example/app/views/issue_comments/_issue_comment.json.jbuilder +2 -0
- data/example/app/views/issue_comments/_table.html.erb +33 -0
- data/example/app/views/issue_comments/edit.html.erb +5 -0
- data/example/app/views/issue_comments/index.html.erb +9 -0
- data/example/app/views/issue_comments/index.json.jbuilder +1 -0
- data/example/app/views/issue_comments/new.html.erb +5 -0
- data/example/app/views/issue_comments/show.html.erb +29 -0
- data/example/app/views/issue_comments/show.json.jbuilder +1 -0
- data/example/config/routes.rb +1 -0
- data/example/db/schema.rb +8 -0
- data/example/spec/controllers/issue_comments_controller_spec.rb +166 -0
- data/example/spec/factories/issue_comments.rb +7 -0
- data/example/spec/helpers/issue_comments_helper_spec.rb +14 -0
- data/example/spec/requests/issue_comments_spec.rb +13 -0
- data/example/spec/routing/issue_comments_routing_spec.rb +39 -0
- data/example/spec/views/issue_comments/edit.html.erb_spec.rb +21 -0
- data/example/spec/views/issue_comments/index.html.erb_spec.rb +21 -0
- data/example/spec/views/issue_comments/new.html.erb_spec.rb +21 -0
- data/example/spec/views/issue_comments/show.html.erb_spec.rb +17 -0
- data/example/spec/views/issues/index.html.erb_spec.rb +2 -2
- data/example/spec/views/phases/index.html.erb_spec.rb +2 -2
- data/example/spec/views/projects/index.html.erb_spec.rb +2 -2
- data/lib/model_base/meta_model.rb +12 -10
- data/lib/model_base/version.rb +1 -1
- data/lib/templates/rspec/scaffold/edit_spec.rb +1 -1
- data/lib/templates/rspec/scaffold/index_spec.rb +2 -2
- data/lib/templates/rspec/scaffold/new_spec.rb +1 -1
- data/lib/templates/rspec/scaffold/show_spec.rb +1 -1
- metadata +22 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1d2876dc33a6877e34ccfb4325445d66f32dc717
|
4
|
+
data.tar.gz: 9edbda0d4b2ab0ff2bdce3bd0f5f3e2ef211006d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 759c8c3a53e256d9ab721550a95c2826942c7a266d6e828e66adfce359c331262ad421e98384bbfc6b7fef8717596df6ce19b3f35716cb41b270401dff908a98
|
7
|
+
data.tar.gz: 342acf0c041a9b63200e4a95c94bbef096df3f34a29a7ee1ca4b2457b4383f7985ec4038483ef389ae0658566cf542ad0f62e2b3ec9f4cd4c8b5d745200d37ff
|
@@ -0,0 +1,62 @@
|
|
1
|
+
class IssueCommentsController < ApplicationController
|
2
|
+
include Authentication
|
3
|
+
load_and_authorize_resource except: [:index]
|
4
|
+
|
5
|
+
before_action :set_issue_comment, only: [:show, :edit, :update, :destroy]
|
6
|
+
|
7
|
+
# GET /issue_comments
|
8
|
+
def index
|
9
|
+
@issue_comments = IssueComment.all
|
10
|
+
end
|
11
|
+
|
12
|
+
# GET /issue_comments/1
|
13
|
+
def show
|
14
|
+
end
|
15
|
+
|
16
|
+
# GET /issue_comments/new
|
17
|
+
def new
|
18
|
+
@issue_comment = IssueComment.new
|
19
|
+
end
|
20
|
+
|
21
|
+
# GET /issue_comments/1/edit
|
22
|
+
def edit
|
23
|
+
end
|
24
|
+
|
25
|
+
# POST /issue_comments
|
26
|
+
def create
|
27
|
+
@issue_comment = IssueComment.new(issue_comment_params)
|
28
|
+
|
29
|
+
if @issue_comment.save
|
30
|
+
redirect_to @issue_comment, notice: 'Issue comment was successfully created.'
|
31
|
+
else
|
32
|
+
render :new
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
# PATCH/PUT /issue_comments/1
|
37
|
+
def update
|
38
|
+
if @issue_comment.update(issue_comment_params)
|
39
|
+
redirect_to @issue_comment, notice: 'Issue comment was successfully updated.'
|
40
|
+
else
|
41
|
+
render :edit
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
# DELETE /issue_comments/1
|
46
|
+
def destroy
|
47
|
+
@issue_comment.destroy
|
48
|
+
redirect_to issue_comments_url, notice: 'Issue comment was successfully destroyed.'
|
49
|
+
end
|
50
|
+
|
51
|
+
private
|
52
|
+
|
53
|
+
# Use callbacks to share common setup or constraints between actions.
|
54
|
+
def set_issue_comment
|
55
|
+
@issue_comment = IssueComment.find(params[:id])
|
56
|
+
end
|
57
|
+
|
58
|
+
# Only allow a trusted parameter "white list" through.
|
59
|
+
def issue_comment_params
|
60
|
+
params.require(:issue_comment).permit(:issue_id, :user_id, :description)
|
61
|
+
end
|
62
|
+
end
|
data/example/app/models/issue.rb
CHANGED
@@ -0,0 +1,55 @@
|
|
1
|
+
<%= form_for issue_comment, :html => { :class => "form-horizontal issue_comment" } do |f| %>
|
2
|
+
|
3
|
+
<% if issue_comment.errors.any? %>
|
4
|
+
<div id="error_expl" class="panel panel-danger">
|
5
|
+
<div class="panel-heading">
|
6
|
+
<h3 class="panel-title"><%= pluralize(issue_comment.errors.count, "error") %> prohibited this issue_comment from being saved:</h3>
|
7
|
+
</div>
|
8
|
+
<div class="panel-body">
|
9
|
+
<ul>
|
10
|
+
<% issue_comment.errors.full_messages.each do |msg| %>
|
11
|
+
<li><%= msg %></li>
|
12
|
+
<% end %>
|
13
|
+
</ul>
|
14
|
+
</div>
|
15
|
+
</div>
|
16
|
+
<% end %>
|
17
|
+
|
18
|
+
<div class="form-group">
|
19
|
+
<%= f.label :id, :class => 'control-label col-lg-2' %>
|
20
|
+
<div class="col-lg-10">
|
21
|
+
<%= f.number_field :id, :class => 'form-control' %>
|
22
|
+
</div>
|
23
|
+
<%=f.error_span(:id) %>
|
24
|
+
</div>
|
25
|
+
<div class="form-group">
|
26
|
+
<%= f.label :issue_id, :class => 'control-label col-lg-2' %>
|
27
|
+
<div class="col-lg-10">
|
28
|
+
<%= f.collection_select :issue_id, Issue.all, :id, :title, {}, :class=>"form-control" %>
|
29
|
+
</div>
|
30
|
+
<%=f.error_span(:issue_id) %>
|
31
|
+
</div>
|
32
|
+
<div class="form-group">
|
33
|
+
<%= f.label :user_id, :class => 'control-label col-lg-2' %>
|
34
|
+
<div class="col-lg-10">
|
35
|
+
<%= f.collection_select :user_id, User.all, :id, :email, {}, :class=>"form-control" %>
|
36
|
+
</div>
|
37
|
+
<%=f.error_span(:user_id) %>
|
38
|
+
</div>
|
39
|
+
<div class="form-group">
|
40
|
+
<%= f.label :description, :class => 'control-label col-lg-2' %>
|
41
|
+
<div class="col-lg-10">
|
42
|
+
<%= f.text_area :description, :class => 'form-control' %>
|
43
|
+
</div>
|
44
|
+
<%=f.error_span(:description) %>
|
45
|
+
</div>
|
46
|
+
|
47
|
+
<div class="form-group">
|
48
|
+
<div class="col-lg-offset-2 col-lg-10">
|
49
|
+
<%= f.submit nil, :class => 'btn btn-primary' %>
|
50
|
+
<%= link_to t('.cancel', :default => t("helpers.links.cancel")),
|
51
|
+
issue_comments_path, :class => 'btn btn-default' %>
|
52
|
+
</div>
|
53
|
+
</div>
|
54
|
+
|
55
|
+
<% end %>
|
@@ -0,0 +1,33 @@
|
|
1
|
+
<%- model_class = IssueComment -%>
|
2
|
+
<table class="table table-striped">
|
3
|
+
<thead>
|
4
|
+
<tr>
|
5
|
+
<th><%= model_class.human_attribute_name(:id) %></th>
|
6
|
+
<th><%= model_class.human_attribute_name(:issue_id) %></th>
|
7
|
+
<th><%= model_class.human_attribute_name(:user_id) %></th>
|
8
|
+
<th><%= model_class.human_attribute_name(:description) %></th>
|
9
|
+
<th><%= model_class.human_attribute_name(:created_at) %></th>
|
10
|
+
<th><%=t '.actions', :default => t("helpers.actions") %></th>
|
11
|
+
</tr>
|
12
|
+
</thead>
|
13
|
+
<tbody>
|
14
|
+
<% @issue_comments.each do |issue_comment| %>
|
15
|
+
<tr>
|
16
|
+
<td><%= issue_comment.id %></td>
|
17
|
+
<td><%= issue_comment.issue.title %></td>
|
18
|
+
<td><%= issue_comment.user.email %></td>
|
19
|
+
<td><%= issue_comment.description %></td>
|
20
|
+
<td><%=l issue_comment.created_at %></td>
|
21
|
+
<td>
|
22
|
+
<%= link_to t('.edit', :default => t("helpers.links.edit")),
|
23
|
+
edit_issue_comment_path(issue_comment), :class => 'btn btn-default btn-xs' %>
|
24
|
+
<%= link_to t('.destroy', :default => t("helpers.links.destroy")),
|
25
|
+
issue_comment_path(issue_comment),
|
26
|
+
:method => :delete,
|
27
|
+
:data => { :confirm => t('.confirm', :default => t("helpers.links.confirm", :default => 'Are you sure?')) },
|
28
|
+
:class => 'btn btn-xs btn-danger' %>
|
29
|
+
</td>
|
30
|
+
</tr>
|
31
|
+
<% end %>
|
32
|
+
</tbody>
|
33
|
+
</table>
|
@@ -0,0 +1,5 @@
|
|
1
|
+
<%- model_class = IssueComment -%>
|
2
|
+
<div class="page-header">
|
3
|
+
<h1><%=t '.title', :default => [:'helpers.titles.edit', 'Edit %{model}'], :model => model_class.model_name.human.titleize %></h1>
|
4
|
+
</div>
|
5
|
+
<%= render 'issue_comments/form', issue_comment: @issue_comment %>
|
@@ -0,0 +1,9 @@
|
|
1
|
+
<%- model_class = IssueComment -%>
|
2
|
+
<div class="page-header">
|
3
|
+
<h1><%=t '.title', :default => model_class.model_name.human.pluralize.titleize %></h1>
|
4
|
+
</div>
|
5
|
+
<%= render 'issue_comments/table' %>
|
6
|
+
|
7
|
+
<%= link_to t('.new', :default => t("helpers.links.new")),
|
8
|
+
new_issue_comment_path,
|
9
|
+
:class => 'btn btn-primary' %>
|
@@ -0,0 +1 @@
|
|
1
|
+
json.array! @issue_comments, partial: 'issue_comments/issue_comment', as: :issue_comment
|
@@ -0,0 +1,29 @@
|
|
1
|
+
<%- model_class = IssueComment -%>
|
2
|
+
<div class="page-header">
|
3
|
+
<h1><%=t '.title', :default => model_class.model_name.human.titleize %></h1>
|
4
|
+
</div>
|
5
|
+
|
6
|
+
<dl class="dl-horizontal">
|
7
|
+
<dt><strong><%= model_class.human_attribute_name(:id) %>:</strong></dt>
|
8
|
+
<dd><%= @issue_comment.id %></dd>
|
9
|
+
<dt><strong><%= model_class.human_attribute_name(:issue_id) %>:</strong></dt>
|
10
|
+
<dd><%= @issue_comment.issue.title %></dd>
|
11
|
+
<dt><strong><%= model_class.human_attribute_name(:user_id) %>:</strong></dt>
|
12
|
+
<dd><%= @issue_comment.user.email %></dd>
|
13
|
+
<dt><strong><%= model_class.human_attribute_name(:description) %>:</strong></dt>
|
14
|
+
<dd><%= @issue_comment.description %></dd>
|
15
|
+
<dt><strong><%= model_class.human_attribute_name(:created_at) %>:</strong></dt>
|
16
|
+
<dd><%=l @issue_comment.created_at %></dd>
|
17
|
+
<dt><strong><%= model_class.human_attribute_name(:updated_at) %>:</strong></dt>
|
18
|
+
<dd><%=l @issue_comment.updated_at %></dd>
|
19
|
+
</dl>
|
20
|
+
|
21
|
+
<%= link_to t('.back', :default => t("helpers.links.back")),
|
22
|
+
issue_comments_path, :class => 'btn btn-default' %>
|
23
|
+
<%= link_to t('.edit', :default => t("helpers.links.edit")),
|
24
|
+
edit_issue_comment_path(@issue_comment), :class => 'btn btn-default' %>
|
25
|
+
<%= link_to t('.destroy', :default => t("helpers.links.destroy")),
|
26
|
+
issue_comment_path(@issue_comment),
|
27
|
+
:method => 'delete',
|
28
|
+
:data => { :confirm => t('.confirm', :default => t("helpers.links.confirm", :default => 'Are you sure?')) },
|
29
|
+
:class => 'btn btn-danger' %>
|
@@ -0,0 +1 @@
|
|
1
|
+
json.partial! "issue_comments/issue_comment", issue_comment: @issue_comment
|
data/example/config/routes.rb
CHANGED
data/example/db/schema.rb
CHANGED
@@ -49,4 +49,12 @@ ActiveRecord::Schema.define(version: 20161013025452) do
|
|
49
49
|
end
|
50
50
|
add_foreign_key :issues, :users, column: 'creator_id'
|
51
51
|
add_foreign_key :issues, :users, column: 'assignee_id'
|
52
|
+
|
53
|
+
create_table :issue_comments do |t|
|
54
|
+
t.references :issue, null: false, foreign_key: true
|
55
|
+
t.references :user, null: false, foreign_key: true
|
56
|
+
t.text :description
|
57
|
+
t.datetime :created_at, null: false
|
58
|
+
t.datetime :updated_at, null: false
|
59
|
+
end
|
52
60
|
end
|
@@ -0,0 +1,166 @@
|
|
1
|
+
require 'rails_helper'
|
2
|
+
|
3
|
+
# This spec was generated by rspec-rails when you ran the scaffold generator.
|
4
|
+
# It demonstrates how one might use RSpec to specify the controller code that
|
5
|
+
# was generated by Rails when you ran the scaffold generator.
|
6
|
+
#
|
7
|
+
# It assumes that the implementation code is generated by the rails scaffold
|
8
|
+
# generator. If you are using any extension libraries to generate different
|
9
|
+
# controller code, this generated spec may or may not pass.
|
10
|
+
#
|
11
|
+
# It only uses APIs available in rails and/or rspec-rails. There are a number
|
12
|
+
# of tools you can use to make these specs even more expressive, but we're
|
13
|
+
# sticking to rails and rspec-rails APIs to keep things simple and stable.
|
14
|
+
#
|
15
|
+
# Compared to earlier versions of this generator, there is very limited use of
|
16
|
+
# stubs and message expectations in this spec. Stubs are only used when there
|
17
|
+
# is no simpler way to get a handle on the object needed for the example.
|
18
|
+
# Message expectations are only used when there is no simpler way to specify
|
19
|
+
# that an instance is receiving a specific message.
|
20
|
+
|
21
|
+
RSpec.describe IssueCommentsController, type: :controller do
|
22
|
+
|
23
|
+
let(:user){ FactoryGirl.create(:user) }
|
24
|
+
let(:project){ FactoryGirl.create(:project, owner: user) }
|
25
|
+
let(:issue){ FactoryGirl.create(:issue, project: project, creator: user) }
|
26
|
+
before{ devise_user_login(user) }
|
27
|
+
|
28
|
+
let(:issue_comment){ FactoryGirl.create(:issue_comment, issue: issue, user: user) }
|
29
|
+
|
30
|
+
# This should return the minimal set of attributes required to create a valid
|
31
|
+
# IssueComment. As you add validations to IssueComment, be sure to
|
32
|
+
# adjust the attributes here as well.
|
33
|
+
let(:valid_parameters) {
|
34
|
+
FactoryGirl.attributes_for(:issue_comment).merge(issue_id: issue.id, user_id: user.id)
|
35
|
+
}
|
36
|
+
|
37
|
+
let(:invalid_parameters) {
|
38
|
+
skip("Add a hash of attributes invalid for your model")
|
39
|
+
}
|
40
|
+
|
41
|
+
# This should return the minimal set of values that should be in the session
|
42
|
+
# in order to pass any filters (e.g. authentication) defined in
|
43
|
+
# IssueCommentsController. Be sure to keep this updated too.
|
44
|
+
let(:valid_session) { {} }
|
45
|
+
|
46
|
+
describe "GET #index" do
|
47
|
+
it "assigns all issue_comments as @issue_comments" do
|
48
|
+
get :index, params: {}, session: valid_session
|
49
|
+
expect(assigns(:issue_comments)).to eq([issue_comment])
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
describe "GET #show" do
|
54
|
+
it "assigns the requested issue_comment as @issue_comment" do
|
55
|
+
issue_comment # To create issue_comment
|
56
|
+
get :show, params: {:id => issue_comment.to_param}, session: valid_session
|
57
|
+
expect(assigns(:issue_comment)).to eq(issue_comment)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
describe "GET #new" do
|
62
|
+
it "assigns a new issue_comment as @issue_comment" do
|
63
|
+
get :new, params: {}, session: valid_session
|
64
|
+
expect(assigns(:issue_comment)).to be_a_new(IssueComment)
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
describe "GET #edit" do
|
69
|
+
it "assigns the requested issue_comment as @issue_comment" do
|
70
|
+
issue_comment # To create issue_comment
|
71
|
+
get :edit, params: {:id => issue_comment.to_param}, session: valid_session
|
72
|
+
expect(assigns(:issue_comment)).to eq(issue_comment)
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
describe "POST #create" do
|
77
|
+
context "with valid params" do
|
78
|
+
it "creates a new IssueComment" do
|
79
|
+
expect {
|
80
|
+
post :create, params: {:issue_comment => valid_parameters}, session: valid_session
|
81
|
+
}.to change(IssueComment, :count).by(1)
|
82
|
+
end
|
83
|
+
|
84
|
+
it "assigns a newly created issue_comment as @issue_comment" do
|
85
|
+
post :create, params: {:issue_comment => valid_parameters}, session: valid_session
|
86
|
+
expect(assigns(:issue_comment)).to be_a(IssueComment)
|
87
|
+
expect(assigns(:issue_comment)).to be_persisted
|
88
|
+
end
|
89
|
+
|
90
|
+
it "redirects to the created issue_comment" do
|
91
|
+
post :create, params: {:issue_comment => valid_parameters}, session: valid_session
|
92
|
+
expect(response).to redirect_to(IssueComment.last)
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
context "with invalid params" do
|
97
|
+
it "assigns a newly created but unsaved issue_comment as @issue_comment" do
|
98
|
+
post :create, params: {:issue_comment => invalid_parameters}, session: valid_session
|
99
|
+
expect(assigns(:issue_comment)).to be_a_new(IssueComment)
|
100
|
+
end
|
101
|
+
|
102
|
+
it "re-renders the 'new' template" do
|
103
|
+
post :create, params: {:issue_comment => invalid_parameters}, session: valid_session
|
104
|
+
expect(response).to render_template("new")
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
describe "PUT #update" do
|
110
|
+
context "with valid params" do
|
111
|
+
|
112
|
+
let(:new_parameters) {
|
113
|
+
skip("Add a hash of attributes valid for your model")
|
114
|
+
}
|
115
|
+
|
116
|
+
it "updates the requested issue_comment" do
|
117
|
+
issue_comment # To create issue_comment
|
118
|
+
put :update, params: {:id => issue_comment.to_param, :issue_comment => new_parameters}, session: valid_session
|
119
|
+
issue_comment.reload
|
120
|
+
skip("Add assertions for updated state")
|
121
|
+
end
|
122
|
+
|
123
|
+
it "assigns the requested issue_comment as @issue_comment" do
|
124
|
+
issue_comment # To create issue_comment
|
125
|
+
put :update, params: {:id => issue_comment.to_param, :issue_comment => new_parameters}, session: valid_session
|
126
|
+
expect(assigns(:issue_comment)).to eq(issue_comment)
|
127
|
+
end
|
128
|
+
|
129
|
+
it "redirects to the issue_comment" do
|
130
|
+
issue_comment # To create issue_comment
|
131
|
+
put :update, params: {:id => issue_comment.to_param, :issue_comment => new_parameters}, session: valid_session
|
132
|
+
expect(response).to redirect_to(issue_comment)
|
133
|
+
end
|
134
|
+
end
|
135
|
+
|
136
|
+
context "with invalid params" do
|
137
|
+
it "assigns the issue_comment as @issue_comment" do
|
138
|
+
issue_comment # To create issue_comment
|
139
|
+
put :update, params: {:id => issue_comment.to_param, :issue_comment => invalid_parameters}, session: valid_session
|
140
|
+
expect(assigns(:issue_comment)).to eq(issue_comment)
|
141
|
+
end
|
142
|
+
|
143
|
+
it "re-renders the 'edit' template" do
|
144
|
+
issue_comment # To create issue_comment
|
145
|
+
put :update, params: {:id => issue_comment.to_param, :issue_comment => invalid_parameters}, session: valid_session
|
146
|
+
expect(response).to render_template("edit")
|
147
|
+
end
|
148
|
+
end
|
149
|
+
end
|
150
|
+
|
151
|
+
describe "DELETE #destroy" do
|
152
|
+
it "destroys the requested issue_comment" do
|
153
|
+
issue_comment # To create issue_comment
|
154
|
+
expect {
|
155
|
+
delete :destroy, params: {:id => issue_comment.to_param}, session: valid_session
|
156
|
+
}.to change(IssueComment, :count).by(-1)
|
157
|
+
end
|
158
|
+
|
159
|
+
it "redirects to the issue_comments list" do
|
160
|
+
issue_comment # To create issue_comment
|
161
|
+
delete :destroy, params: {:id => issue_comment.to_param}, session: valid_session
|
162
|
+
expect(response).to redirect_to(issue_comments_url)
|
163
|
+
end
|
164
|
+
end
|
165
|
+
|
166
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'rails_helper'
|
2
|
+
|
3
|
+
# Specs in this file have access to a helper object that includes
|
4
|
+
# the IssueCommentsHelper. For example:
|
5
|
+
#
|
6
|
+
# describe IssueCommentsHelper do
|
7
|
+
# describe "string concat" do
|
8
|
+
# it "concats two strings with spaces" do
|
9
|
+
# expect(helper.concat_strings("this","that")).to eq("this that")
|
10
|
+
# end
|
11
|
+
# end
|
12
|
+
# end
|
13
|
+
RSpec.describe IssueCommentsHelper, type: :helper do
|
14
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'rails_helper'
|
2
|
+
|
3
|
+
RSpec.describe "IssueComments", type: :request do
|
4
|
+
let(:user) { FactoryGirl.create(:user) }
|
5
|
+
before{ login_as(user, :scope => :user) }
|
6
|
+
|
7
|
+
describe "GET /issue_comments" do
|
8
|
+
it "works! (now write some real specs)" do
|
9
|
+
get issue_comments_path
|
10
|
+
expect(response).to have_http_status(200)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require "rails_helper"
|
2
|
+
|
3
|
+
RSpec.describe IssueCommentsController, type: :routing do
|
4
|
+
describe "routing" do
|
5
|
+
|
6
|
+
it "routes to #index" do
|
7
|
+
expect(:get => "/issue_comments").to route_to("issue_comments#index")
|
8
|
+
end
|
9
|
+
|
10
|
+
it "routes to #new" do
|
11
|
+
expect(:get => "/issue_comments/new").to route_to("issue_comments#new")
|
12
|
+
end
|
13
|
+
|
14
|
+
it "routes to #show" do
|
15
|
+
expect(:get => "/issue_comments/1").to route_to("issue_comments#show", :id => "1")
|
16
|
+
end
|
17
|
+
|
18
|
+
it "routes to #edit" do
|
19
|
+
expect(:get => "/issue_comments/1/edit").to route_to("issue_comments#edit", :id => "1")
|
20
|
+
end
|
21
|
+
|
22
|
+
it "routes to #create" do
|
23
|
+
expect(:post => "/issue_comments").to route_to("issue_comments#create")
|
24
|
+
end
|
25
|
+
|
26
|
+
it "routes to #update via PUT" do
|
27
|
+
expect(:put => "/issue_comments/1").to route_to("issue_comments#update", :id => "1")
|
28
|
+
end
|
29
|
+
|
30
|
+
it "routes to #update via PATCH" do
|
31
|
+
expect(:patch => "/issue_comments/1").to route_to("issue_comments#update", :id => "1")
|
32
|
+
end
|
33
|
+
|
34
|
+
it "routes to #destroy" do
|
35
|
+
expect(:delete => "/issue_comments/1").to route_to("issue_comments#destroy", :id => "1")
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'rails_helper'
|
2
|
+
|
3
|
+
RSpec.describe "issue_comments/edit", type: :view do
|
4
|
+
let(:user){ FactoryGirl.create(:user) }
|
5
|
+
let(:project){ FactoryGirl.create(:project, owner: user) }
|
6
|
+
let(:issue){ FactoryGirl.create(:issue, project: project, creator: user) }
|
7
|
+
before(:each) do
|
8
|
+
@issue_comment = assign(:issue_comment, FactoryGirl.create(:issue_comment, issue: issue, user: user))
|
9
|
+
end
|
10
|
+
|
11
|
+
it "renders the edit issue_comment form" do
|
12
|
+
render
|
13
|
+
|
14
|
+
assert_select "form[action=?][method=?]", issue_comment_path(@issue_comment), "post" do
|
15
|
+
assert_select "input#issue_comment_id[name=?]", "issue_comment[id]"
|
16
|
+
assert_select "select#issue_comment_issue_id[name=?]", "issue_comment[issue_id]"
|
17
|
+
assert_select "select#issue_comment_user_id[name=?]", "issue_comment[user_id]"
|
18
|
+
assert_select "textarea#issue_comment_description[name=?]", "issue_comment[description]"
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'rails_helper'
|
2
|
+
|
3
|
+
RSpec.describe "issue_comments/index", type: :view do
|
4
|
+
let(:user){ FactoryGirl.create(:user) }
|
5
|
+
let(:project){ FactoryGirl.create(:project, owner: user) }
|
6
|
+
let(:issue){ FactoryGirl.create(:issue, project: project, creator: user) }
|
7
|
+
before(:each) do
|
8
|
+
assign(:issue_comments, [
|
9
|
+
FactoryGirl.create(:issue_comment, issue: issue, user: user, description: 'issue_comment_description_1'),
|
10
|
+
FactoryGirl.create(:issue_comment, issue: issue, user: user, description: 'issue_comment_description_2'),
|
11
|
+
])
|
12
|
+
end
|
13
|
+
|
14
|
+
it "renders a list of issue_comments" do
|
15
|
+
render
|
16
|
+
assert_select "tr>td", :text => 'issue1', :count => 2
|
17
|
+
assert_select "tr>td", :text => 'user1@example.com', :count => 2
|
18
|
+
assert_select "tr>td", :text => 'issue_comment_description_1', :count => 1
|
19
|
+
assert_select "tr>td", :text => 'issue_comment_description_2', :count => 1
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'rails_helper'
|
2
|
+
|
3
|
+
RSpec.describe "issue_comments/new", type: :view do
|
4
|
+
let(:user){ FactoryGirl.create(:user) }
|
5
|
+
let(:project){ FactoryGirl.create(:project, owner: user) }
|
6
|
+
let(:issue){ FactoryGirl.create(:issue, project: project, creator: user) }
|
7
|
+
before(:each) do
|
8
|
+
assign(:issue_comment, FactoryGirl.build(:issue_comment, issue: issue, user: user))
|
9
|
+
end
|
10
|
+
|
11
|
+
it "renders new issue_comment form" do
|
12
|
+
render
|
13
|
+
|
14
|
+
assert_select "form[action=?][method=?]", issue_comments_path, "post" do
|
15
|
+
assert_select "input#issue_comment_id[name=?]", "issue_comment[id]"
|
16
|
+
assert_select "select#issue_comment_issue_id[name=?]", "issue_comment[issue_id]"
|
17
|
+
assert_select "select#issue_comment_user_id[name=?]", "issue_comment[user_id]"
|
18
|
+
assert_select "textarea#issue_comment_description[name=?]", "issue_comment[description]"
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'rails_helper'
|
2
|
+
|
3
|
+
RSpec.describe "issue_comments/show", type: :view do
|
4
|
+
let(:user){ FactoryGirl.create(:user) }
|
5
|
+
let(:project){ FactoryGirl.create(:project, owner: user) }
|
6
|
+
let(:issue){ FactoryGirl.create(:issue, project: project, creator: user) }
|
7
|
+
before(:each) do
|
8
|
+
@issue_comment = assign(:issue_comment, FactoryGirl.create(:issue_comment, issue: issue, user: user))
|
9
|
+
end
|
10
|
+
|
11
|
+
it "renders attributes in <p>" do
|
12
|
+
render
|
13
|
+
expect(rendered).to match(/issue1/)
|
14
|
+
expect(rendered).to match(/user1@example.com/)
|
15
|
+
expect(rendered).to match(/issue_comment_description_1/)
|
16
|
+
end
|
17
|
+
end
|
@@ -5,8 +5,8 @@ RSpec.describe "issues/index", type: :view do
|
|
5
5
|
let(:project){ FactoryGirl.create(:project, owner: user) }
|
6
6
|
before(:each) do
|
7
7
|
assign(:issues, [
|
8
|
-
FactoryGirl.create(:issue,
|
9
|
-
FactoryGirl.create(:issue,
|
8
|
+
FactoryGirl.create(:issue, project: project, creator: user, title: 'issue1'),
|
9
|
+
FactoryGirl.create(:issue, project: project, creator: user, title: 'issue2'),
|
10
10
|
])
|
11
11
|
end
|
12
12
|
|
@@ -5,8 +5,8 @@ RSpec.describe "phases/index", type: :view do
|
|
5
5
|
let(:project){ FactoryGirl.create(:project, owner: user) }
|
6
6
|
before(:each) do
|
7
7
|
assign(:phases, [
|
8
|
-
FactoryGirl.create(:phase, name: 'phase1'
|
9
|
-
FactoryGirl.create(:phase, name: 'phase2'
|
8
|
+
FactoryGirl.create(:phase, project: project, name: 'phase1'),
|
9
|
+
FactoryGirl.create(:phase, project: project, name: 'phase2'),
|
10
10
|
])
|
11
11
|
end
|
12
12
|
|
@@ -4,8 +4,8 @@ RSpec.describe "projects/index", type: :view do
|
|
4
4
|
let(:user){ FactoryGirl.create(:user) }
|
5
5
|
before(:each) do
|
6
6
|
assign(:projects, [
|
7
|
-
FactoryGirl.create(:project, name: 'project1'
|
8
|
-
FactoryGirl.create(:project, name: 'project2'
|
7
|
+
FactoryGirl.create(:project, owner: user, name: 'project1'),
|
8
|
+
FactoryGirl.create(:project, owner: user, name: 'project2'),
|
9
9
|
])
|
10
10
|
end
|
11
11
|
|
@@ -115,23 +115,25 @@ module ModelBase
|
|
115
115
|
dependencies.map{|attr, model| "#{attr}: #{model.full_resource_name}" }
|
116
116
|
end
|
117
117
|
|
118
|
-
def factory_girl_create(extra = {})
|
119
|
-
factory_girl_method(:create, extra)
|
120
|
-
end
|
121
|
-
|
122
|
-
def factory_girl_build(extra = {})
|
123
|
-
factory_girl_method(:build, extra)
|
124
|
-
end
|
125
|
-
|
126
118
|
def factory_girl_method(name, extra)
|
127
119
|
extra_str = extra.blank? ? '' : ', ' << extra.map{|k,v| "#{k}: '#{v}'"}.join(', ')
|
128
120
|
options = factory_girl_options
|
129
121
|
options_str = options.empty? ? '' : ', ' << factory_girl_options.join(', ')
|
130
|
-
'FactoryGirl.%s(:%s%s%s)' % [name, full_resource_name,
|
122
|
+
'FactoryGirl.%s(:%s%s%s)' % [name, full_resource_name, options_str, extra_str]
|
123
|
+
end
|
124
|
+
|
125
|
+
def factory_girl_to(name, context: nil, index: 1, extra: {})
|
126
|
+
case context
|
127
|
+
when :spec_index
|
128
|
+
columns_for(:spec_index).delete_if(&:single_sample_only?).delete_if(&:reference).each do |col|
|
129
|
+
extra[col.name] = col.sample_value(index)
|
130
|
+
end
|
131
|
+
end
|
132
|
+
factory_girl_method(name, extra)
|
131
133
|
end
|
132
134
|
|
133
135
|
def factory_girl_let_definition
|
134
|
-
'let(:%s){ %s }' % [full_resource_name,
|
136
|
+
'let(:%s){ %s }' % [full_resource_name, factory_girl_to(:create)]
|
135
137
|
end
|
136
138
|
|
137
139
|
def factory_girl_let_definitions(spacer = " ")
|
data/lib/model_base/version.rb
CHANGED
@@ -3,7 +3,7 @@ require 'rails_helper'
|
|
3
3
|
RSpec.describe "<%= ns_table_name %>/edit", <%= type_metatag(:view) %> do
|
4
4
|
<%= model.factory_girl_let_definitions %>
|
5
5
|
before(:each) do
|
6
|
-
@<%= ns_file_name %> = assign(:<%= ns_file_name %>, <%= model.
|
6
|
+
@<%= ns_file_name %> = assign(:<%= ns_file_name %>, <%= model.factory_girl_to :create %>)
|
7
7
|
end
|
8
8
|
|
9
9
|
it "renders the edit <%= ns_file_name %> form" do
|
@@ -7,9 +7,9 @@ RSpec.describe "<%= ns_table_name %>/index", <%= type_metatag(:view) %> do
|
|
7
7
|
assign(:<%= table_name %>, [
|
8
8
|
<% [1,2].each_with_index do |id, model_index| -%>
|
9
9
|
<%- if tc = model.title_column -%>
|
10
|
-
<%= model.
|
10
|
+
<%= model.factory_girl_to(:create, extra: {tc.name.to_sym => tc.sample_value(model_index + 1)}) %>,
|
11
11
|
<%- else -%>
|
12
|
-
<%= model.
|
12
|
+
<%= model.factory_girl_to(:create, context: :spec_index, index: id, ) %>,
|
13
13
|
<%- end -%>
|
14
14
|
<% end -%>
|
15
15
|
])
|
@@ -4,7 +4,7 @@ require 'rails_helper'
|
|
4
4
|
RSpec.describe "<%= ns_table_name %>/new", <%= type_metatag(:view) %> do
|
5
5
|
<%= model.factory_girl_let_definitions %>
|
6
6
|
before(:each) do
|
7
|
-
assign(:<%= ns_file_name %>, <%= model.
|
7
|
+
assign(:<%= ns_file_name %>, <%= model.factory_girl_to :build %>)
|
8
8
|
end
|
9
9
|
|
10
10
|
it "renders new <%= ns_file_name %> form" do
|
@@ -3,7 +3,7 @@ require 'rails_helper'
|
|
3
3
|
RSpec.describe "<%= ns_table_name %>/show", <%= type_metatag(:view) %> do
|
4
4
|
<%= model.factory_girl_let_definitions %>
|
5
5
|
before(:each) do
|
6
|
-
@<%= ns_file_name %> = assign(:<%= ns_file_name %>, <%= model.
|
6
|
+
@<%= ns_file_name %> = assign(:<%= ns_file_name %>, <%= model.factory_girl_to :create %>)
|
7
7
|
end
|
8
8
|
|
9
9
|
it "renders attributes in <p>" do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: model_base_generators
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- akm
|
@@ -141,11 +141,13 @@ files:
|
|
141
141
|
- example/app/controllers/application_controller.rb
|
142
142
|
- example/app/controllers/concerns/.keep
|
143
143
|
- example/app/controllers/concerns/authentication.rb
|
144
|
+
- example/app/controllers/issue_comments_controller.rb
|
144
145
|
- example/app/controllers/issues_controller.rb
|
145
146
|
- example/app/controllers/phases_controller.rb
|
146
147
|
- example/app/controllers/project_assignments_controller.rb
|
147
148
|
- example/app/controllers/projects_controller.rb
|
148
149
|
- example/app/helpers/application_helper.rb
|
150
|
+
- example/app/helpers/issue_comments_helper.rb
|
149
151
|
- example/app/helpers/issues_helper.rb
|
150
152
|
- example/app/helpers/phases_helper.rb
|
151
153
|
- example/app/helpers/projects_helper.rb
|
@@ -155,6 +157,7 @@ files:
|
|
155
157
|
- example/app/models/application_record.rb
|
156
158
|
- example/app/models/concerns/.keep
|
157
159
|
- example/app/models/issue.rb
|
160
|
+
- example/app/models/issue_comment.rb
|
158
161
|
- example/app/models/phase.rb
|
159
162
|
- example/app/models/project.rb
|
160
163
|
- example/app/models/project_assignment.rb
|
@@ -165,6 +168,15 @@ files:
|
|
165
168
|
- example/app/validations/project_assignment_validation.rb
|
166
169
|
- example/app/validations/project_validation.rb
|
167
170
|
- example/app/validations/user_validation.rb
|
171
|
+
- example/app/views/issue_comments/_form.html.erb
|
172
|
+
- example/app/views/issue_comments/_issue_comment.json.jbuilder
|
173
|
+
- example/app/views/issue_comments/_table.html.erb
|
174
|
+
- example/app/views/issue_comments/edit.html.erb
|
175
|
+
- example/app/views/issue_comments/index.html.erb
|
176
|
+
- example/app/views/issue_comments/index.json.jbuilder
|
177
|
+
- example/app/views/issue_comments/new.html.erb
|
178
|
+
- example/app/views/issue_comments/show.html.erb
|
179
|
+
- example/app/views/issue_comments/show.json.jbuilder
|
168
180
|
- example/app/views/issues/_form.html.erb
|
169
181
|
- example/app/views/issues/_table.html.erb
|
170
182
|
- example/app/views/issues/edit.html.erb
|
@@ -235,16 +247,21 @@ files:
|
|
235
247
|
- example/public/apple-touch-icon-precomposed.png
|
236
248
|
- example/public/apple-touch-icon.png
|
237
249
|
- example/public/favicon.ico
|
250
|
+
- example/spec/controllers/issue_comments_controller_spec.rb
|
238
251
|
- example/spec/controllers/issues_controller_spec.rb
|
239
252
|
- example/spec/controllers/phases_controller_spec.rb
|
240
253
|
- example/spec/controllers/project_assignments_controller_spec.rb
|
241
254
|
- example/spec/controllers/projects_controller_spec.rb
|
255
|
+
- example/spec/factories/issue_comments.rb
|
242
256
|
- example/spec/factories/issues.rb
|
243
257
|
- example/spec/factories/phases.rb
|
244
258
|
- example/spec/factories/project_assignments.rb
|
245
259
|
- example/spec/factories/projects.rb
|
246
260
|
- example/spec/factories/users.rb
|
261
|
+
- example/spec/helpers/issue_comments_helper_spec.rb
|
247
262
|
- example/spec/rails_helper.rb
|
263
|
+
- example/spec/requests/issue_comments_spec.rb
|
264
|
+
- example/spec/routing/issue_comments_routing_spec.rb
|
248
265
|
- example/spec/routing/issues_routing_spec.rb
|
249
266
|
- example/spec/routing/phases_routing_spec.rb
|
250
267
|
- example/spec/routing/project_assignments_routing_spec.rb
|
@@ -253,6 +270,10 @@ files:
|
|
253
270
|
- example/spec/support/controller_macros.rb
|
254
271
|
- example/spec/support/devise.rb
|
255
272
|
- example/spec/support/field_assertions.rb
|
273
|
+
- example/spec/views/issue_comments/edit.html.erb_spec.rb
|
274
|
+
- example/spec/views/issue_comments/index.html.erb_spec.rb
|
275
|
+
- example/spec/views/issue_comments/new.html.erb_spec.rb
|
276
|
+
- example/spec/views/issue_comments/show.html.erb_spec.rb
|
256
277
|
- example/spec/views/issues/edit.html.erb_spec.rb
|
257
278
|
- example/spec/views/issues/index.html.erb_spec.rb
|
258
279
|
- example/spec/views/issues/new.html.erb_spec.rb
|