├── .circleci
└── config.yml
├── .env.app.testing
├── .env.db.testing
├── .gitignore
├── .rspec
├── .rubocop.yml
├── .ruby-version
├── COPYING
├── Dockerfile
├── Gemfile
├── Gemfile.lock
├── README.md
├── Rakefile
├── app
├── assets
│ ├── config
│ │ └── manifest.js
│ ├── images
│ │ └── .keep
│ ├── javascripts
│ │ ├── application.js
│ │ ├── cable.js
│ │ ├── channels
│ │ │ └── .keep
│ │ ├── posts.coffee
│ │ └── welcome.coffee
│ └── stylesheets
│ │ ├── application.css
│ │ ├── posts.scss
│ │ ├── scaffolds.scss
│ │ └── welcome.scss
├── channels
│ └── application_cable
│ │ ├── channel.rb
│ │ └── connection.rb
├── controllers
│ ├── application_controller.rb
│ ├── concerns
│ │ └── .keep
│ ├── posts_controller.rb
│ └── welcome_controller.rb
├── helpers
│ ├── application_helper.rb
│ ├── posts_helper.rb
│ └── welcome_helper.rb
├── jobs
│ └── application_job.rb
├── mailers
│ └── application_mailer.rb
├── models
│ ├── application_record.rb
│ ├── concerns
│ │ └── .keep
│ └── post.rb
└── views
│ ├── layouts
│ ├── application.html.erb
│ ├── mailer.html.erb
│ └── mailer.text.erb
│ ├── posts
│ ├── _form.html.erb
│ ├── _post.json.jbuilder
│ ├── edit.html.erb
│ ├── index.html.erb
│ ├── index.json.jbuilder
│ ├── new.html.erb
│ ├── show.html.erb
│ └── show.json.jbuilder
│ └── welcome
│ └── index.html.erb
├── bin
├── bundle
├── rails
├── rake
├── setup
├── spring
├── update
└── yarn
├── config.ru
├── config
├── application.rb
├── boot.rb
├── cable.yml
├── database.yml
├── environment.rb
├── environments
│ ├── development.rb
│ ├── production.rb
│ └── test.rb
├── initializers
│ ├── application_controller_renderer.rb
│ ├── assets.rb
│ ├── backtrace_silencers.rb
│ ├── cookies_serializer.rb
│ ├── filter_parameter_logging.rb
│ ├── inflections.rb
│ ├── mime_types.rb
│ └── wrap_parameters.rb
├── locales
│ └── en.yml
├── puma.rb
├── routes.rb
├── secrets.yml
└── spring.rb
├── db
├── migrate
│ └── 20170509232014_create_posts.rb
├── schema.rb
└── seeds.rb
├── docker-compose.yml
├── entrypoint.sh
├── lib
├── assets
│ └── .keep
└── tasks
│ └── .keep
├── log
└── .keep
├── package.json
├── public
├── 404.html
├── 422.html
├── 500.html
├── apple-touch-icon-precomposed.png
├── apple-touch-icon.png
├── favicon.ico
└── robots.txt
├── spec
├── controllers
│ ├── posts_controller_spec.rb
│ └── welcome_controller_spec.rb
├── helpers
│ ├── posts_helper_spec.rb
│ └── welcome_helper_spec.rb
├── models
│ └── post_spec.rb
├── rails_helper.rb
├── requests
│ └── posts_spec.rb
├── routing
│ └── posts_routing_spec.rb
├── spec_helper.rb
└── views
│ ├── posts
│ ├── edit.html.erb_spec.rb
│ ├── index.html.erb_spec.rb
│ ├── new.html.erb_spec.rb
│ └── show.html.erb_spec.rb
│ └── welcome
│ └── index.html.erb_spec.rb
├── test
├── application_system_test_case.rb
├── controllers
│ └── .keep
├── fixtures
│ ├── .keep
│ └── files
│ │ └── .keep
├── helpers
│ └── .keep
├── integration
│ └── .keep
├── mailers
│ └── .keep
├── models
│ └── .keep
├── system
│ ├── .keep
│ └── posts_test.rb
└── test_helper.rb
├── tmp
└── .keep
├── vendor
└── .keep
└── yarn.lock
/.circleci/config.yml:
--------------------------------------------------------------------------------
1 | version: 2.1
2 |
3 | orbs:
4 | ruby: circleci/ruby@1.1.0
5 | node: circleci/node@2
6 |
7 | jobs:
8 | build:
9 | docker:
10 | - image: cimg/ruby:2.7-node
11 | steps:
12 | - checkout
13 | - ruby/install-deps
14 | # Store bundle cache
15 | - node/install-packages:
16 | pkg-manager: yarn
17 | cache-key: "yarn.lock"
18 | test:
19 | parallelism: 3
20 | docker:
21 | - image: cimg/ruby:2.7-node
22 | - image: circleci/postgres:9.5-alpine
23 | environment:
24 | POSTGRES_USER: circleci-demo-ruby
25 | POSTGRES_DB: rails_blog_test
26 | POSTGRES_PASSWORD: ""
27 | environment:
28 | BUNDLE_JOBS: "3"
29 | BUNDLE_RETRY: "3"
30 | PGHOST: 127.0.0.1
31 | PGUSER: circleci-demo-ruby
32 | PGPASSWORD: ""
33 | RAILS_ENV: test
34 | steps:
35 | - checkout
36 | - ruby/install-deps
37 | - node/install-packages:
38 | pkg-manager: yarn
39 | cache-key: "yarn.lock"
40 | - run:
41 | name: Wait for DB
42 | command: dockerize -wait tcp://localhost:5432 -timeout 1m
43 | - run:
44 | name: Database setup
45 | command: bundle exec rails db:schema:load --trace
46 | # Run rspec in parallel
47 | - ruby/rspec-test
48 | - ruby/rubocop-check
49 |
50 | workflows:
51 | version: 2
52 | build_and_test:
53 | jobs:
54 | - build
55 | - test:
56 | requires:
57 | - build
58 |
--------------------------------------------------------------------------------
/.env.app.testing:
--------------------------------------------------------------------------------
1 | POSTGRES_HOST=db
2 | PGUSER=postgres
3 | PGPASSWORD=postgres
4 | RAILS_ENV=development
5 |
--------------------------------------------------------------------------------
/.env.db.testing:
--------------------------------------------------------------------------------
1 | POSTGRES_USER=postgres
2 | POSTGRES_PASSWORD=postgres
3 | POSTGRES_DB=rails_blog_dev
4 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # See https://help.github.com/articles/ignoring-files for more about ignoring files.
2 | #
3 | # If you find yourself ignoring temporary files generated by your text editor
4 | # or operating system, you probably want to add a global ignore instead:
5 | # git config --global core.excludesfile '~/.gitignore_global'
6 |
7 | # Ignore bundler config.
8 | /.bundle
9 |
10 | # Ignore the default SQLite database.
11 | /db/*.sqlite3
12 | /db/*.sqlite3-journal
13 |
14 | # Ignore all logfiles and tempfiles.
15 | /log/*
16 | /tmp/*
17 | !/log/.keep
18 | !/tmp/.keep
19 |
20 | /yarn-error.log
21 | .byebug_history
22 |
23 | # Ignore packages
24 | /vendor
25 | /node_modules
26 |
27 | # Ignore dist files
28 | /public/assets
29 |
30 | # Ignore env files
31 | *.env
32 |
33 |
--------------------------------------------------------------------------------
/.rspec:
--------------------------------------------------------------------------------
1 | --require spec_helper
2 |
--------------------------------------------------------------------------------
/.rubocop.yml:
--------------------------------------------------------------------------------
1 | Style/Documentation:
2 | Enabled: false
3 |
4 | Metrics/BlockLength:
5 | Enabled: false
6 |
7 | Style/RedundantParentheses:
8 | Enabled: false
9 |
10 | # I can correct It by -a
11 | Style/FrozenStringLiteralComment:
12 | Safe: true
13 |
14 | # About ABC http://wiki.c2.com/?AbcMetric
15 | Metrics/AbcSize:
16 | Enabled: false
17 |
18 | AllCops:
19 | Exclude:
20 | - 'db/**/*'
21 | - 'config/**/*'
22 | - 'script/**/*'
23 | - 'bin/*'
24 | - 'node_modules/**/*'
25 | - 'vendor/bundle/**/*' # For CI broken
26 |
27 | # pending status for avoiding the warning
28 |
29 | Layout/EmptyLinesAroundAttributeAccessor:
30 | Enabled: true
31 |
32 | Layout/SpaceAroundMethodCallOperator:
33 | Enabled: true
34 |
35 | Lint/DeprecatedOpenSSLConstant:
36 | Enabled: true
37 |
38 | Lint/DuplicateElsifCondition:
39 | Enabled: true
40 |
41 | Lint/MixedRegexpCaptureTypes:
42 | Enabled: true
43 |
44 | Lint/RaiseException:
45 | Enabled: true
46 |
47 | Lint/StructNewOverride:
48 | Enabled: true
49 |
50 | Style/AccessorGrouping:
51 | Enabled: true
52 |
53 | Style/ArrayCoercion:
54 | Enabled: true
55 |
56 | Style/BisectedAttrAccessor:
57 | Enabled: true
58 |
59 | Style/CaseLikeIf:
60 | Enabled: true
61 |
62 | Style/ExponentialNotation:
63 | Enabled: true
64 |
65 | Style/HashAsLastArrayItem:
66 | Enabled: true
67 |
68 | Style/HashEachMethods:
69 | Enabled: true
70 |
71 | Style/HashLikeCase:
72 | Enabled: true
73 |
74 | Style/HashTransformKeys:
75 | Enabled: true
76 |
77 | Style/HashTransformValues:
78 | Enabled: true
79 |
80 | Style/RedundantAssignment:
81 | Enabled: true
82 |
83 | Style/RedundantFetchBlock:
84 | Enabled: true
85 |
86 | Style/RedundantFileExtensionInRequire:
87 | Enabled: true
88 |
89 | Style/RedundantRegexpCharacterClass:
90 | Enabled: true
91 |
92 | Style/RedundantRegexpEscape:
93 | Enabled: true
94 |
95 | Style/SlicingWithRange:
96 | Enabled: true
97 |
--------------------------------------------------------------------------------
/.ruby-version:
--------------------------------------------------------------------------------
1 | 2.7.5
2 |
--------------------------------------------------------------------------------
/COPYING:
--------------------------------------------------------------------------------
1 | Copyright (c) 2017 CircleCI
2 |
3 | Permission is hereby granted, free of charge, to any person obtaining a copy
4 | of this software and associated documentation files (the "Software"), to deal
5 | in the Software without restriction, including without limitation the rights
6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 | copies of the Software, and to permit persons to whom the Software is
8 | furnished to do so, subject to the following conditions:
9 |
10 | The above copyright notice and this permission notice shall be included in all
11 | copies or substantial portions of the Software.
12 |
13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19 | SOFTWARE.
20 |
--------------------------------------------------------------------------------
/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM ruby:2.7.5
2 |
3 | RUN apt-get update \
4 | && apt-get install -y nodejs postgresql-client
5 |
6 | RUN mkdir /myapp
7 | WORKDIR /myapp
8 | COPY Gemfile /myapp/Gemfile
9 | COPY Gemfile.lock /myapp/Gemfile.lock
10 | RUN bundle install
11 | COPY . /myapp
12 |
13 |
14 | # Add a script to be executed every time the container starts.
15 | COPY entrypoint.sh /usr/bin/
16 | RUN chmod +x /usr/bin/entrypoint.sh
17 | ENTRYPOINT ["entrypoint.sh"]
18 | EXPOSE 3000
19 |
20 | # Start the main process.
21 | CMD ["rails", "server", "-b", "0.0.0.0"]
22 |
--------------------------------------------------------------------------------
/Gemfile:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | source 'https://rubygems.org'
4 |
5 | git_source(:github) do |repo_name|
6 | repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?('/')
7 | "https://github.com/#{repo_name}.git"
8 | end
9 |
10 | ruby '2.7.5'
11 |
12 | # Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
13 | gem 'rails', '~> 6.0.1'
14 | # Use postgresql as the database for Active Record
15 | gem 'pg', '~> 0.18'
16 | # Use Puma as the app server
17 | gem 'puma', '~> 3.7'
18 | # Use SCSS for stylesheets
19 | gem 'sass-rails', '~> 5.0.7'
20 | # Use Uglifier as compressor for JavaScript assets
21 | gem 'uglifier', '>= 1.3.0'
22 | # See https://github.com/rails/execjs#readme for more supported runtimes
23 | # gem 'therubyracer', platforms: :ruby
24 |
25 | # Use CoffeeScript for .coffee assets and views
26 | gem 'coffee-rails', '~> 5.0.0'
27 | # Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks
28 | gem 'turbolinks', '~> 5'
29 | # Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
30 | gem 'jbuilder', '~> 2.9.1'
31 | # Use Redis adapter to run Action Cable in production
32 | # gem 'redis', '~> 3.0'
33 | # Use ActiveModel has_secure_password
34 | # gem 'bcrypt', '~> 3.1.7'
35 |
36 | # Use Capistrano for deployment
37 | # gem 'capistrano-rails', group: :development
38 |
39 | # https://github.com/rubocop-hq/rubocop
40 | gem 'rubocop', '~> 0.89.0', require: false
41 |
42 | group :development, :test do
43 | # Call 'byebug' anywhere in the code to stop execution and get a debugger console
44 | gem 'byebug', platforms: %i[mri mingw x64_mingw]
45 | # Adds support for Capybara system testing and selenium driver
46 | gem 'capybara', '~> 2.13.0'
47 | gem 'selenium-webdriver'
48 |
49 | gem 'rspec_junit_formatter'
50 | gem 'rspec-rails', '4.0.0.beta3'
51 | end
52 |
53 | group :development do
54 | # Access an IRB console on exception pages or by using <%= console %> anywhere in the code.
55 | gem 'listen', '>= 3.0.5', '< 3.2'
56 | gem 'web-console', '>= 3.7.0'
57 | # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
58 | gem 'spring', '~> 2.0.2'
59 | gem 'spring-watcher-listen', '~> 2.0.0'
60 | end
61 |
62 | # Windows does not include zoneinfo files, so bundle the tzinfo-data gem
63 | gem 'tzinfo-data', platforms: %i[mingw mswin x64_mingw jruby]
64 |
--------------------------------------------------------------------------------
/Gemfile.lock:
--------------------------------------------------------------------------------
1 | GEM
2 | remote: https://rubygems.org/
3 | specs:
4 | actioncable (6.0.3.6)
5 | actionpack (= 6.0.3.6)
6 | nio4r (~> 2.0)
7 | websocket-driver (>= 0.6.1)
8 | actionmailbox (6.0.3.6)
9 | actionpack (= 6.0.3.6)
10 | activejob (= 6.0.3.6)
11 | activerecord (= 6.0.3.6)
12 | activestorage (= 6.0.3.6)
13 | activesupport (= 6.0.3.6)
14 | mail (>= 2.7.1)
15 | actionmailer (6.0.3.6)
16 | actionpack (= 6.0.3.6)
17 | actionview (= 6.0.3.6)
18 | activejob (= 6.0.3.6)
19 | mail (~> 2.5, >= 2.5.4)
20 | rails-dom-testing (~> 2.0)
21 | actionpack (6.0.3.6)
22 | actionview (= 6.0.3.6)
23 | activesupport (= 6.0.3.6)
24 | rack (~> 2.0, >= 2.0.8)
25 | rack-test (>= 0.6.3)
26 | rails-dom-testing (~> 2.0)
27 | rails-html-sanitizer (~> 1.0, >= 1.2.0)
28 | actiontext (6.0.3.6)
29 | actionpack (= 6.0.3.6)
30 | activerecord (= 6.0.3.6)
31 | activestorage (= 6.0.3.6)
32 | activesupport (= 6.0.3.6)
33 | nokogiri (>= 1.8.5)
34 | actionview (6.0.3.6)
35 | activesupport (= 6.0.3.6)
36 | builder (~> 3.1)
37 | erubi (~> 1.4)
38 | rails-dom-testing (~> 2.0)
39 | rails-html-sanitizer (~> 1.1, >= 1.2.0)
40 | activejob (6.0.3.6)
41 | activesupport (= 6.0.3.6)
42 | globalid (>= 0.3.6)
43 | activemodel (6.0.3.6)
44 | activesupport (= 6.0.3.6)
45 | activerecord (6.0.3.6)
46 | activemodel (= 6.0.3.6)
47 | activesupport (= 6.0.3.6)
48 | activestorage (6.0.3.6)
49 | actionpack (= 6.0.3.6)
50 | activejob (= 6.0.3.6)
51 | activerecord (= 6.0.3.6)
52 | marcel (~> 1.0.0)
53 | activesupport (6.0.3.6)
54 | concurrent-ruby (~> 1.0, >= 1.0.2)
55 | i18n (>= 0.7, < 2)
56 | minitest (~> 5.1)
57 | tzinfo (~> 1.1)
58 | zeitwerk (~> 2.2, >= 2.2.2)
59 | addressable (2.7.0)
60 | public_suffix (>= 2.0.2, < 5.0)
61 | ast (2.4.2)
62 | bindex (0.8.1)
63 | builder (3.2.4)
64 | byebug (11.1.3)
65 | capybara (2.13.0)
66 | addressable
67 | mime-types (>= 1.16)
68 | nokogiri (>= 1.3.3)
69 | rack (>= 1.0.0)
70 | rack-test (>= 0.5.4)
71 | xpath (~> 2.0)
72 | childprocess (3.0.0)
73 | coffee-rails (5.0.0)
74 | coffee-script (>= 2.2.0)
75 | railties (>= 5.2.0)
76 | coffee-script (2.4.1)
77 | coffee-script-source
78 | execjs
79 | coffee-script-source (1.12.2)
80 | concurrent-ruby (1.1.8)
81 | crass (1.0.6)
82 | diff-lcs (1.4.4)
83 | erubi (1.10.0)
84 | execjs (2.7.0)
85 | ffi (1.15.0)
86 | globalid (0.4.2)
87 | activesupport (>= 4.2.0)
88 | i18n (1.8.10)
89 | concurrent-ruby (~> 1.0)
90 | jbuilder (2.9.1)
91 | activesupport (>= 4.2.0)
92 | listen (3.1.5)
93 | rb-fsevent (~> 0.9, >= 0.9.4)
94 | rb-inotify (~> 0.9, >= 0.9.7)
95 | ruby_dep (~> 1.2)
96 | loofah (2.9.1)
97 | crass (~> 1.0.2)
98 | nokogiri (>= 1.5.9)
99 | mail (2.7.1)
100 | mini_mime (>= 0.1.1)
101 | marcel (1.0.1)
102 | method_source (1.0.0)
103 | mime-types (3.3.1)
104 | mime-types-data (~> 3.2015)
105 | mime-types-data (3.2021.0225)
106 | mini_mime (1.1.0)
107 | mini_portile2 (2.5.0)
108 | minitest (5.14.4)
109 | nio4r (2.5.7)
110 | nokogiri (1.11.3)
111 | mini_portile2 (~> 2.5.0)
112 | racc (~> 1.4)
113 | parallel (1.20.1)
114 | parser (3.0.1.0)
115 | ast (~> 2.4.1)
116 | pg (0.21.0)
117 | public_suffix (4.0.6)
118 | puma (3.12.6)
119 | racc (1.5.2)
120 | rack (2.2.3)
121 | rack-test (1.1.0)
122 | rack (>= 1.0, < 3)
123 | rails (6.0.3.6)
124 | actioncable (= 6.0.3.6)
125 | actionmailbox (= 6.0.3.6)
126 | actionmailer (= 6.0.3.6)
127 | actionpack (= 6.0.3.6)
128 | actiontext (= 6.0.3.6)
129 | actionview (= 6.0.3.6)
130 | activejob (= 6.0.3.6)
131 | activemodel (= 6.0.3.6)
132 | activerecord (= 6.0.3.6)
133 | activestorage (= 6.0.3.6)
134 | activesupport (= 6.0.3.6)
135 | bundler (>= 1.3.0)
136 | railties (= 6.0.3.6)
137 | sprockets-rails (>= 2.0.0)
138 | rails-dom-testing (2.0.3)
139 | activesupport (>= 4.2.0)
140 | nokogiri (>= 1.6)
141 | rails-html-sanitizer (1.3.0)
142 | loofah (~> 2.3)
143 | railties (6.0.3.6)
144 | actionpack (= 6.0.3.6)
145 | activesupport (= 6.0.3.6)
146 | method_source
147 | rake (>= 0.8.7)
148 | thor (>= 0.20.3, < 2.0)
149 | rainbow (3.0.0)
150 | rake (13.0.3)
151 | rb-fsevent (0.10.4)
152 | rb-inotify (0.10.1)
153 | ffi (~> 1.0)
154 | regexp_parser (2.1.1)
155 | rexml (3.2.5)
156 | rspec-core (3.10.1)
157 | rspec-support (~> 3.10.0)
158 | rspec-expectations (3.10.1)
159 | diff-lcs (>= 1.2.0, < 2.0)
160 | rspec-support (~> 3.10.0)
161 | rspec-mocks (3.10.2)
162 | diff-lcs (>= 1.2.0, < 2.0)
163 | rspec-support (~> 3.10.0)
164 | rspec-rails (4.0.0.beta3)
165 | actionpack (>= 4.2)
166 | activesupport (>= 4.2)
167 | railties (>= 4.2)
168 | rspec-core (~> 3.8)
169 | rspec-expectations (~> 3.8)
170 | rspec-mocks (~> 3.8)
171 | rspec-support (~> 3.8)
172 | rspec-support (3.10.2)
173 | rspec_junit_formatter (0.4.1)
174 | rspec-core (>= 2, < 4, != 2.12.0)
175 | rubocop (0.89.1)
176 | parallel (~> 1.10)
177 | parser (>= 2.7.1.1)
178 | rainbow (>= 2.2.2, < 4.0)
179 | regexp_parser (>= 1.7)
180 | rexml
181 | rubocop-ast (>= 0.3.0, < 1.0)
182 | ruby-progressbar (~> 1.7)
183 | unicode-display_width (>= 1.4.0, < 2.0)
184 | rubocop-ast (0.8.0)
185 | parser (>= 2.7.1.5)
186 | ruby-progressbar (1.11.0)
187 | ruby_dep (1.5.0)
188 | rubyzip (2.3.0)
189 | sass (3.7.4)
190 | sass-listen (~> 4.0.0)
191 | sass-listen (4.0.0)
192 | rb-fsevent (~> 0.9, >= 0.9.4)
193 | rb-inotify (~> 0.9, >= 0.9.7)
194 | sass-rails (5.0.8)
195 | railties (>= 5.2.0)
196 | sass (~> 3.1)
197 | sprockets (>= 2.8, < 4.0)
198 | sprockets-rails (>= 2.0, < 4.0)
199 | tilt (>= 1.1, < 3)
200 | selenium-webdriver (3.142.7)
201 | childprocess (>= 0.5, < 4.0)
202 | rubyzip (>= 1.2.2)
203 | spring (2.0.2)
204 | activesupport (>= 4.2)
205 | spring-watcher-listen (2.0.1)
206 | listen (>= 2.7, < 4.0)
207 | spring (>= 1.2, < 3.0)
208 | sprockets (3.7.2)
209 | concurrent-ruby (~> 1.0)
210 | rack (> 1, < 3)
211 | sprockets-rails (3.2.2)
212 | actionpack (>= 4.0)
213 | activesupport (>= 4.0)
214 | sprockets (>= 3.0.0)
215 | thor (1.1.0)
216 | thread_safe (0.3.6)
217 | tilt (2.0.10)
218 | turbolinks (5.2.1)
219 | turbolinks-source (~> 5.2)
220 | turbolinks-source (5.2.0)
221 | tzinfo (1.2.9)
222 | thread_safe (~> 0.1)
223 | uglifier (4.2.0)
224 | execjs (>= 0.3.0, < 3)
225 | unicode-display_width (1.7.0)
226 | web-console (4.1.0)
227 | actionview (>= 6.0.0)
228 | activemodel (>= 6.0.0)
229 | bindex (>= 0.4.0)
230 | railties (>= 6.0.0)
231 | websocket-driver (0.7.3)
232 | websocket-extensions (>= 0.1.0)
233 | websocket-extensions (0.1.5)
234 | xpath (2.1.0)
235 | nokogiri (~> 1.3)
236 | zeitwerk (2.4.2)
237 |
238 | PLATFORMS
239 | ruby
240 |
241 | DEPENDENCIES
242 | byebug
243 | capybara (~> 2.13.0)
244 | coffee-rails (~> 5.0.0)
245 | jbuilder (~> 2.9.1)
246 | listen (>= 3.0.5, < 3.2)
247 | pg (~> 0.18)
248 | puma (~> 3.7)
249 | rails (~> 6.0.1)
250 | rspec-rails (= 4.0.0.beta3)
251 | rspec_junit_formatter
252 | rubocop (~> 0.89.0)
253 | sass-rails (~> 5.0.7)
254 | selenium-webdriver
255 | spring (~> 2.0.2)
256 | spring-watcher-listen (~> 2.0.0)
257 | turbolinks (~> 5)
258 | tzinfo-data
259 | uglifier (>= 1.3.0)
260 | web-console (>= 3.7.0)
261 |
262 | RUBY VERSION
263 | ruby 2.7.5p203
264 |
265 | BUNDLED WITH
266 | 2.1.4
267 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # CircleCI Demo Application: Ruby on Rails [](https://circleci.com/gh/CircleCI-Public/circleci-demo-ruby-rails)
2 |
3 | This is an example application showcasing how to run a Ruby on Rails app on CircleCI 2.0 using 2.1 configuration.
4 |
5 | You can follow along with this project by reading the [documentation](https://circleci.com/docs/2.0/language-ruby/).
6 |
7 | ## Local Development
8 |
9 | ### set environment
10 |
11 | 1. Create your `app.env` file from the example file: `cp .env.app.testing app.env`
12 | ```
13 | POSTGRES_HOST=db
14 | PGUSER=postgres
15 | PGPASSWORD=postgres
16 | RAILS_ENV=development
17 | ```
18 |
19 | 2. Create your `db.env` file from the example file: `cp .env.db.testing db.env`
20 | ```
21 | POSTGRES_USER=postgres
22 | POSTGRES_PASSWORD=postgres
23 | POSTGRES_DB=rails_blog_dev
24 | ```
25 |
26 | ### Starting the application
27 |
28 | ```
29 | $ docker-compose build
30 | $ docker-compose up
31 | $ docker-compose run web bundle exec rails db:migrate:reset
32 | ```
33 |
34 | ### reset the database
35 |
36 | ```
37 | $ docker-compose up db
38 | $ docker-compose run web bundle exec rails db:migrate:reset
39 | ```
40 |
41 | Navigate to http://localhost:3000
42 |
43 | ## License
44 |
45 | Copyright (c) 2019 CircleCI
46 |
47 | Distributed under the MIT License. See the file COPYING.
48 |
--------------------------------------------------------------------------------
/Rakefile:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | # Add your own tasks in files placed in lib/tasks ending in .rake,
4 | # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
5 |
6 | require_relative 'config/application'
7 |
8 | Rails.application.load_tasks
9 |
--------------------------------------------------------------------------------
/app/assets/config/manifest.js:
--------------------------------------------------------------------------------
1 | //= link_tree ../images
2 | //= link_directory ../javascripts .js
3 | //= link_directory ../stylesheets .css
4 |
--------------------------------------------------------------------------------
/app/assets/images/.keep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CircleCI-Public/circleci-demo-ruby-rails/2033c5f8da3010941127e0f9133925bd8efc7a79/app/assets/images/.keep
--------------------------------------------------------------------------------
/app/assets/javascripts/application.js:
--------------------------------------------------------------------------------
1 | // This is a manifest file that'll be compiled into application.js, which will include all the files
2 | // listed below.
3 | //
4 | // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, or any plugin's
5 | // vendor/assets/javascripts directory can be referenced here using a relative path.
6 | //
7 | // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
8 | // compiled file. JavaScript code in this file should be added after the last require_* statement.
9 | //
10 | // Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
11 | // about supported directives.
12 | //
13 | //= require rails-ujs
14 | //= require turbolinks
15 | //= require_tree .
16 |
--------------------------------------------------------------------------------
/app/assets/javascripts/cable.js:
--------------------------------------------------------------------------------
1 | // Action Cable provides the framework to deal with WebSockets in Rails.
2 | // You can generate new channels where WebSocket features live using the `rails generate channel` command.
3 | //
4 | //= require action_cable
5 | //= require_self
6 | //= require_tree ./channels
7 |
8 | (function() {
9 | this.App || (this.App = {});
10 |
11 | App.cable = ActionCable.createConsumer();
12 |
13 | }).call(this);
14 |
--------------------------------------------------------------------------------
/app/assets/javascripts/channels/.keep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CircleCI-Public/circleci-demo-ruby-rails/2033c5f8da3010941127e0f9133925bd8efc7a79/app/assets/javascripts/channels/.keep
--------------------------------------------------------------------------------
/app/assets/javascripts/posts.coffee:
--------------------------------------------------------------------------------
1 | # Place all the behaviors and hooks related to the matching controller here.
2 | # All this logic will automatically be available in application.js.
3 | # You can use CoffeeScript in this file: http://coffeescript.org/
4 |
--------------------------------------------------------------------------------
/app/assets/javascripts/welcome.coffee:
--------------------------------------------------------------------------------
1 | # Place all the behaviors and hooks related to the matching controller here.
2 | # All this logic will automatically be available in application.js.
3 | # You can use CoffeeScript in this file: http://coffeescript.org/
4 |
--------------------------------------------------------------------------------
/app/assets/stylesheets/application.css:
--------------------------------------------------------------------------------
1 | /*
2 | * This is a manifest file that'll be compiled into application.css, which will include all the files
3 | * listed below.
4 | *
5 | * Any CSS and SCSS file within this directory, lib/assets/stylesheets, or any plugin's
6 | * vendor/assets/stylesheets directory can be referenced here using a relative path.
7 | *
8 | * You're free to add application-wide styles to this file and they'll appear at the bottom of the
9 | * compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS
10 | * files in this directory. Styles in this file should be added after the last require_* statement.
11 | * It is generally better to create a new file per style scope.
12 | *
13 | *= require_tree .
14 | *= require_self
15 | */
16 |
--------------------------------------------------------------------------------
/app/assets/stylesheets/posts.scss:
--------------------------------------------------------------------------------
1 | // Place all the styles related to the posts controller here.
2 | // They will automatically be included in application.css.
3 | // You can use Sass (SCSS) here: http://sass-lang.com/
4 |
--------------------------------------------------------------------------------
/app/assets/stylesheets/scaffolds.scss:
--------------------------------------------------------------------------------
1 | body {
2 | background-color: #fff;
3 | color: #333;
4 | margin: 33px;
5 | font-family: verdana, arial, helvetica, sans-serif;
6 | font-size: 13px;
7 | line-height: 18px;
8 | }
9 |
10 | p, ol, ul, td {
11 | font-family: verdana, arial, helvetica, sans-serif;
12 | font-size: 13px;
13 | line-height: 18px;
14 | }
15 |
16 | pre {
17 | background-color: #eee;
18 | padding: 10px;
19 | font-size: 11px;
20 | }
21 |
22 | a {
23 | color: #000;
24 |
25 | &:visited {
26 | color: #666;
27 | }
28 |
29 | &:hover {
30 | color: #fff;
31 | background-color: #000;
32 | }
33 | }
34 |
35 | th {
36 | padding-bottom: 5px;
37 | }
38 |
39 | td {
40 | padding: 0 5px 7px;
41 | }
42 |
43 | div {
44 | &.field, &.actions {
45 | margin-bottom: 10px;
46 | }
47 | }
48 |
49 | #notice {
50 | color: green;
51 | }
52 |
53 | .field_with_errors {
54 | padding: 2px;
55 | background-color: red;
56 | display: table;
57 | }
58 |
59 | #error_explanation {
60 | width: 450px;
61 | border: 2px solid red;
62 | padding: 7px 7px 0;
63 | margin-bottom: 20px;
64 | background-color: #f0f0f0;
65 |
66 | h2 {
67 | text-align: left;
68 | font-weight: bold;
69 | padding: 5px 5px 5px 15px;
70 | font-size: 12px;
71 | margin: -7px -7px 0;
72 | background-color: #c00;
73 | color: #fff;
74 | }
75 |
76 | ul li {
77 | font-size: 12px;
78 | list-style: square;
79 | }
80 | }
81 |
82 | label {
83 | display: block;
84 | }
85 |
--------------------------------------------------------------------------------
/app/assets/stylesheets/welcome.scss:
--------------------------------------------------------------------------------
1 | // Place all the styles related to the Welcome controller here.
2 | // They will automatically be included in application.css.
3 | // You can use Sass (SCSS) here: http://sass-lang.com/
4 |
--------------------------------------------------------------------------------
/app/channels/application_cable/channel.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | module ApplicationCable
4 | class Channel < ActionCable::Channel::Base
5 | end
6 | end
7 |
--------------------------------------------------------------------------------
/app/channels/application_cable/connection.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | module ApplicationCable
4 | class Connection < ActionCable::Connection::Base
5 | end
6 | end
7 |
--------------------------------------------------------------------------------
/app/controllers/application_controller.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | class ApplicationController < ActionController::Base
4 | protect_from_forgery with: :exception
5 | end
6 |
--------------------------------------------------------------------------------
/app/controllers/concerns/.keep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CircleCI-Public/circleci-demo-ruby-rails/2033c5f8da3010941127e0f9133925bd8efc7a79/app/controllers/concerns/.keep
--------------------------------------------------------------------------------
/app/controllers/posts_controller.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | class PostsController < ApplicationController
4 | before_action :set_post, only: %i[show edit update destroy]
5 |
6 | # GET /posts
7 | # GET /posts.json
8 | def index
9 | @posts = Post.all
10 | end
11 |
12 | # GET /posts/1
13 | # GET /posts/1.json
14 | def show; end
15 |
16 | # GET /posts/new
17 | def new
18 | @post = Post.new
19 | end
20 |
21 | # GET /posts/1/edit
22 | def edit; end
23 |
24 | # POST /posts
25 | # POST /posts.json
26 | def create
27 | @post = Post.new(post_params)
28 |
29 | respond_to do |format|
30 | if @post.save
31 | format.html { redirect_to @post, notice: 'Post was successfully created.' }
32 | format.json { render :show, status: :created, location: @post }
33 | else
34 | format.html { render :new }
35 | format.json { render json: @post.errors, status: :unprocessable_entity }
36 | end
37 | end
38 | end
39 |
40 | # PATCH/PUT /posts/1
41 | # PATCH/PUT /posts/1.json
42 | def update
43 | respond_to do |format|
44 | if @post.update(post_params)
45 | format.html { redirect_to @post, notice: 'Post was successfully updated.' }
46 | format.json { render :show, status: :ok, location: @post }
47 | else
48 | format.html { render :edit }
49 | format.json { render json: @post.errors, status: :unprocessable_entity }
50 | end
51 | end
52 | end
53 |
54 | # DELETE /posts/1
55 | # DELETE /posts/1.json
56 | def destroy
57 | @post.destroy
58 | respond_to do |format|
59 | format.html { redirect_to posts_url, notice: 'Post was successfully destroyed.' }
60 | format.json { head :no_content }
61 | end
62 | end
63 |
64 | private
65 |
66 | # Use callbacks to share common setup or constraints between actions.
67 | def set_post
68 | @post = Post.find(params[:id])
69 | end
70 |
71 | # Never trust parameters from the scary internet, only allow the white list through.
72 | def post_params
73 | params.require(:post).permit(:title, :body, :published)
74 | end
75 | end
76 |
--------------------------------------------------------------------------------
/app/controllers/welcome_controller.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | class WelcomeController < ApplicationController
4 | def index; end
5 | end
6 |
--------------------------------------------------------------------------------
/app/helpers/application_helper.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | module ApplicationHelper
4 | end
5 |
--------------------------------------------------------------------------------
/app/helpers/posts_helper.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | module PostsHelper
4 | end
5 |
--------------------------------------------------------------------------------
/app/helpers/welcome_helper.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | module WelcomeHelper
4 | end
5 |
--------------------------------------------------------------------------------
/app/jobs/application_job.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | class ApplicationJob < ActiveJob::Base
4 | end
5 |
--------------------------------------------------------------------------------
/app/mailers/application_mailer.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | class ApplicationMailer < ActionMailer::Base
4 | default from: 'from@example.com'
5 | layout 'mailer'
6 | end
7 |
--------------------------------------------------------------------------------
/app/models/application_record.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | class ApplicationRecord < ActiveRecord::Base
4 | self.abstract_class = true
5 | end
6 |
--------------------------------------------------------------------------------
/app/models/concerns/.keep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CircleCI-Public/circleci-demo-ruby-rails/2033c5f8da3010941127e0f9133925bd8efc7a79/app/models/concerns/.keep
--------------------------------------------------------------------------------
/app/models/post.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | class Post < ApplicationRecord
4 | validates_presence_of :title
5 | validates_presence_of :body
6 | end
7 |
--------------------------------------------------------------------------------
/app/views/layouts/application.html.erb:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Blog
5 | <%= csrf_meta_tags %>
6 |
7 | <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>
8 | <%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %>
9 |
10 |
11 |
12 | <%= yield %>
13 |
14 |
15 |
--------------------------------------------------------------------------------
/app/views/layouts/mailer.html.erb:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
8 |
9 |
10 |
11 | <%= yield %>
12 |
13 |
14 |
--------------------------------------------------------------------------------
/app/views/layouts/mailer.text.erb:
--------------------------------------------------------------------------------
1 | <%= yield %>
2 |
--------------------------------------------------------------------------------
/app/views/posts/_form.html.erb:
--------------------------------------------------------------------------------
1 | <%= form_with(model: post, local: true) do |form| %>
2 | <% if post.errors.any? %>
3 |
4 |
<%= pluralize(post.errors.count, "error") %> prohibited this post from being saved:
5 |
6 |
7 | <% post.errors.full_messages.each do |message| %>
8 | - <%= message %>
9 | <% end %>
10 |
11 |
12 | <% end %>
13 |
14 |
15 | <%= form.label :title %>
16 | <%= form.text_field :title, id: :post_title %>
17 |
18 |
19 |
20 | <%= form.label :body %>
21 | <%= form.text_area :body, id: :post_body %>
22 |
23 |
24 |
25 | <%= form.label :published %>
26 | <%= form.check_box :published, id: :post_published %>
27 |
28 |
29 |
30 | <%= form.submit %>
31 |
32 | <% end %>
33 |
--------------------------------------------------------------------------------
/app/views/posts/_post.json.jbuilder:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | json.extract! post, :id, :title, :body, :published, :created_at, :updated_at
4 | json.url post_url(post, format: :json)
5 |
--------------------------------------------------------------------------------
/app/views/posts/edit.html.erb:
--------------------------------------------------------------------------------
1 | Editing Post
2 |
3 | <%= render 'form', post: @post %>
4 |
5 | <%= link_to 'Show', @post %> |
6 | <%= link_to 'Back', posts_path %>
7 |
--------------------------------------------------------------------------------
/app/views/posts/index.html.erb:
--------------------------------------------------------------------------------
1 | <%= notice %>
2 |
3 | Posts
4 |
5 |
6 |
7 |
8 | Title |
9 | Body |
10 | Published |
11 | |
12 |
13 |
14 |
15 |
16 | <% @posts.each do |post| %>
17 |
18 | <%= post.title %> |
19 | <%= post.body %> |
20 | <%= post.published %> |
21 | <%= link_to 'Show', post %> |
22 | <%= link_to 'Edit', edit_post_path(post) %> |
23 | <%= link_to 'Destroy', post, method: :delete, data: { confirm: 'Are you sure?' } %> |
24 |
25 | <% end %>
26 |
27 |
28 |
29 |
30 |
31 | <%= link_to 'New Post', new_post_path %>
32 |
--------------------------------------------------------------------------------
/app/views/posts/index.json.jbuilder:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | json.array! @posts, partial: 'posts/post', as: :post
4 |
--------------------------------------------------------------------------------
/app/views/posts/new.html.erb:
--------------------------------------------------------------------------------
1 | New Post
2 |
3 | <%= render 'form', post: @post %>
4 |
5 | <%= link_to 'Back', posts_path %>
6 |
--------------------------------------------------------------------------------
/app/views/posts/show.html.erb:
--------------------------------------------------------------------------------
1 | <%= notice %>
2 |
3 |
4 | Title:
5 | <%= @post.title %>
6 |
7 |
8 |
9 | Body:
10 | <%= @post.body %>
11 |
12 |
13 |
14 | Published:
15 | <%= @post.published %>
16 |
17 |
18 | <%= link_to 'Edit', edit_post_path(@post) %> |
19 | <%= link_to 'Back', posts_path %>
20 |
--------------------------------------------------------------------------------
/app/views/posts/show.json.jbuilder:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | json.partial! 'posts/post', post: @post
4 |
--------------------------------------------------------------------------------
/app/views/welcome/index.html.erb:
--------------------------------------------------------------------------------
1 | Hello, Rails!
2 |
--------------------------------------------------------------------------------
/bin/bundle:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 | ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
3 | load Gem.bin_path('bundler', 'bundle')
4 |
--------------------------------------------------------------------------------
/bin/rails:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 | begin
3 | load File.expand_path('../spring', __FILE__)
4 | rescue LoadError => e
5 | raise unless e.message.include?('spring')
6 | end
7 | APP_PATH = File.expand_path('../config/application', __dir__)
8 | require_relative '../config/boot'
9 | require 'rails/commands'
10 |
--------------------------------------------------------------------------------
/bin/rake:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 | begin
3 | load File.expand_path('../spring', __FILE__)
4 | rescue LoadError => e
5 | raise unless e.message.include?('spring')
6 | end
7 | require_relative '../config/boot'
8 | require 'rake'
9 | Rake.application.run
10 |
--------------------------------------------------------------------------------
/bin/setup:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 | require 'pathname'
3 | require 'fileutils'
4 | include FileUtils
5 |
6 | # path to your application root.
7 | APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)
8 |
9 | def system!(*args)
10 | system(*args) || abort("\n== Command #{args} failed ==")
11 | end
12 |
13 | chdir APP_ROOT do
14 | # This script is a starting point to setup your application.
15 | # Add necessary setup steps to this file.
16 |
17 | puts '== Installing dependencies =='
18 | system! 'gem install bundler --conservative'
19 | system('bundle check') || system!('bundle install')
20 |
21 | # Install JavaScript dependencies if using Yarn
22 | # system('bin/yarn')
23 |
24 |
25 | # puts "\n== Copying sample files =="
26 | # unless File.exist?('config/database.yml')
27 | # cp 'config/database.yml.sample', 'config/database.yml'
28 | # end
29 |
30 | puts "\n== Preparing database =="
31 | system! 'bin/rails db:setup'
32 |
33 | puts "\n== Removing old logs and tempfiles =="
34 | system! 'bin/rails log:clear tmp:clear'
35 |
36 | puts "\n== Restarting application server =="
37 | system! 'bin/rails restart'
38 | end
39 |
--------------------------------------------------------------------------------
/bin/spring:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 |
3 | # This file loads spring without using Bundler, in order to be fast.
4 | # It gets overwritten when you run the `spring binstub` command.
5 |
6 | unless defined?(Spring)
7 | require 'rubygems'
8 | require 'bundler'
9 |
10 | lockfile = Bundler::LockfileParser.new(Bundler.default_lockfile.read)
11 | spring = lockfile.specs.detect { |spec| spec.name == "spring" }
12 | if spring
13 | Gem.use_paths Gem.dir, Bundler.bundle_path.to_s, *Gem.path
14 | gem 'spring', spring.version
15 | require 'spring/binstub'
16 | end
17 | end
18 |
--------------------------------------------------------------------------------
/bin/update:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 | require 'pathname'
3 | require 'fileutils'
4 | include FileUtils
5 |
6 | # path to your application root.
7 | APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)
8 |
9 | def system!(*args)
10 | system(*args) || abort("\n== Command #{args} failed ==")
11 | end
12 |
13 | chdir APP_ROOT do
14 | # This script is a way to update your development environment automatically.
15 | # Add necessary update steps to this file.
16 |
17 | puts '== Installing dependencies =='
18 | system! 'gem install bundler --conservative'
19 | system('bundle check') || system!('bundle install')
20 |
21 | puts "\n== Updating database =="
22 | system! 'bin/rails db:migrate'
23 |
24 | puts "\n== Removing old logs and tempfiles =="
25 | system! 'bin/rails log:clear tmp:clear'
26 |
27 | puts "\n== Restarting application server =="
28 | system! 'bin/rails restart'
29 | end
30 |
--------------------------------------------------------------------------------
/bin/yarn:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 | VENDOR_PATH = File.expand_path('..', __dir__)
3 | Dir.chdir(VENDOR_PATH) do
4 | begin
5 | exec "yarnpkg #{ARGV.join(" ")}"
6 | rescue Errno::ENOENT
7 | $stderr.puts "Yarn executable was not detected in the system."
8 | $stderr.puts "Download Yarn at https://yarnpkg.com/en/docs/install"
9 | exit 1
10 | end
11 | end
12 |
--------------------------------------------------------------------------------
/config.ru:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | # This file is used by Rack-based servers to start the application.
4 |
5 | require_relative 'config/environment'
6 |
7 | run Rails.application
8 |
--------------------------------------------------------------------------------
/config/application.rb:
--------------------------------------------------------------------------------
1 | require_relative 'boot'
2 |
3 | require 'rails/all'
4 |
5 | # Require the gems listed in Gemfile, including any gems
6 | # you've limited to :test, :development, or :production.
7 | Bundler.require(*Rails.groups)
8 |
9 | module Blog
10 | class Application < Rails::Application
11 | # Initialize configuration defaults for originally generated Rails version.
12 | config.load_defaults 5.1
13 |
14 | # Settings in config/environments/* take precedence over those specified here.
15 | # Application configuration should go into files in config/initializers
16 | # -- all .rb files in that directory are automatically loaded.
17 | end
18 | end
19 |
--------------------------------------------------------------------------------
/config/boot.rb:
--------------------------------------------------------------------------------
1 | ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
2 |
3 | require 'bundler/setup' # Set up gems listed in the Gemfile.
4 |
--------------------------------------------------------------------------------
/config/cable.yml:
--------------------------------------------------------------------------------
1 | development:
2 | adapter: async
3 |
4 | test:
5 | adapter: async
6 |
7 | production:
8 | adapter: redis
9 | url: redis://localhost:6379/1
10 | channel_prefix: blog_production
11 |
--------------------------------------------------------------------------------
/config/database.yml:
--------------------------------------------------------------------------------
1 | # PostgreSQL. Versions 9.1 and up are supported.
2 | #
3 | # Install the pg driver:
4 | # gem install pg
5 | # On OS X with Homebrew:
6 | # gem install pg -- --with-pg-config=/usr/local/bin/pg_config
7 | # On OS X with MacPorts:
8 | # gem install pg -- --with-pg-config=/opt/local/lib/postgresql84/bin/pg_config
9 | # On Windows:
10 | # gem install pg
11 | # Choose the win32 build.
12 | # Install PostgreSQL and put its /bin directory on your path.
13 | #
14 | # Configure Using Gemfile
15 | # gem 'pg'
16 | #
17 | default: &default
18 | adapter: postgresql
19 | encoding: unicode
20 | host: <%= ENV.fetch("POSTGRES_HOST", 'localhost') %>
21 | user: postgres
22 | password: postgres
23 | # For details on connection pooling, see Rails configuration guide
24 | # http://guides.rubyonrails.org/configuring.html#database-pooling
25 | pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
26 |
27 | development:
28 | <<: *default
29 | database: rails_blog_dev
30 |
31 | # The specified database role being used to connect to postgres.
32 | # To create additional roles in postgres see `$ createuser --help`.
33 | # When left blank, postgres will use the default role. This is
34 | # the same name as the operating system user that initialized the database.
35 | #username: zomg
36 |
37 | # The password associated with the postgres role (username).
38 | #password:
39 |
40 | # Connect on a TCP socket. Omitted by default since the client uses a
41 | # domain socket that doesn't need configuration. Windows does not have
42 | # domain sockets, so uncomment these lines.
43 | #host: localhost
44 |
45 | # The TCP port the server listens on. Defaults to 5432.
46 | # If your server runs on a different port number, change accordingly.
47 | #port: 5432
48 |
49 | # Schema search path. The server defaults to $user,public
50 | #schema_search_path: myapp,sharedapp,public
51 |
52 | # Minimum log levels, in increasing order:
53 | # debug5, debug4, debug3, debug2, debug1,
54 | # log, notice, warning, error, fatal, and panic
55 | # Defaults to warning.
56 | #min_messages: notice
57 |
58 | # Warning: The database defined as "test" will be erased and
59 | # re-generated from your development database when you run "rake".
60 | # Do not set this db to the same as development or production.
61 | test:
62 | <<: *default
63 | user: <%= ENV.fetch("PGUSER") %>
64 | user: <%= ENV.fetch("PGPASSWORD") %>
65 | database: rails_blog_test
66 |
67 | # As with config/secrets.yml, you never want to store sensitive information,
68 | # like your database password, in your source code. If your source code is
69 | # ever seen by anyone, they now have access to your database.
70 | #
71 | # Instead, provide the password as a unix environment variable when you boot
72 | # the app. Read http://guides.rubyonrails.org/configuring.html#configuring-a-database
73 | # for a full rundown on how to provide these environment variables in a
74 | # production deployment.
75 | #
76 | # On Heroku and other platform providers, you may have a full connection URL
77 | # available as an environment variable. For example:
78 | #
79 | # DATABASE_URL="postgres://myuser:mypass@localhost/somedatabase"
80 | #
81 | # You can use this database configuration with:
82 | #
83 | # production:
84 | # url: <%= ENV['DATABASE_URL'] %>
85 | #
86 | production:
87 | <<: *default
88 | database: zomg_production
89 | username: zomg
90 | password: <%= ENV['ZOMG_DATABASE_PASSWORD'] %>
91 |
--------------------------------------------------------------------------------
/config/environment.rb:
--------------------------------------------------------------------------------
1 | # Load the Rails application.
2 | require_relative 'application'
3 |
4 | # Initialize the Rails application.
5 | Rails.application.initialize!
6 |
--------------------------------------------------------------------------------
/config/environments/development.rb:
--------------------------------------------------------------------------------
1 | Rails.application.configure do
2 | # Settings specified here will take precedence over those in config/application.rb.
3 |
4 | # In the development environment your application's code is reloaded on
5 | # every request. This slows down response time but is perfect for development
6 | # since you don't have to restart the web server when you make code changes.
7 | config.cache_classes = false
8 |
9 | # Do not eager load code on boot.
10 | config.eager_load = false
11 |
12 | # Show full error reports.
13 | config.consider_all_requests_local = true
14 |
15 | # Enable/disable caching. By default caching is disabled.
16 | if Rails.root.join('tmp/caching-dev.txt').exist?
17 | config.action_controller.perform_caching = true
18 |
19 | config.cache_store = :memory_store
20 | config.public_file_server.headers = {
21 | 'Cache-Control' => "public, max-age=#{2.days.seconds.to_i}"
22 | }
23 | else
24 | config.action_controller.perform_caching = false
25 |
26 | config.cache_store = :null_store
27 | end
28 |
29 | # Don't care if the mailer can't send.
30 | config.action_mailer.raise_delivery_errors = false
31 |
32 | config.action_mailer.perform_caching = false
33 |
34 | # Print deprecation notices to the Rails logger.
35 | config.active_support.deprecation = :log
36 |
37 | # Raise an error on page load if there are pending migrations.
38 | config.active_record.migration_error = :page_load
39 |
40 | # Debug mode disables concatenation and preprocessing of assets.
41 | # This option may cause significant delays in view rendering with a large
42 | # number of complex assets.
43 | config.assets.debug = true
44 |
45 | # Suppress logger output for asset requests.
46 | config.assets.quiet = true
47 |
48 | # Raises error for missing translations
49 | # config.action_view.raise_on_missing_translations = true
50 |
51 | # Use an evented file watcher to asynchronously detect changes in source code,
52 | # routes, locales, etc. This feature depends on the listen gem.
53 | config.file_watcher = ActiveSupport::EventedFileUpdateChecker
54 | end
55 |
--------------------------------------------------------------------------------
/config/environments/production.rb:
--------------------------------------------------------------------------------
1 | Rails.application.configure do
2 | # Settings specified here will take precedence over those in config/application.rb.
3 |
4 | # Code is not reloaded between requests.
5 | config.cache_classes = true
6 |
7 | # Eager load code on boot. This eager loads most of Rails and
8 | # your application in memory, allowing both threaded web servers
9 | # and those relying on copy on write to perform better.
10 | # Rake tasks automatically ignore this option for performance.
11 | config.eager_load = true
12 |
13 | # Full error reports are disabled and caching is turned on.
14 | config.consider_all_requests_local = false
15 | config.action_controller.perform_caching = true
16 |
17 | # Attempt to read encrypted secrets from `config/secrets.yml.enc`.
18 | # Requires an encryption key in `ENV["RAILS_MASTER_KEY"]` or
19 | # `config/secrets.yml.key`.
20 | config.read_encrypted_secrets = true
21 |
22 | # Disable serving static files from the `/public` folder by default since
23 | # Apache or NGINX already handles this.
24 | config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present?
25 |
26 | # Compress JavaScripts and CSS.
27 | config.assets.js_compressor = :uglifier
28 | # config.assets.css_compressor = :sass
29 |
30 | # Do not fallback to assets pipeline if a precompiled asset is missed.
31 | config.assets.compile = false
32 |
33 | # `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb
34 |
35 | # Enable serving of images, stylesheets, and JavaScripts from an asset server.
36 | # config.action_controller.asset_host = 'http://assets.example.com'
37 |
38 | # Specifies the header that your server uses for sending files.
39 | # config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache
40 | # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX
41 |
42 | # Mount Action Cable outside main process or domain
43 | # config.action_cable.mount_path = nil
44 | # config.action_cable.url = 'wss://example.com/cable'
45 | # config.action_cable.allowed_request_origins = [ 'http://example.com', /http:\/\/example.*/ ]
46 |
47 | # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
48 | # config.force_ssl = true
49 |
50 | # Use the lowest log level to ensure availability of diagnostic information
51 | # when problems arise.
52 | config.log_level = :debug
53 |
54 | # Prepend all log lines with the following tags.
55 | config.log_tags = [ :request_id ]
56 |
57 | # Use a different cache store in production.
58 | # config.cache_store = :mem_cache_store
59 |
60 | # Use a real queuing backend for Active Job (and separate queues per environment)
61 | # config.active_job.queue_adapter = :resque
62 | # config.active_job.queue_name_prefix = "blog_#{Rails.env}"
63 | config.action_mailer.perform_caching = false
64 |
65 | # Ignore bad email addresses and do not raise email delivery errors.
66 | # Set this to true and configure the email server for immediate delivery to raise delivery errors.
67 | # config.action_mailer.raise_delivery_errors = false
68 |
69 | # Enable locale fallbacks for I18n (makes lookups for any locale fall back to
70 | # the I18n.default_locale when a translation cannot be found).
71 | config.i18n.fallbacks = true
72 |
73 | # Send deprecation notices to registered listeners.
74 | config.active_support.deprecation = :notify
75 |
76 | # Use default logging formatter so that PID and timestamp are not suppressed.
77 | config.log_formatter = ::Logger::Formatter.new
78 |
79 | # Use a different logger for distributed setups.
80 | # require 'syslog/logger'
81 | # config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name')
82 |
83 | if ENV["RAILS_LOG_TO_STDOUT"].present?
84 | logger = ActiveSupport::Logger.new(STDOUT)
85 | logger.formatter = config.log_formatter
86 | config.logger = ActiveSupport::TaggedLogging.new(logger)
87 | end
88 |
89 | # Do not dump schema after migrations.
90 | config.active_record.dump_schema_after_migration = false
91 | end
92 |
--------------------------------------------------------------------------------
/config/environments/test.rb:
--------------------------------------------------------------------------------
1 | Rails.application.configure do
2 | # Settings specified here will take precedence over those in config/application.rb.
3 |
4 | # The test environment is used exclusively to run your application's
5 | # test suite. You never need to work with it otherwise. Remember that
6 | # your test database is "scratch space" for the test suite and is wiped
7 | # and recreated between test runs. Don't rely on the data there!
8 | config.cache_classes = true
9 |
10 | # Do not eager load code on boot. This avoids loading your whole application
11 | # just for the purpose of running a single test. If you are using a tool that
12 | # preloads Rails for running tests, you may have to set it to true.
13 | config.eager_load = false
14 |
15 | # Configure public file server for tests with Cache-Control for performance.
16 | config.public_file_server.enabled = true
17 | config.public_file_server.headers = {
18 | 'Cache-Control' => "public, max-age=#{1.hour.seconds.to_i}"
19 | }
20 |
21 | # Show full error reports and disable caching.
22 | config.consider_all_requests_local = true
23 | config.action_controller.perform_caching = false
24 |
25 | # Raise exceptions instead of rendering exception templates.
26 | config.action_dispatch.show_exceptions = false
27 |
28 | # Disable request forgery protection in test environment.
29 | config.action_controller.allow_forgery_protection = false
30 | config.action_mailer.perform_caching = false
31 |
32 | # Tell Action Mailer not to deliver emails to the real world.
33 | # The :test delivery method accumulates sent emails in the
34 | # ActionMailer::Base.deliveries array.
35 | config.action_mailer.delivery_method = :test
36 |
37 | # Print deprecation notices to the stderr.
38 | config.active_support.deprecation = :stderr
39 |
40 | # Raises error for missing translations
41 | # config.action_view.raise_on_missing_translations = true
42 | end
43 |
--------------------------------------------------------------------------------
/config/initializers/application_controller_renderer.rb:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 |
3 | # ApplicationController.renderer.defaults.merge!(
4 | # http_host: 'example.org',
5 | # https: false
6 | # )
7 |
--------------------------------------------------------------------------------
/config/initializers/assets.rb:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 |
3 | # Version of your assets, change this if you want to expire all your assets.
4 | Rails.application.config.assets.version = '1.0'
5 |
6 | # Add additional assets to the asset load path.
7 | # Rails.application.config.assets.paths << Emoji.images_path
8 | # Add Yarn node_modules folder to the asset load path.
9 | Rails.application.config.assets.paths << Rails.root.join('node_modules')
10 |
11 | # Precompile additional assets.
12 | # application.js, application.css, and all non-JS/CSS in the app/assets
13 | # folder are already added.
14 | # Rails.application.config.assets.precompile += %w( admin.js admin.css )
15 |
--------------------------------------------------------------------------------
/config/initializers/backtrace_silencers.rb:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 |
3 | # You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
4 | # Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }
5 |
6 | # You can also remove all the silencers if you're trying to debug a problem that might stem from framework code.
7 | # Rails.backtrace_cleaner.remove_silencers!
8 |
--------------------------------------------------------------------------------
/config/initializers/cookies_serializer.rb:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 |
3 | # Specify a serializer for the signed and encrypted cookie jars.
4 | # Valid options are :json, :marshal, and :hybrid.
5 | Rails.application.config.action_dispatch.cookies_serializer = :json
6 |
--------------------------------------------------------------------------------
/config/initializers/filter_parameter_logging.rb:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 |
3 | # Configure sensitive parameters which will be filtered from the log file.
4 | Rails.application.config.filter_parameters += [:password]
5 |
--------------------------------------------------------------------------------
/config/initializers/inflections.rb:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 |
3 | # Add new inflection rules using the following format. Inflections
4 | # are locale specific, and you may define rules for as many different
5 | # locales as you wish. All of these examples are active by default:
6 | # ActiveSupport::Inflector.inflections(:en) do |inflect|
7 | # inflect.plural /^(ox)$/i, '\1en'
8 | # inflect.singular /^(ox)en/i, '\1'
9 | # inflect.irregular 'person', 'people'
10 | # inflect.uncountable %w( fish sheep )
11 | # end
12 |
13 | # These inflection rules are supported but not enabled by default:
14 | # ActiveSupport::Inflector.inflections(:en) do |inflect|
15 | # inflect.acronym 'RESTful'
16 | # end
17 |
--------------------------------------------------------------------------------
/config/initializers/mime_types.rb:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 |
3 | # Add new mime types for use in respond_to blocks:
4 | # Mime::Type.register "text/richtext", :rtf
5 |
--------------------------------------------------------------------------------
/config/initializers/wrap_parameters.rb:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 |
3 | # This file contains settings for ActionController::ParamsWrapper which
4 | # is enabled by default.
5 |
6 | # Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
7 | ActiveSupport.on_load(:action_controller) do
8 | wrap_parameters format: [:json]
9 | end
10 |
11 | # To enable root element in JSON for ActiveRecord objects.
12 | # ActiveSupport.on_load(:active_record) do
13 | # self.include_root_in_json = true
14 | # end
15 |
--------------------------------------------------------------------------------
/config/locales/en.yml:
--------------------------------------------------------------------------------
1 | # Files in the config/locales directory are used for internationalization
2 | # and are automatically loaded by Rails. If you want to use locales other
3 | # than English, add the necessary files in this directory.
4 | #
5 | # To use the locales, use `I18n.t`:
6 | #
7 | # I18n.t 'hello'
8 | #
9 | # In views, this is aliased to just `t`:
10 | #
11 | # <%= t('hello') %>
12 | #
13 | # To use a different locale, set it with `I18n.locale`:
14 | #
15 | # I18n.locale = :es
16 | #
17 | # This would use the information in config/locales/es.yml.
18 | #
19 | # The following keys must be escaped otherwise they will not be retrieved by
20 | # the default I18n backend:
21 | #
22 | # true, false, on, off, yes, no
23 | #
24 | # Instead, surround them with single quotes.
25 | #
26 | # en:
27 | # 'true': 'foo'
28 | #
29 | # To learn more, please read the Rails Internationalization guide
30 | # available at http://guides.rubyonrails.org/i18n.html.
31 |
32 | en:
33 | hello: "Hello world"
34 |
--------------------------------------------------------------------------------
/config/puma.rb:
--------------------------------------------------------------------------------
1 | # Puma can serve each request in a thread from an internal thread pool.
2 | # The `threads` method setting takes two numbers: a minimum and maximum.
3 | # Any libraries that use thread pools should be configured to match
4 | # the maximum value specified for Puma. Default is set to 5 threads for minimum
5 | # and maximum; this matches the default thread size of Active Record.
6 | #
7 | threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 }
8 | threads threads_count, threads_count
9 |
10 | # Specifies the `port` that Puma will listen on to receive requests; default is 3000.
11 | #
12 | port ENV.fetch("PORT") { 3000 }
13 |
14 | # Specifies the `environment` that Puma will run in.
15 | #
16 | environment ENV.fetch("RAILS_ENV") { "development" }
17 |
18 | # Specifies the number of `workers` to boot in clustered mode.
19 | # Workers are forked webserver processes. If using threads and workers together
20 | # the concurrency of the application would be max `threads` * `workers`.
21 | # Workers do not work on JRuby or Windows (both of which do not support
22 | # processes).
23 | #
24 | # workers ENV.fetch("WEB_CONCURRENCY") { 2 }
25 |
26 | # Use the `preload_app!` method when specifying a `workers` number.
27 | # This directive tells Puma to first boot the application and load code
28 | # before forking the application. This takes advantage of Copy On Write
29 | # process behavior so workers use less memory. If you use this option
30 | # you need to make sure to reconnect any threads in the `on_worker_boot`
31 | # block.
32 | #
33 | # preload_app!
34 |
35 | # If you are preloading your application and using Active Record, it's
36 | # recommended that you close any connections to the database before workers
37 | # are forked to prevent connection leakage.
38 | #
39 | # before_fork do
40 | # ActiveRecord::Base.connection_pool.disconnect! if defined?(ActiveRecord)
41 | # end
42 |
43 | # The code in the `on_worker_boot` will be called if you are using
44 | # clustered mode by specifying a number of `workers`. After each worker
45 | # process is booted, this block will be run. If you are using the `preload_app!`
46 | # option, you will want to use this block to reconnect to any threads
47 | # or connections that may have been created at application boot, as Ruby
48 | # cannot share connections between processes.
49 | #
50 | # on_worker_boot do
51 | # ActiveRecord::Base.establish_connection if defined?(ActiveRecord)
52 | # end
53 | #
54 |
55 | # Allow puma to be restarted by `rails restart` command.
56 | plugin :tmp_restart
57 |
--------------------------------------------------------------------------------
/config/routes.rb:
--------------------------------------------------------------------------------
1 | Rails.application.routes.draw do
2 | resources :posts
3 | get 'welcome/index'
4 | root :to => 'posts#index'
5 |
6 | # For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
7 | end
8 |
--------------------------------------------------------------------------------
/config/secrets.yml:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 |
3 | # Your secret key is used for verifying the integrity of signed cookies.
4 | # If you change this key, all old signed cookies will become invalid!
5 |
6 | # Make sure the secret is at least 30 characters and all random,
7 | # no regular words or you'll be exposed to dictionary attacks.
8 | # You can use `rails secret` to generate a secure secret key.
9 |
10 | # Make sure the secrets in this file are kept private
11 | # if you're sharing your code publicly.
12 |
13 | # Shared secrets are available across all environments.
14 |
15 | # shared:
16 | # api_key: a1B2c3D4e5F6
17 |
18 | # Environmental secrets are only available for that specific environment.
19 |
20 | development:
21 | secret_key_base: 1772865d68179331209180bfb411ef9c9a982de29f41ebfc434b061cdbda03d4916c44fd4a8822e52bb6ae7b9f00996cbd5d2cd06c717b7197691df01318381c
22 |
23 | test:
24 | secret_key_base: aed8f9bc41e732bd2f6d8f2656a075695d6b898caed71a2510987676c1cf30726f6ac943a47b6acde7cc4d1d66216c62f1725d707d4373849d252a4829d9d749
25 |
26 | # Do not keep production secrets in the unencrypted secrets file.
27 | # Instead, either read values from the environment.
28 | # Or, use `bin/rails secrets:setup` to configure encrypted secrets
29 | # and move the `production:` environment over there.
30 |
31 | production:
32 | secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>
33 |
--------------------------------------------------------------------------------
/config/spring.rb:
--------------------------------------------------------------------------------
1 | %w(
2 | .ruby-version
3 | .rbenv-vars
4 | tmp/restart.txt
5 | tmp/caching-dev.txt
6 | ).each { |path| Spring.watch(path) }
7 |
--------------------------------------------------------------------------------
/db/migrate/20170509232014_create_posts.rb:
--------------------------------------------------------------------------------
1 | class CreatePosts < ActiveRecord::Migration[5.1]
2 | def change
3 | create_table :posts do |t|
4 | t.string :title
5 | t.text :body
6 | t.boolean :published
7 |
8 | t.timestamps
9 | end
10 | end
11 | end
12 |
--------------------------------------------------------------------------------
/db/schema.rb:
--------------------------------------------------------------------------------
1 | # This file is auto-generated from the current state of the database. Instead
2 | # of editing this file, please use the migrations feature of Active Record to
3 | # incrementally modify your database, and then regenerate this schema definition.
4 | #
5 | # Note that this schema.rb definition is the authoritative source for your
6 | # database schema. If you need to create the application database on another
7 | # system, you should be using db:schema:load, not running all the migrations
8 | # from scratch. The latter is a flawed and unsustainable approach (the more migrations
9 | # you'll amass, the slower it'll run and the greater likelihood for issues).
10 | #
11 | # It's strongly recommended that you check this file into your version control system.
12 |
13 | ActiveRecord::Schema.define(version: 2017_05_09_232014) do
14 |
15 | # These are extensions that must be enabled in order to support this database
16 | enable_extension "plpgsql"
17 |
18 | create_table "posts", force: :cascade do |t|
19 | t.string "title"
20 | t.text "body"
21 | t.boolean "published"
22 | t.datetime "created_at", null: false
23 | t.datetime "updated_at", null: false
24 | end
25 |
26 | end
27 |
--------------------------------------------------------------------------------
/db/seeds.rb:
--------------------------------------------------------------------------------
1 | # This file should contain all the record creation needed to seed the database with its default values.
2 | # The data can then be loaded with the rails db:seed command (or created alongside the database with db:setup).
3 | #
4 | # Examples:
5 | #
6 | # movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the Rings' }])
7 | # Character.create(name: 'Luke', movie: movies.first)
8 |
--------------------------------------------------------------------------------
/docker-compose.yml:
--------------------------------------------------------------------------------
1 | version: '3'
2 | services:
3 | db:
4 | image: postgres:9.5
5 | volumes:
6 | - ./tmp/db:/var/lib/postgresql/data
7 | restart: always
8 | env_file:
9 | - db.env
10 | web:
11 | build: .
12 | command: bash -c "rm -f tmp/pids/server.pid && bundle exec rails s -p 3000 -b '0.0.0.0'; env"
13 | volumes:
14 | - .:/myapp
15 | ports:
16 | - "3000:3000"
17 | depends_on:
18 | - db
19 | env_file:
20 | - app.env
21 |
--------------------------------------------------------------------------------
/entrypoint.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | set -e
3 |
4 | # Remove a potentially pre-existing server.pid for Rails.
5 | rm -f /myapp/tmp/pids/server.pid
6 |
7 | # Then exec the container's main process (what's set as CMD in the Dockerfile).
8 | exec "$@"
9 |
--------------------------------------------------------------------------------
/lib/assets/.keep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CircleCI-Public/circleci-demo-ruby-rails/2033c5f8da3010941127e0f9133925bd8efc7a79/lib/assets/.keep
--------------------------------------------------------------------------------
/lib/tasks/.keep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CircleCI-Public/circleci-demo-ruby-rails/2033c5f8da3010941127e0f9133925bd8efc7a79/lib/tasks/.keep
--------------------------------------------------------------------------------
/log/.keep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CircleCI-Public/circleci-demo-ruby-rails/2033c5f8da3010941127e0f9133925bd8efc7a79/log/.keep
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "circleci-demo-ruby-rails",
3 | "private": true,
4 | "dependencies": {
5 | "bootstrap": "~>4.3.1"
6 | },
7 | "version": "1.0.0",
8 | "repository": "git@github.com:CircleCI-Public/circleci-demo-ruby-rails.git",
9 | "author": "Zachary Scott ",
10 | "license": "MIT"
11 | }
12 |
--------------------------------------------------------------------------------
/public/404.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | The page you were looking for doesn't exist (404)
5 |
6 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
The page you were looking for doesn't exist.
62 |
You may have mistyped the address or the page may have moved.
63 |
64 |
If you are the application owner check the logs for more information.
65 |
66 |
67 |
68 |
--------------------------------------------------------------------------------
/public/422.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | The change you wanted was rejected (422)
5 |
6 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
The change you wanted was rejected.
62 |
Maybe you tried to change something you didn't have access to.
63 |
64 |
If you are the application owner check the logs for more information.
65 |
66 |
67 |
68 |
--------------------------------------------------------------------------------
/public/500.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | We're sorry, but something went wrong (500)
5 |
6 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
We're sorry, but something went wrong.
62 |
63 |
If you are the application owner check the logs for more information.
64 |
65 |
66 |
67 |
--------------------------------------------------------------------------------
/public/apple-touch-icon-precomposed.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CircleCI-Public/circleci-demo-ruby-rails/2033c5f8da3010941127e0f9133925bd8efc7a79/public/apple-touch-icon-precomposed.png
--------------------------------------------------------------------------------
/public/apple-touch-icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CircleCI-Public/circleci-demo-ruby-rails/2033c5f8da3010941127e0f9133925bd8efc7a79/public/apple-touch-icon.png
--------------------------------------------------------------------------------
/public/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CircleCI-Public/circleci-demo-ruby-rails/2033c5f8da3010941127e0f9133925bd8efc7a79/public/favicon.ico
--------------------------------------------------------------------------------
/public/robots.txt:
--------------------------------------------------------------------------------
1 | # See http://www.robotstxt.org/robotstxt.html for documentation on how to use the robots.txt file
2 |
--------------------------------------------------------------------------------
/spec/controllers/posts_controller_spec.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | require 'rails_helper'
4 |
5 | # This spec was generated by rspec-rails when you ran the scaffold generator.
6 | # It demonstrates how one might use RSpec to specify the controller code that
7 | # was generated by Rails when you ran the scaffold generator.
8 | #
9 | # It assumes that the implementation code is generated by the rails scaffold
10 | # generator. If you are using any extension libraries to generate different
11 | # controller code, this generated spec may or may not pass.
12 | #
13 | # It only uses APIs available in rails and/or rspec-rails. There are a number
14 | # of tools you can use to make these specs even more expressive, but we're
15 | # sticking to rails and rspec-rails APIs to keep things simple and stable.
16 | #
17 | # Compared to earlier versions of this generator, there is very limited use of
18 | # stubs and message expectations in this spec. Stubs are only used when there
19 | # is no simpler way to get a handle on the object needed for the example.
20 | # Message expectations are only used when there is no simpler way to specify
21 | # that an instance is receiving a specific message.
22 | #
23 | # Also compared to earlier versions of this generator, there are no longer any
24 | # expectations of assigns and templates rendered. These features have been
25 | # removed from Rails core in Rails 5, but can be added back in via the
26 | # `rails-controller-testing` gem.
27 |
28 | RSpec.describe PostsController, type: :controller do
29 | # This should return the minimal set of attributes required to create a valid
30 | # Post. As you add validations to Post, be sure to
31 | # adjust the attributes here as well.
32 | let(:valid_attributes) do
33 | {
34 | title: 'A new blog post',
35 | body: 'The body of the post'
36 | }
37 | end
38 |
39 | let(:invalid_attributes) do
40 | {
41 | title: nil,
42 | body: nil
43 | }
44 | end
45 |
46 | # This should return the minimal set of values that should be in the session
47 | # in order to pass any filters (e.g. authentication) defined in
48 | # PostsController. Be sure to keep this updated too.
49 | let(:valid_session) { {} }
50 |
51 | describe 'GET #index' do
52 | it 'returns a success response' do
53 | Post.create! valid_attributes
54 | get :index, params: {}, session: valid_session
55 | expect(response).to be_successful
56 | end
57 | end
58 |
59 | describe 'GET #show' do
60 | it 'returns a success response' do
61 | post = Post.create! valid_attributes
62 | get :show, params: { id: post.to_param }, session: valid_session
63 | expect(response).to be_successful
64 | end
65 | end
66 |
67 | describe 'GET #new' do
68 | it 'returns a success response' do
69 | get :new, params: {}, session: valid_session
70 | expect(response).to be_successful
71 | end
72 | end
73 |
74 | describe 'GET #edit' do
75 | it 'returns a success response' do
76 | post = Post.create! valid_attributes
77 | get :edit, params: { id: post.to_param }, session: valid_session
78 | expect(response).to be_successful
79 | end
80 | end
81 |
82 | describe 'POST #create' do
83 | context 'with valid params' do
84 | it 'creates a new Post' do
85 | expect do
86 | post :create, params: { post: valid_attributes }, session: valid_session
87 | end.to change(Post, :count).by(1)
88 | end
89 |
90 | it 'redirects to the created post' do
91 | post :create, params: { post: valid_attributes }, session: valid_session
92 | expect(response).to redirect_to(Post.last)
93 | end
94 | end
95 |
96 | context 'with invalid params' do
97 | it "returns a success response (i.e. to display the 'new' template)" do
98 | post :create, params: { post: invalid_attributes }, session: valid_session
99 | expect(response).to be_successful
100 | end
101 | end
102 | end
103 |
104 | describe 'PUT #update' do
105 | context 'with valid params' do
106 | let(:new_attributes) do
107 | {
108 | title: 'Zomg updated!',
109 | body: 'The updated blog post...'
110 | }
111 | end
112 |
113 | it 'updates the requested post' do
114 | post = Post.create! valid_attributes
115 | put :update, params: { id: post.to_param, post: new_attributes }, session: valid_session
116 | post.reload
117 | expect(post.title).to eq('Zomg updated!')
118 | end
119 |
120 | it 'redirects to the post' do
121 | post = Post.create! valid_attributes
122 | put :update, params: { id: post.to_param, post: valid_attributes }, session: valid_session
123 | expect(response).to redirect_to(post)
124 | end
125 | end
126 |
127 | context 'with invalid params' do
128 | it "returns a success response (i.e. to display the 'edit' template)" do
129 | post = Post.create! valid_attributes
130 | put :update, params: { id: post.to_param, post: invalid_attributes }, session: valid_session
131 | expect(response).to be_successful
132 | end
133 | end
134 | end
135 |
136 | describe 'DELETE #destroy' do
137 | it 'destroys the requested post' do
138 | post = Post.create! valid_attributes
139 | expect do
140 | delete :destroy, params: { id: post.to_param }, session: valid_session
141 | end.to change(Post, :count).by(-1)
142 | end
143 |
144 | it 'redirects to the posts list' do
145 | post = Post.create! valid_attributes
146 | delete :destroy, params: { id: post.to_param }, session: valid_session
147 | expect(response).to redirect_to(posts_url)
148 | end
149 | end
150 | end
151 |
--------------------------------------------------------------------------------
/spec/controllers/welcome_controller_spec.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | require 'rails_helper'
4 |
5 | RSpec.describe WelcomeController, type: :controller do
6 | describe 'GET #index' do
7 | it 'returns http success' do
8 | get :index
9 | expect(response).to have_http_status(:success)
10 | end
11 | end
12 | end
13 |
--------------------------------------------------------------------------------
/spec/helpers/posts_helper_spec.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | require 'rails_helper'
4 |
5 | # Specs in this file have access to a helper object that includes
6 | # the PostsHelper. For example:
7 | #
8 | # describe PostsHelper do
9 | # describe "string concat" do
10 | # it "concats two strings with spaces" do
11 | # expect(helper.concat_strings("this","that")).to eq("this that")
12 | # end
13 | # end
14 | # end
15 | RSpec.describe PostsHelper, type: :helper do
16 | pending "add some examples to (or delete) #{__FILE__}"
17 | end
18 |
--------------------------------------------------------------------------------
/spec/helpers/welcome_helper_spec.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | require 'rails_helper'
4 |
5 | # Specs in this file have access to a helper object that includes
6 | # the WelcomeHelper. For example:
7 | #
8 | # describe WelcomeHelper do
9 | # describe "string concat" do
10 | # it "concats two strings with spaces" do
11 | # expect(helper.concat_strings("this","that")).to eq("this that")
12 | # end
13 | # end
14 | # end
15 | RSpec.describe WelcomeHelper, type: :helper do
16 | pending "add some examples to (or delete) #{__FILE__}"
17 | end
18 |
--------------------------------------------------------------------------------
/spec/models/post_spec.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | require 'rails_helper'
4 |
5 | RSpec.describe Post, type: :model do
6 | # This should return the minimal set of attributes required to create a valid
7 | # Post. As you add validations to Post, be sure to
8 | # adjust the attributes here as well.
9 | let(:valid_attributes) do
10 | {
11 | title: 'A new blog post',
12 | body: 'The body of the post'
13 | }
14 | end
15 |
16 | let(:invalid_attributes) do
17 | {
18 | title: nil,
19 | body: nil
20 | }
21 | end
22 |
23 | describe 'an valid post' do
24 | it {
25 | post = Post.new valid_attributes
26 | expect(post.valid?).to be_truthy
27 | expect { post.save }.to change { Post.count }.by(1)
28 | }
29 | end
30 |
31 | describe 'an invalid post' do
32 | it {
33 | post = Post.new invalid_attributes
34 | expect(post.valid?).to be_falsey
35 | }
36 | end
37 | end
38 |
--------------------------------------------------------------------------------
/spec/rails_helper.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | # This file is copied to spec/ when you run 'rails generate rspec:install'
4 | require 'spec_helper'
5 | ENV['RAILS_ENV'] ||= 'test'
6 | require File.expand_path('../config/environment', __dir__)
7 | # Prevent database truncation if the environment is production
8 | abort('The Rails environment is running in production mode!') if Rails.env.production?
9 | require 'rspec/rails'
10 | # Add additional requires below this line. Rails is not loaded until this point!
11 |
12 | # Requires supporting ruby files with custom matchers and macros, etc, in
13 | # spec/support/ and its subdirectories. Files matching `spec/**/*_spec.rb` are
14 | # run as spec files by default. This means that files in spec/support that end
15 | # in _spec.rb will both be required and run as specs, causing the specs to be
16 | # run twice. It is recommended that you do not name files matching this glob to
17 | # end with _spec.rb. You can configure this pattern with the --pattern
18 | # option on the command line or in ~/.rspec, .rspec or `.rspec-local`.
19 | #
20 | # The following line is provided for convenience purposes. It has the downside
21 | # of increasing the boot-up time by auto-requiring all files in the support
22 | # directory. Alternatively, in the individual `*_spec.rb` files, manually
23 | # require only the support files necessary.
24 | #
25 | # Dir[Rails.root.join('spec/support/**/*.rb')].each { |f| require f }
26 |
27 | # Checks for pending migration and applies them before tests are run.
28 | # If you are not using ActiveRecord, you can remove this line.
29 | ActiveRecord::Migration.maintain_test_schema!
30 |
31 | RSpec.configure do |config|
32 | # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
33 | config.fixture_path = "#{::Rails.root}/spec/fixtures"
34 |
35 | # If you're not using ActiveRecord, or you'd prefer not to run each of your
36 | # examples within a transaction, remove the following line or assign false
37 | # instead of true.
38 | config.use_transactional_fixtures = true
39 |
40 | # RSpec Rails can automatically mix in different behaviours to your tests
41 | # based on their file location, for example enabling you to call `get` and
42 | # `post` in specs under `spec/controllers`.
43 | #
44 | # You can disable this behaviour by removing the line below, and instead
45 | # explicitly tag your specs with their type, e.g.:
46 | #
47 | # RSpec.describe UsersController, :type => :controller do
48 | # # ...
49 | # end
50 | #
51 | # The different available types are documented in the features, such as in
52 | # https://relishapp.com/rspec/rspec-rails/docs
53 | config.infer_spec_type_from_file_location!
54 |
55 | # Filter lines from Rails gems in backtraces.
56 | config.filter_rails_from_backtrace!
57 | # arbitrary gems may also be filtered via:
58 | # config.filter_gems_from_backtrace("gem name")
59 | end
60 |
--------------------------------------------------------------------------------
/spec/requests/posts_spec.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | require 'rails_helper'
4 |
5 | RSpec.describe 'Posts', type: :request do
6 | describe 'GET /posts' do
7 | it 'works! (now write some real specs)' do
8 | get posts_path
9 | expect(response).to have_http_status(200)
10 | end
11 | end
12 | end
13 |
--------------------------------------------------------------------------------
/spec/routing/posts_routing_spec.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | require 'rails_helper'
4 |
5 | RSpec.describe PostsController, type: :routing do
6 | describe 'routing' do
7 | it 'routes to #index' do
8 | expect(get: '/posts').to route_to('posts#index')
9 | end
10 |
11 | it 'routes to #new' do
12 | expect(get: '/posts/new').to route_to('posts#new')
13 | end
14 |
15 | it 'routes to #show' do
16 | expect(get: '/posts/1').to route_to('posts#show', id: '1')
17 | end
18 |
19 | it 'routes to #edit' do
20 | expect(get: '/posts/1/edit').to route_to('posts#edit', id: '1')
21 | end
22 |
23 | it 'routes to #create' do
24 | expect(post: '/posts').to route_to('posts#create')
25 | end
26 |
27 | it 'routes to #update via PUT' do
28 | expect(put: '/posts/1').to route_to('posts#update', id: '1')
29 | end
30 |
31 | it 'routes to #update via PATCH' do
32 | expect(patch: '/posts/1').to route_to('posts#update', id: '1')
33 | end
34 |
35 | it 'routes to #destroy' do
36 | expect(delete: '/posts/1').to route_to('posts#destroy', id: '1')
37 | end
38 | end
39 | end
40 |
--------------------------------------------------------------------------------
/spec/spec_helper.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | # This file was generated by the `rails generate rspec:install` command. Conventionally, all
4 | # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
5 | # The generated `.rspec` file contains `--require spec_helper` which will cause
6 | # this file to always be loaded, without a need to explicitly require it in any
7 | # files.
8 | #
9 | # Given that it is always loaded, you are encouraged to keep this file as
10 | # light-weight as possible. Requiring heavyweight dependencies from this file
11 | # will add to the boot time of your test suite on EVERY test run, even for an
12 | # individual file that may not need all of that loaded. Instead, consider making
13 | # a separate helper file that requires the additional dependencies and performs
14 | # the additional setup, and require it from the spec files that actually need
15 | # it.
16 | #
17 | # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
18 | RSpec.configure do |config|
19 | # rspec-expectations config goes here. You can use an alternate
20 | # assertion/expectation library such as wrong or the stdlib/minitest
21 | # assertions if you prefer.
22 | config.expect_with :rspec do |expectations|
23 | # This option will default to `true` in RSpec 4. It makes the `description`
24 | # and `failure_message` of custom matchers include text for helper methods
25 | # defined using `chain`, e.g.:
26 | # be_bigger_than(2).and_smaller_than(4).description
27 | # # => "be bigger than 2 and smaller than 4"
28 | # ...rather than:
29 | # # => "be bigger than 2"
30 | expectations.include_chain_clauses_in_custom_matcher_descriptions = true
31 | end
32 |
33 | # rspec-mocks config goes here. You can use an alternate test double
34 | # library (such as bogus or mocha) by changing the `mock_with` option here.
35 | config.mock_with :rspec do |mocks|
36 | # Prevents you from mocking or stubbing a method that does not exist on
37 | # a real object. This is generally recommended, and will default to
38 | # `true` in RSpec 4.
39 | mocks.verify_partial_doubles = true
40 | end
41 |
42 | # This option will default to `:apply_to_host_groups` in RSpec 4 (and will
43 | # have no way to turn it off -- the option exists only for backwards
44 | # compatibility in RSpec 3). It causes shared context metadata to be
45 | # inherited by the metadata hash of host groups and examples, rather than
46 | # triggering implicit auto-inclusion in groups with matching metadata.
47 | config.shared_context_metadata_behavior = :apply_to_host_groups
48 |
49 | # The settings below are suggested to provide a good initial experience
50 | # with RSpec, but feel free to customize to your heart's content.
51 | # # This allows you to limit a spec run to individual examples or groups
52 | # # you care about by tagging them with `:focus` metadata. When nothing
53 | # # is tagged with `:focus`, all examples get run. RSpec also provides
54 | # # aliases for `it`, `describe`, and `context` that include `:focus`
55 | # # metadata: `fit`, `fdescribe` and `fcontext`, respectively.
56 | # config.filter_run_when_matching :focus
57 | #
58 | # # Allows RSpec to persist some state between runs in order to support
59 | # # the `--only-failures` and `--next-failure` CLI options. We recommend
60 | # # you configure your source control system to ignore this file.
61 | # config.example_status_persistence_file_path = "spec/examples.txt"
62 | #
63 | # # Limits the available syntax to the non-monkey patched syntax that is
64 | # # recommended. For more details, see:
65 | # # - http://rspec.info/blog/2012/06/rspecs-new-expectation-syntax/
66 | # # - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
67 | # # - http://rspec.info/blog/2014/05/notable-changes-in-rspec-3/#zero-monkey-patching-mode
68 | # config.disable_monkey_patching!
69 | #
70 | # # Many RSpec users commonly either run the entire suite or an individual
71 | # # file, and it's useful to allow more verbose output when running an
72 | # # individual spec file.
73 | # if config.files_to_run.one?
74 | # # Use the documentation formatter for detailed output,
75 | # # unless a formatter has already been configured
76 | # # (e.g. via a command-line flag).
77 | # config.default_formatter = "doc"
78 | # end
79 | #
80 | # # Print the 10 slowest examples and example groups at the
81 | # # end of the spec run, to help surface which specs are running
82 | # # particularly slow.
83 | # config.profile_examples = 10
84 | #
85 | # # Run specs in random order to surface order dependencies. If you find an
86 | # # order dependency and want to debug it, you can fix the order by providing
87 | # # the seed, which is printed after each run.
88 | # # --seed 1234
89 | # config.order = :random
90 | #
91 | # # Seed global randomization in this process using the `--seed` CLI option.
92 | # # Setting this allows you to use `--seed` to deterministically reproduce
93 | # # test failures related to randomization by passing the same `--seed` value
94 | # # as the one that triggered the failure.
95 | # Kernel.srand config.seed
96 | end
97 |
--------------------------------------------------------------------------------
/spec/views/posts/edit.html.erb_spec.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | require 'rails_helper'
4 |
5 | RSpec.describe 'posts/edit', type: :view do
6 | before(:each) do
7 | @post = assign(:post, Post.create!(
8 | title: 'MyString',
9 | body: 'MyText',
10 | published: false
11 | ))
12 | end
13 |
14 | it 'renders the edit post form' do
15 | render
16 |
17 | assert_select 'form[action=?][method=?]', post_path(@post), 'post' do
18 | assert_select 'input[name=?]', 'post[title]'
19 |
20 | assert_select 'textarea[name=?]', 'post[body]'
21 |
22 | assert_select 'input[name=?]', 'post[published]'
23 | end
24 | end
25 | end
26 |
--------------------------------------------------------------------------------
/spec/views/posts/index.html.erb_spec.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | require 'rails_helper'
4 |
5 | RSpec.describe 'posts/index', type: :view do
6 | before(:each) do
7 | assign(:posts, [
8 | Post.create!(
9 | title: 'Title',
10 | body: 'MyText',
11 | published: false
12 | ),
13 | Post.create!(
14 | title: 'Title',
15 | body: 'MyText',
16 | published: false
17 | )
18 | ])
19 | end
20 |
21 | it 'renders a list of posts' do
22 | render
23 | assert_select 'tr>td', text: 'Title'.to_s, count: 2
24 | assert_select 'tr>td', text: 'MyText'.to_s, count: 2
25 | assert_select 'tr>td', text: false.to_s, count: 2
26 | end
27 | end
28 |
--------------------------------------------------------------------------------
/spec/views/posts/new.html.erb_spec.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | require 'rails_helper'
4 |
5 | RSpec.describe 'posts/new', type: :view do
6 | before(:each) do
7 | assign(:post, Post.new(
8 | title: 'MyString',
9 | body: 'MyText',
10 | published: false
11 | ))
12 | end
13 |
14 | it 'renders new post form' do
15 | render
16 |
17 | assert_select 'form[action=?][method=?]', posts_path, 'post' do
18 | assert_select 'input[name=?]', 'post[title]'
19 |
20 | assert_select 'textarea[name=?]', 'post[body]'
21 |
22 | assert_select 'input[name=?]', 'post[published]'
23 | end
24 | end
25 | end
26 |
--------------------------------------------------------------------------------
/spec/views/posts/show.html.erb_spec.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | require 'rails_helper'
4 |
5 | RSpec.describe 'posts/show', type: :view do
6 | before(:each) do
7 | @post = assign(:post, Post.create!(
8 | title: 'Title',
9 | body: 'MyText',
10 | published: false
11 | ))
12 | end
13 |
14 | it 'renders attributes in ' do
15 | render
16 | expect(rendered).to match(/Title/)
17 | expect(rendered).to match(/MyText/)
18 | expect(rendered).to match(/false/)
19 | end
20 | end
21 |
--------------------------------------------------------------------------------
/spec/views/welcome/index.html.erb_spec.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | require 'rails_helper'
4 |
5 | RSpec.describe 'welcome/index.html.erb', type: :view do
6 | pending "add some examples to (or delete) #{__FILE__}"
7 | end
8 |
--------------------------------------------------------------------------------
/test/application_system_test_case.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | require 'test_helper'
4 |
5 | class ApplicationSystemTestCase < ActionDispatch::SystemTestCase
6 | driven_by :selenium, using: :chrome, screen_size: [1400, 1400]
7 | end
8 |
--------------------------------------------------------------------------------
/test/controllers/.keep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CircleCI-Public/circleci-demo-ruby-rails/2033c5f8da3010941127e0f9133925bd8efc7a79/test/controllers/.keep
--------------------------------------------------------------------------------
/test/fixtures/.keep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CircleCI-Public/circleci-demo-ruby-rails/2033c5f8da3010941127e0f9133925bd8efc7a79/test/fixtures/.keep
--------------------------------------------------------------------------------
/test/fixtures/files/.keep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CircleCI-Public/circleci-demo-ruby-rails/2033c5f8da3010941127e0f9133925bd8efc7a79/test/fixtures/files/.keep
--------------------------------------------------------------------------------
/test/helpers/.keep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CircleCI-Public/circleci-demo-ruby-rails/2033c5f8da3010941127e0f9133925bd8efc7a79/test/helpers/.keep
--------------------------------------------------------------------------------
/test/integration/.keep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CircleCI-Public/circleci-demo-ruby-rails/2033c5f8da3010941127e0f9133925bd8efc7a79/test/integration/.keep
--------------------------------------------------------------------------------
/test/mailers/.keep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CircleCI-Public/circleci-demo-ruby-rails/2033c5f8da3010941127e0f9133925bd8efc7a79/test/mailers/.keep
--------------------------------------------------------------------------------
/test/models/.keep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CircleCI-Public/circleci-demo-ruby-rails/2033c5f8da3010941127e0f9133925bd8efc7a79/test/models/.keep
--------------------------------------------------------------------------------
/test/system/.keep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CircleCI-Public/circleci-demo-ruby-rails/2033c5f8da3010941127e0f9133925bd8efc7a79/test/system/.keep
--------------------------------------------------------------------------------
/test/system/posts_test.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | require 'application_system_test_case'
4 |
5 | class PostsTest < ApplicationSystemTestCase
6 | # test "visiting the index" do
7 | # visit posts_url
8 | #
9 | # assert_selector "h1", text: "Post"
10 | # end
11 | end
12 |
--------------------------------------------------------------------------------
/test/test_helper.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | require File.expand_path('../config/environment', __dir__)
4 | require 'rails/test_help'
5 |
6 | module ActiveSupport
7 | class TestCase
8 | # Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order.
9 | fixtures :all
10 |
11 | # Add more helper methods to be used by all tests here...
12 | end
13 | end
14 |
--------------------------------------------------------------------------------
/tmp/.keep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CircleCI-Public/circleci-demo-ruby-rails/2033c5f8da3010941127e0f9133925bd8efc7a79/tmp/.keep
--------------------------------------------------------------------------------
/vendor/.keep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CircleCI-Public/circleci-demo-ruby-rails/2033c5f8da3010941127e0f9133925bd8efc7a79/vendor/.keep
--------------------------------------------------------------------------------
/yarn.lock:
--------------------------------------------------------------------------------
1 | # THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
2 | # yarn lockfile v1
3 |
4 |
5 | bootstrap@~>4.3.1:
6 | version "4.3.1"
7 | resolved "https://registry.yarnpkg.com/bootstrap/-/bootstrap-4.3.1.tgz#280ca8f610504d99d7b6b4bfc4b68cec601704ac"
8 | integrity sha512-rXqOmH1VilAt2DyPzluTi2blhk17bO7ef+zLLPlWvG494pDxcM234pJ8wTc/6R40UWizAIIMgxjvxZg5kmsbag==
9 |
--------------------------------------------------------------------------------