model_base_generators 0.1.2 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +6 -0
- data/Rakefile +13 -1
- data/example/.gitignore +2 -0
- data/example/.rspec +2 -0
- data/example/Gemfile +72 -0
- data/example/Gemfile.lock +304 -0
- data/example/Rakefile +6 -0
- data/example/app/assets/config/manifest.js +5 -0
- data/example/app/assets/images/.keep +0 -0
- data/example/app/assets/javascripts/application.js +13 -0
- data/example/app/assets/javascripts/cable.js +13 -0
- data/example/app/assets/javascripts/channels/.keep +0 -0
- data/example/app/assets/stylesheets/application.css +15 -0
- data/example/app/channels/application_cable/channel.rb +4 -0
- data/example/app/channels/application_cable/connection.rb +4 -0
- data/example/app/controllers/application_controller.rb +3 -0
- data/example/app/controllers/concerns/.keep +0 -0
- data/example/app/controllers/concerns/authentication.rb +12 -0
- data/{examples → example}/app/controllers/issues_controller.rb +1 -1
- data/example/app/controllers/projects_controller.rb +62 -0
- data/example/app/helpers/application_helper.rb +2 -0
- data/example/app/helpers/issues_helper.rb +2 -0
- data/example/app/helpers/projects_helper.rb +2 -0
- data/example/app/jobs/application_job.rb +2 -0
- data/example/app/mailers/application_mailer.rb +4 -0
- data/example/app/models/ability.rb +35 -0
- data/example/app/models/application_record.rb +3 -0
- data/example/app/models/concerns/.keep +0 -0
- data/example/app/models/issue.rb +16 -0
- data/example/app/models/project.rb +6 -0
- data/example/app/models/user.rb +25 -0
- data/example/app/validations/ar_internal_metadatum_validation.rb +8 -0
- data/example/app/validations/issue_validation.rb +9 -0
- data/example/app/validations/project_validation.rb +8 -0
- data/example/app/validations/user_validation.rb +10 -0
- data/{examples → example}/app/views/issues/_form.html.erb +8 -1
- data/{examples/app/views/issues/index.html.erb → example/app/views/issues/_table.html.erb} +2 -7
- data/{examples → example}/app/views/issues/edit.html.erb +0 -0
- data/example/app/views/issues/index.html.erb +9 -0
- data/{examples → example}/app/views/issues/new.html.erb +0 -0
- data/{examples → example}/app/views/issues/show.html.erb +6 -0
- data/example/app/views/layouts/application.html.erb +14 -0
- data/example/app/views/layouts/mailer.html.erb +13 -0
- data/example/app/views/layouts/mailer.text.erb +1 -0
- data/{examples → example}/app/views/projects/_form.html.erb +7 -0
- data/{examples/app/views/projects/index.html.erb → example/app/views/projects/_table.html.erb} +2 -9
- data/{examples → example}/app/views/projects/edit.html.erb +0 -0
- data/example/app/views/projects/index.html.erb +9 -0
- data/{examples → example}/app/views/projects/new.html.erb +0 -0
- data/{examples → example}/app/views/projects/show.html.erb +2 -0
- data/example/bin/bundle +3 -0
- data/example/bin/rails +4 -0
- data/example/bin/rake +4 -0
- data/example/bin/setup +34 -0
- data/example/bin/update +29 -0
- data/example/config/application.rb +20 -0
- data/example/config/boot.rb +5 -0
- data/example/config/cable.yml +9 -0
- data/example/config/database.yml +25 -0
- data/example/config/environment.rb +5 -0
- data/example/config/environments/development.rb +56 -0
- data/example/config/environments/production.rb +86 -0
- data/example/config/environments/test.rb +42 -0
- data/example/config/initializers/application_controller_renderer.rb +6 -0
- data/example/config/initializers/assets.rb +11 -0
- data/example/config/initializers/backtrace_silencers.rb +7 -0
- data/example/config/initializers/cookies_serializer.rb +5 -0
- data/example/config/initializers/devise.rb +274 -0
- data/example/config/initializers/filter_parameter_logging.rb +4 -0
- data/example/config/initializers/inflections.rb +16 -0
- data/example/config/initializers/mime_types.rb +4 -0
- data/example/config/initializers/new_framework_defaults.rb +24 -0
- data/example/config/initializers/pretty_validation.rb +5 -0
- data/example/config/initializers/session_store.rb +3 -0
- data/example/config/initializers/wrap_parameters.rb +14 -0
- data/example/config/locales/devise.en.yml +62 -0
- data/example/config/locales/en.yml +23 -0
- data/example/config/puma.rb +47 -0
- data/example/config/routes.rb +6 -0
- data/example/config/secrets.yml +22 -0
- data/example/config/spring.rb +6 -0
- data/example/config.ru +5 -0
- data/example/db/schema.rb +34 -0
- data/example/lib/assets/.keep +0 -0
- data/example/log/.keep +0 -0
- data/example/public/404.html +67 -0
- data/example/public/422.html +67 -0
- data/example/public/500.html +66 -0
- data/example/public/apple-touch-icon-precomposed.png +0 -0
- data/example/public/apple-touch-icon.png +0 -0
- data/example/public/favicon.ico +0 -0
- data/{examples → example}/spec/controllers/issues_controller_spec.rb +6 -6
- data/{examples → example}/spec/controllers/projects_controller_spec.rb +4 -4
- data/example/spec/factories/issues.rb +8 -0
- data/example/spec/factories/projects.rb +6 -0
- data/example/spec/factories/users.rb +8 -0
- data/example/spec/rails_helper.rb +57 -0
- data/{examples → example}/spec/routing/issues_routing_spec.rb +0 -0
- data/{examples → example}/spec/routing/projects_routing_spec.rb +0 -0
- data/example/spec/spec_helper.rb +99 -0
- data/example/spec/support/controller_macros.rb +18 -0
- data/example/spec/support/devise.rb +16 -0
- data/{examples → example}/spec/views/issues/edit.html.erb_spec.rb +4 -1
- data/example/spec/views/issues/index.html.erb_spec.rb +21 -0
- data/{examples → example}/spec/views/issues/new.html.erb_spec.rb +4 -1
- data/example/spec/views/issues/show.html.erb_spec.rb +17 -0
- data/{examples → example}/spec/views/projects/edit.html.erb_spec.rb +3 -1
- data/example/spec/views/projects/index.html.erb_spec.rb +18 -0
- data/{examples → example}/spec/views/projects/new.html.erb_spec.rb +3 -1
- data/example/spec/views/projects/show.html.erb_spec.rb +14 -0
- data/example/tmp/.keep +0 -0
- data/lib/model_base/column_attribute.rb +63 -2
- data/lib/model_base/config.rb +13 -2
- data/lib/model_base/generators/erb/scaffold.rb +23 -0
- data/lib/model_base/generators/factory_girl/model.rb +37 -0
- data/lib/model_base/meta_model.rb +77 -13
- data/lib/model_base/version.rb +1 -1
- data/lib/model_base.rb +4 -0
- data/lib/templates/controller.rb +1 -1
- data/lib/templates/erb/scaffold/_form.html.erb +1 -1
- data/lib/templates/erb/scaffold/_table.html.erb +39 -0
- data/lib/templates/erb/scaffold/index.html.erb +1 -38
- data/lib/templates/erb/scaffold/show.html.erb +3 -1
- data/lib/templates/factory_girl/factory.rb +11 -0
- data/lib/templates/rspec/scaffold/controller_spec.rb +8 -13
- data/lib/templates/rspec/scaffold/edit_spec.rb +3 -3
- data/lib/templates/rspec/scaffold/index_spec.rb +13 -3
- data/lib/templates/rspec/scaffold/new_spec.rb +3 -2
- data/lib/templates/rspec/scaffold/show_spec.rb +4 -4
- metadata +115 -25
- data/examples/spec/views/issues/index.html.erb_spec.rb +0 -17
- data/examples/spec/views/issues/show.html.erb_spec.rb +0 -14
- data/examples/spec/views/projects/index.html.erb_spec.rb +0 -15
- data/examples/spec/views/projects/show.html.erb_spec.rb +0 -12
@@ -0,0 +1,67 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>The change you wanted was rejected (422)</title>
|
5
|
+
<meta name="viewport" content="width=device-width,initial-scale=1">
|
6
|
+
<style>
|
7
|
+
body {
|
8
|
+
background-color: #EFEFEF;
|
9
|
+
color: #2E2F30;
|
10
|
+
text-align: center;
|
11
|
+
font-family: arial, sans-serif;
|
12
|
+
margin: 0;
|
13
|
+
}
|
14
|
+
|
15
|
+
div.dialog {
|
16
|
+
width: 95%;
|
17
|
+
max-width: 33em;
|
18
|
+
margin: 4em auto 0;
|
19
|
+
}
|
20
|
+
|
21
|
+
div.dialog > div {
|
22
|
+
border: 1px solid #CCC;
|
23
|
+
border-right-color: #999;
|
24
|
+
border-left-color: #999;
|
25
|
+
border-bottom-color: #BBB;
|
26
|
+
border-top: #B00100 solid 4px;
|
27
|
+
border-top-left-radius: 9px;
|
28
|
+
border-top-right-radius: 9px;
|
29
|
+
background-color: white;
|
30
|
+
padding: 7px 12% 0;
|
31
|
+
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
32
|
+
}
|
33
|
+
|
34
|
+
h1 {
|
35
|
+
font-size: 100%;
|
36
|
+
color: #730E15;
|
37
|
+
line-height: 1.5em;
|
38
|
+
}
|
39
|
+
|
40
|
+
div.dialog > p {
|
41
|
+
margin: 0 0 1em;
|
42
|
+
padding: 1em;
|
43
|
+
background-color: #F7F7F7;
|
44
|
+
border: 1px solid #CCC;
|
45
|
+
border-right-color: #999;
|
46
|
+
border-left-color: #999;
|
47
|
+
border-bottom-color: #999;
|
48
|
+
border-bottom-left-radius: 4px;
|
49
|
+
border-bottom-right-radius: 4px;
|
50
|
+
border-top-color: #DADADA;
|
51
|
+
color: #666;
|
52
|
+
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
53
|
+
}
|
54
|
+
</style>
|
55
|
+
</head>
|
56
|
+
|
57
|
+
<body>
|
58
|
+
<!-- This file lives in public/422.html -->
|
59
|
+
<div class="dialog">
|
60
|
+
<div>
|
61
|
+
<h1>The change you wanted was rejected.</h1>
|
62
|
+
<p>Maybe you tried to change something you didn't have access to.</p>
|
63
|
+
</div>
|
64
|
+
<p>If you are the application owner check the logs for more information.</p>
|
65
|
+
</div>
|
66
|
+
</body>
|
67
|
+
</html>
|
@@ -0,0 +1,66 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>We're sorry, but something went wrong (500)</title>
|
5
|
+
<meta name="viewport" content="width=device-width,initial-scale=1">
|
6
|
+
<style>
|
7
|
+
body {
|
8
|
+
background-color: #EFEFEF;
|
9
|
+
color: #2E2F30;
|
10
|
+
text-align: center;
|
11
|
+
font-family: arial, sans-serif;
|
12
|
+
margin: 0;
|
13
|
+
}
|
14
|
+
|
15
|
+
div.dialog {
|
16
|
+
width: 95%;
|
17
|
+
max-width: 33em;
|
18
|
+
margin: 4em auto 0;
|
19
|
+
}
|
20
|
+
|
21
|
+
div.dialog > div {
|
22
|
+
border: 1px solid #CCC;
|
23
|
+
border-right-color: #999;
|
24
|
+
border-left-color: #999;
|
25
|
+
border-bottom-color: #BBB;
|
26
|
+
border-top: #B00100 solid 4px;
|
27
|
+
border-top-left-radius: 9px;
|
28
|
+
border-top-right-radius: 9px;
|
29
|
+
background-color: white;
|
30
|
+
padding: 7px 12% 0;
|
31
|
+
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
32
|
+
}
|
33
|
+
|
34
|
+
h1 {
|
35
|
+
font-size: 100%;
|
36
|
+
color: #730E15;
|
37
|
+
line-height: 1.5em;
|
38
|
+
}
|
39
|
+
|
40
|
+
div.dialog > p {
|
41
|
+
margin: 0 0 1em;
|
42
|
+
padding: 1em;
|
43
|
+
background-color: #F7F7F7;
|
44
|
+
border: 1px solid #CCC;
|
45
|
+
border-right-color: #999;
|
46
|
+
border-left-color: #999;
|
47
|
+
border-bottom-color: #999;
|
48
|
+
border-bottom-left-radius: 4px;
|
49
|
+
border-bottom-right-radius: 4px;
|
50
|
+
border-top-color: #DADADA;
|
51
|
+
color: #666;
|
52
|
+
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
53
|
+
}
|
54
|
+
</style>
|
55
|
+
</head>
|
56
|
+
|
57
|
+
<body>
|
58
|
+
<!-- This file lives in public/500.html -->
|
59
|
+
<div class="dialog">
|
60
|
+
<div>
|
61
|
+
<h1>We're sorry, but something went wrong.</h1>
|
62
|
+
</div>
|
63
|
+
<p>If you are the application owner check the logs for more information.</p>
|
64
|
+
</div>
|
65
|
+
</body>
|
66
|
+
</html>
|
File without changes
|
File without changes
|
File without changes
|
@@ -20,17 +20,17 @@ require 'rails_helper'
|
|
20
20
|
|
21
21
|
RSpec.describe IssuesController, type: :controller do
|
22
22
|
|
23
|
-
let(:project){ FactoryGirl.create(:project) }
|
23
|
+
let(:project){ FactoryGirl.create(:project, owner: user) }
|
24
24
|
let(:user){ FactoryGirl.create(:user) }
|
25
25
|
before{ devise_user_login(user) }
|
26
26
|
|
27
|
-
let(:issue){ FactoryGirl.create(:issue, project: project) }
|
27
|
+
let(:issue){ FactoryGirl.create(:issue, project: project, creator: user) }
|
28
28
|
|
29
29
|
# This should return the minimal set of attributes required to create a valid
|
30
30
|
# Issue. As you add validations to Issue, be sure to
|
31
31
|
# adjust the attributes here as well.
|
32
32
|
let(:valid_parameters) {
|
33
|
-
FactoryGirl.attributes_for(:issue).merge(project_id: project.id)
|
33
|
+
FactoryGirl.attributes_for(:issue).merge(project_id: project.id, creator_id: user.id)
|
34
34
|
}
|
35
35
|
|
36
36
|
let(:invalid_parameters) {
|
@@ -108,7 +108,7 @@ RSpec.describe IssuesController, type: :controller do
|
|
108
108
|
describe "PUT #update" do
|
109
109
|
context "with valid params" do
|
110
110
|
let(:new_title){ valid_parameters[:title].succ }
|
111
|
-
let(:new_status){
|
111
|
+
let(:new_status){ Issue.status.values[1] }
|
112
112
|
|
113
113
|
let(:new_parameters) {
|
114
114
|
valid_parameters.merge(title: new_title, status: new_status)
|
@@ -124,13 +124,13 @@ RSpec.describe IssuesController, type: :controller do
|
|
124
124
|
|
125
125
|
it "assigns the requested issue as @issue" do
|
126
126
|
issue # To create issue
|
127
|
-
put :update, params: {:id => issue.to_param, :issue =>
|
127
|
+
put :update, params: {:id => issue.to_param, :issue => new_parameters}, session: valid_session
|
128
128
|
expect(assigns(:issue)).to eq(issue)
|
129
129
|
end
|
130
130
|
|
131
131
|
it "redirects to the issue" do
|
132
132
|
issue # To create issue
|
133
|
-
put :update, params: {:id => issue.to_param, :issue =>
|
133
|
+
put :update, params: {:id => issue.to_param, :issue => new_parameters}, session: valid_session
|
134
134
|
expect(response).to redirect_to(issue)
|
135
135
|
end
|
136
136
|
end
|
@@ -23,13 +23,13 @@ RSpec.describe ProjectsController, type: :controller do
|
|
23
23
|
let(:user){ FactoryGirl.create(:user) }
|
24
24
|
before{ devise_user_login(user) }
|
25
25
|
|
26
|
-
let(:project){ FactoryGirl.create(:project) }
|
26
|
+
let(:project){ FactoryGirl.create(:project, owner: user) }
|
27
27
|
|
28
28
|
# This should return the minimal set of attributes required to create a valid
|
29
29
|
# Project. As you add validations to Project, be sure to
|
30
30
|
# adjust the attributes here as well.
|
31
31
|
let(:valid_parameters) {
|
32
|
-
FactoryGirl.attributes_for(:project)
|
32
|
+
FactoryGirl.attributes_for(:project).merge(owner_id: user.id)
|
33
33
|
}
|
34
34
|
|
35
35
|
let(:invalid_parameters) {
|
@@ -121,13 +121,13 @@ RSpec.describe ProjectsController, type: :controller do
|
|
121
121
|
|
122
122
|
it "assigns the requested project as @project" do
|
123
123
|
project # To create project
|
124
|
-
put :update, params: {:id => project.to_param, :project =>
|
124
|
+
put :update, params: {:id => project.to_param, :project => new_parameters}, session: valid_session
|
125
125
|
expect(assigns(:project)).to eq(project)
|
126
126
|
end
|
127
127
|
|
128
128
|
it "redirects to the project" do
|
129
129
|
project # To create project
|
130
|
-
put :update, params: {:id => project.to_param, :project =>
|
130
|
+
put :update, params: {:id => project.to_param, :project => new_parameters}, session: valid_session
|
131
131
|
expect(response).to redirect_to(project)
|
132
132
|
end
|
133
133
|
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
# This file is copied to spec/ when you run 'rails generate rspec:install'
|
2
|
+
ENV['RAILS_ENV'] ||= 'test'
|
3
|
+
require File.expand_path('../../config/environment', __FILE__)
|
4
|
+
# Prevent database truncation if the environment is production
|
5
|
+
abort("The Rails environment is running in production mode!") if Rails.env.production?
|
6
|
+
require 'spec_helper'
|
7
|
+
require 'rspec/rails'
|
8
|
+
# Add additional requires below this line. Rails is not loaded until this point!
|
9
|
+
|
10
|
+
# Requires supporting ruby files with custom matchers and macros, etc, in
|
11
|
+
# spec/support/ and its subdirectories. Files matching `spec/**/*_spec.rb` are
|
12
|
+
# run as spec files by default. This means that files in spec/support that end
|
13
|
+
# in _spec.rb will both be required and run as specs, causing the specs to be
|
14
|
+
# run twice. It is recommended that you do not name files matching this glob to
|
15
|
+
# end with _spec.rb. You can configure this pattern with the --pattern
|
16
|
+
# option on the command line or in ~/.rspec, .rspec or `.rspec-local`.
|
17
|
+
#
|
18
|
+
# The following line is provided for convenience purposes. It has the downside
|
19
|
+
# of increasing the boot-up time by auto-requiring all files in the support
|
20
|
+
# directory. Alternatively, in the individual `*_spec.rb` files, manually
|
21
|
+
# require only the support files necessary.
|
22
|
+
#
|
23
|
+
Dir[Rails.root.join('spec/support/**/*.rb')].each { |f| require f }
|
24
|
+
|
25
|
+
# Checks for pending migration and applies them before tests are run.
|
26
|
+
# If you are not using ActiveRecord, you can remove this line.
|
27
|
+
ActiveRecord::Migration.maintain_test_schema!
|
28
|
+
|
29
|
+
RSpec.configure do |config|
|
30
|
+
# Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
|
31
|
+
config.fixture_path = "#{::Rails.root}/spec/fixtures"
|
32
|
+
|
33
|
+
# If you're not using ActiveRecord, or you'd prefer not to run each of your
|
34
|
+
# examples within a transaction, remove the following line or assign false
|
35
|
+
# instead of true.
|
36
|
+
config.use_transactional_fixtures = true
|
37
|
+
|
38
|
+
# RSpec Rails can automatically mix in different behaviours to your tests
|
39
|
+
# based on their file location, for example enabling you to call `get` and
|
40
|
+
# `post` in specs under `spec/controllers`.
|
41
|
+
#
|
42
|
+
# You can disable this behaviour by removing the line below, and instead
|
43
|
+
# explicitly tag your specs with their type, e.g.:
|
44
|
+
#
|
45
|
+
# RSpec.describe UsersController, :type => :controller do
|
46
|
+
# # ...
|
47
|
+
# end
|
48
|
+
#
|
49
|
+
# The different available types are documented in the features, such as in
|
50
|
+
# https://relishapp.com/rspec/rspec-rails/docs
|
51
|
+
config.infer_spec_type_from_file_location!
|
52
|
+
|
53
|
+
# Filter lines from Rails gems in backtraces.
|
54
|
+
config.filter_rails_from_backtrace!
|
55
|
+
# arbitrary gems may also be filtered via:
|
56
|
+
# config.filter_gems_from_backtrace("gem name")
|
57
|
+
end
|
File without changes
|
File without changes
|
@@ -0,0 +1,99 @@
|
|
1
|
+
# This file was generated by the `rails generate rspec:install` command. Conventionally, all
|
2
|
+
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
|
3
|
+
# The generated `.rspec` file contains `--require spec_helper` which will cause
|
4
|
+
# this file to always be loaded, without a need to explicitly require it in any
|
5
|
+
# files.
|
6
|
+
#
|
7
|
+
# Given that it is always loaded, you are encouraged to keep this file as
|
8
|
+
# light-weight as possible. Requiring heavyweight dependencies from this file
|
9
|
+
# will add to the boot time of your test suite on EVERY test run, even for an
|
10
|
+
# individual file that may not need all of that loaded. Instead, consider making
|
11
|
+
# a separate helper file that requires the additional dependencies and performs
|
12
|
+
# the additional setup, and require it from the spec files that actually need
|
13
|
+
# it.
|
14
|
+
#
|
15
|
+
# The `.rspec` file also contains a few flags that are not defaults but that
|
16
|
+
# users commonly want.
|
17
|
+
#
|
18
|
+
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
19
|
+
RSpec.configure do |config|
|
20
|
+
# rspec-expectations config goes here. You can use an alternate
|
21
|
+
# assertion/expectation library such as wrong or the stdlib/minitest
|
22
|
+
# assertions if you prefer.
|
23
|
+
config.expect_with :rspec do |expectations|
|
24
|
+
# This option will default to `true` in RSpec 4. It makes the `description`
|
25
|
+
# and `failure_message` of custom matchers include text for helper methods
|
26
|
+
# defined using `chain`, e.g.:
|
27
|
+
# be_bigger_than(2).and_smaller_than(4).description
|
28
|
+
# # => "be bigger than 2 and smaller than 4"
|
29
|
+
# ...rather than:
|
30
|
+
# # => "be bigger than 2"
|
31
|
+
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
|
32
|
+
end
|
33
|
+
|
34
|
+
# rspec-mocks config goes here. You can use an alternate test double
|
35
|
+
# library (such as bogus or mocha) by changing the `mock_with` option here.
|
36
|
+
config.mock_with :rspec do |mocks|
|
37
|
+
# Prevents you from mocking or stubbing a method that does not exist on
|
38
|
+
# a real object. This is generally recommended, and will default to
|
39
|
+
# `true` in RSpec 4.
|
40
|
+
mocks.verify_partial_doubles = true
|
41
|
+
end
|
42
|
+
|
43
|
+
# This option will default to `:apply_to_host_groups` in RSpec 4 (and will
|
44
|
+
# have no way to turn it off -- the option exists only for backwards
|
45
|
+
# compatibility in RSpec 3). It causes shared context metadata to be
|
46
|
+
# inherited by the metadata hash of host groups and examples, rather than
|
47
|
+
# triggering implicit auto-inclusion in groups with matching metadata.
|
48
|
+
config.shared_context_metadata_behavior = :apply_to_host_groups
|
49
|
+
|
50
|
+
# The settings below are suggested to provide a good initial experience
|
51
|
+
# with RSpec, but feel free to customize to your heart's content.
|
52
|
+
=begin
|
53
|
+
# This allows you to limit a spec run to individual examples or groups
|
54
|
+
# you care about by tagging them with `:focus` metadata. When nothing
|
55
|
+
# is tagged with `:focus`, all examples get run. RSpec also provides
|
56
|
+
# aliases for `it`, `describe`, and `context` that include `:focus`
|
57
|
+
# metadata: `fit`, `fdescribe` and `fcontext`, respectively.
|
58
|
+
config.filter_run_when_matching :focus
|
59
|
+
|
60
|
+
# Allows RSpec to persist some state between runs in order to support
|
61
|
+
# the `--only-failures` and `--next-failure` CLI options. We recommend
|
62
|
+
# you configure your source control system to ignore this file.
|
63
|
+
config.example_status_persistence_file_path = "spec/examples.txt"
|
64
|
+
|
65
|
+
# Limits the available syntax to the non-monkey patched syntax that is
|
66
|
+
# recommended. For more details, see:
|
67
|
+
# - http://rspec.info/blog/2012/06/rspecs-new-expectation-syntax/
|
68
|
+
# - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
|
69
|
+
# - http://rspec.info/blog/2014/05/notable-changes-in-rspec-3/#zero-monkey-patching-mode
|
70
|
+
config.disable_monkey_patching!
|
71
|
+
|
72
|
+
# Many RSpec users commonly either run the entire suite or an individual
|
73
|
+
# file, and it's useful to allow more verbose output when running an
|
74
|
+
# individual spec file.
|
75
|
+
if config.files_to_run.one?
|
76
|
+
# Use the documentation formatter for detailed output,
|
77
|
+
# unless a formatter has already been configured
|
78
|
+
# (e.g. via a command-line flag).
|
79
|
+
config.default_formatter = 'doc'
|
80
|
+
end
|
81
|
+
|
82
|
+
# Print the 10 slowest examples and example groups at the
|
83
|
+
# end of the spec run, to help surface which specs are running
|
84
|
+
# particularly slow.
|
85
|
+
config.profile_examples = 10
|
86
|
+
|
87
|
+
# Run specs in random order to surface order dependencies. If you find an
|
88
|
+
# order dependency and want to debug it, you can fix the order by providing
|
89
|
+
# the seed, which is printed after each run.
|
90
|
+
# --seed 1234
|
91
|
+
config.order = :random
|
92
|
+
|
93
|
+
# Seed global randomization in this process using the `--seed` CLI option.
|
94
|
+
# Setting this allows you to use `--seed` to deterministically reproduce
|
95
|
+
# test failures related to randomization by passing the same `--seed` value
|
96
|
+
# as the one that triggered the failure.
|
97
|
+
Kernel.srand config.seed
|
98
|
+
=end
|
99
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module ControllerMacros
|
2
|
+
def devise_login(key, user)
|
3
|
+
@request.env["devise.mapping"] = Devise.mappings[key]
|
4
|
+
sign_in(user)
|
5
|
+
end
|
6
|
+
|
7
|
+
def devise_user_login(user)
|
8
|
+
devise_login(:user, user)
|
9
|
+
end
|
10
|
+
|
11
|
+
def login_admin
|
12
|
+
before(:each){ devise_login(:admin, FactoryGirl.create(:admin)) }
|
13
|
+
end
|
14
|
+
|
15
|
+
def login_user
|
16
|
+
before(:each){ devise_login(:user, FactoryGirl.create(:user)) }
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# https://github.com/plataformatec/devise/wiki/How-To:-Test-controllers-with-Rails-3-and-4-(and-RSpec)
|
2
|
+
RSpec.configure do |config|
|
3
|
+
config.with_options(:type => :controller) do |c|
|
4
|
+
c.include Devise::Test::ControllerHelpers
|
5
|
+
c.include ControllerMacros
|
6
|
+
c.extend ControllerMacros
|
7
|
+
end
|
8
|
+
|
9
|
+
# For request spec
|
10
|
+
# https://github.com/plataformatec/devise/wiki/How-To:-Test-with-Capybara
|
11
|
+
# http://qiita.com/gakkie/items/40e5678af7b63afc14df
|
12
|
+
config.include Warden::Test::Helpers, :type => :request
|
13
|
+
config.before :suite do
|
14
|
+
Warden.test_mode!
|
15
|
+
end
|
16
|
+
end
|
@@ -1,8 +1,10 @@
|
|
1
1
|
require 'rails_helper'
|
2
2
|
|
3
3
|
RSpec.describe "issues/edit", type: :view do
|
4
|
+
let(:project){ FactoryGirl.create(:project, owner: user) }
|
5
|
+
let(:user){ FactoryGirl.create(:user) }
|
4
6
|
before(:each) do
|
5
|
-
@issue = assign(:issue, FactoryGirl.create(:issue))
|
7
|
+
@issue = assign(:issue, FactoryGirl.create(:issue, project: project, creator: user))
|
6
8
|
end
|
7
9
|
|
8
10
|
it "renders the edit issue form" do
|
@@ -12,6 +14,7 @@ RSpec.describe "issues/edit", type: :view do
|
|
12
14
|
assert_select "select#issue_project_id[name=?]", "issue[project_id]"
|
13
15
|
assert_select "input#issue_title[name=?]", "issue[title]"
|
14
16
|
assert_select "select#issue_status[name=?]", "issue[status]"
|
17
|
+
assert_select "select#issue_creator_id[name=?]", "issue[creator_id]"
|
15
18
|
end
|
16
19
|
end
|
17
20
|
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'rails_helper'
|
2
|
+
|
3
|
+
RSpec.describe "issues/index", type: :view do
|
4
|
+
let(:project){ FactoryGirl.create(:project, owner: user) }
|
5
|
+
let(:user){ FactoryGirl.create(:user) }
|
6
|
+
before(:each) do
|
7
|
+
assign(:issues, [
|
8
|
+
FactoryGirl.create(:issue, title: 'issue1', project: project, creator: user),
|
9
|
+
FactoryGirl.create(:issue, title: 'issue2', project: project, creator: user),
|
10
|
+
])
|
11
|
+
end
|
12
|
+
|
13
|
+
it "renders a list of issues" do
|
14
|
+
render
|
15
|
+
assert_select "tr>td", :text => 'project1', :count => 2
|
16
|
+
assert_select "tr>td", :text => 'issue1', :count => 1
|
17
|
+
assert_select "tr>td", :text => 'issue2', :count => 1
|
18
|
+
assert_select "tr>td", :text => 'Draft', :count => 2
|
19
|
+
assert_select "tr>td", :text => 'user1@example.com', :count => 2
|
20
|
+
end
|
21
|
+
end
|
@@ -1,8 +1,10 @@
|
|
1
1
|
require 'rails_helper'
|
2
2
|
|
3
3
|
RSpec.describe "issues/new", type: :view do
|
4
|
+
let(:project){ FactoryGirl.create(:project, owner: user) }
|
5
|
+
let(:user){ FactoryGirl.create(:user) }
|
4
6
|
before(:each) do
|
5
|
-
assign(:issue, FactoryGirl.build(:issue))
|
7
|
+
assign(:issue, FactoryGirl.build(:issue, project: project, creator: user))
|
6
8
|
end
|
7
9
|
|
8
10
|
it "renders new issue form" do
|
@@ -12,6 +14,7 @@ RSpec.describe "issues/new", type: :view do
|
|
12
14
|
assert_select "select#issue_project_id[name=?]", "issue[project_id]"
|
13
15
|
assert_select "input#issue_title[name=?]", "issue[title]"
|
14
16
|
assert_select "select#issue_status[name=?]", "issue[status]"
|
17
|
+
assert_select "select#issue_creator_id[name=?]", "issue[creator_id]"
|
15
18
|
end
|
16
19
|
end
|
17
20
|
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'rails_helper'
|
2
|
+
|
3
|
+
RSpec.describe "issues/show", type: :view do
|
4
|
+
let(:project){ FactoryGirl.create(:project, owner: user) }
|
5
|
+
let(:user){ FactoryGirl.create(:user) }
|
6
|
+
before(:each) do
|
7
|
+
@issue = assign(:issue, FactoryGirl.create(:issue, project: project, creator: user))
|
8
|
+
end
|
9
|
+
|
10
|
+
it "renders attributes in <p>" do
|
11
|
+
render
|
12
|
+
expect(rendered).to match(/project1/)
|
13
|
+
expect(rendered).to match(/issue1/)
|
14
|
+
expect(rendered).to match(/Draft/)
|
15
|
+
expect(rendered).to match(/user1@example.com/)
|
16
|
+
end
|
17
|
+
end
|
@@ -1,14 +1,16 @@
|
|
1
1
|
require 'rails_helper'
|
2
2
|
|
3
3
|
RSpec.describe "projects/edit", type: :view do
|
4
|
+
let(:user){ FactoryGirl.create(:user) }
|
4
5
|
before(:each) do
|
5
|
-
@project = assign(:project, FactoryGirl.create(:project))
|
6
|
+
@project = assign(:project, FactoryGirl.create(:project, owner: user))
|
6
7
|
end
|
7
8
|
|
8
9
|
it "renders the edit project form" do
|
9
10
|
render
|
10
11
|
|
11
12
|
assert_select "form[action=?][method=?]", project_path(@project), "post" do
|
13
|
+
assert_select "select#project_owner_id[name=?]", "project[owner_id]"
|
12
14
|
assert_select "input#project_name[name=?]", "project[name]"
|
13
15
|
end
|
14
16
|
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'rails_helper'
|
2
|
+
|
3
|
+
RSpec.describe "projects/index", type: :view do
|
4
|
+
let(:user){ FactoryGirl.create(:user) }
|
5
|
+
before(:each) do
|
6
|
+
assign(:projects, [
|
7
|
+
FactoryGirl.create(:project, name: 'project1', owner: user),
|
8
|
+
FactoryGirl.create(:project, name: 'project2', owner: user),
|
9
|
+
])
|
10
|
+
end
|
11
|
+
|
12
|
+
it "renders a list of projects" do
|
13
|
+
render
|
14
|
+
assert_select "tr>td", :text => 'user1@example.com', :count => 2
|
15
|
+
assert_select "tr>td", :text => 'project1', :count => 1
|
16
|
+
assert_select "tr>td", :text => 'project2', :count => 1
|
17
|
+
end
|
18
|
+
end
|
@@ -1,14 +1,16 @@
|
|
1
1
|
require 'rails_helper'
|
2
2
|
|
3
3
|
RSpec.describe "projects/new", type: :view do
|
4
|
+
let(:user){ FactoryGirl.create(:user) }
|
4
5
|
before(:each) do
|
5
|
-
assign(:project, FactoryGirl.build(:project))
|
6
|
+
assign(:project, FactoryGirl.build(:project, owner: user))
|
6
7
|
end
|
7
8
|
|
8
9
|
it "renders new project form" do
|
9
10
|
render
|
10
11
|
|
11
12
|
assert_select "form[action=?][method=?]", projects_path, "post" do
|
13
|
+
assert_select "select#project_owner_id[name=?]", "project[owner_id]"
|
12
14
|
assert_select "input#project_name[name=?]", "project[name]"
|
13
15
|
end
|
14
16
|
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'rails_helper'
|
2
|
+
|
3
|
+
RSpec.describe "projects/show", type: :view do
|
4
|
+
let(:user){ FactoryGirl.create(:user) }
|
5
|
+
before(:each) do
|
6
|
+
@project = assign(:project, FactoryGirl.create(:project, owner: user))
|
7
|
+
end
|
8
|
+
|
9
|
+
it "renders attributes in <p>" do
|
10
|
+
render
|
11
|
+
expect(rendered).to match(/user1@example.com/)
|
12
|
+
expect(rendered).to match(/project1/)
|
13
|
+
end
|
14
|
+
end
|
data/example/tmp/.keep
ADDED
File without changes
|