Commit 5cf43780 by tady (Masato TADA)

Merge pull request #139 from tadyjp/heroku

up to Heroku
parents 51feadb2 cc23a8ba
...@@ -7,3 +7,8 @@ RV_S3_BACKET_NAME=xxxxxxxxxxxxxxxxxxxxx ...@@ -7,3 +7,8 @@ RV_S3_BACKET_NAME=xxxxxxxxxxxxxxxxxxxxx
RV_PDF_UPLOADING=1 RV_PDF_UPLOADING=1
DATABASE_URL=mysql2://user:passwd@localhost/rendezvous_development DATABASE_URL=mysql2://user:passwd@localhost/rendezvous_development
RV_ALLOW_IPS=1.1.1.1,2.2.2.2 RV_ALLOW_IPS=1.1.1.1,2.2.2.2
RV_NEWRELIC_LICENSE_KEY=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
RV_HIPCHAT_TOKEN=xxxxxxxxxxxxxxxxxxxxxxxxxxxx
RV_HIPCHAT_ROOM=xxxxxxxxxxxxxx
RV_GOOGLE_ANALYTICS_ID=UA-xxxxxxxxxx-xx
RV_PDF_UPLOADING=1
AllCops:
# Rails特有のチェックを実行
RunRailsCops: true
# チェック対象外ディレクトリ
Exclude:
- 'db/**/*'
- 'config/**/*'
- 'script/**/*'
- 'bin/**/*'
- 'vendor/**/*'
- 'Guardfile'
# Ascii文字以外のコメントを許容
Style/AsciiComments:
Enabled: false
# 1行の最大文字列長を緩和
Metrics/LineLength:
Max: 160
# メソッド定義の行数を緩和
Metrics/MethodLength:
Max: 50
LineLength: # Classの最大長制限
Max: 159 Metrics/ClassLength:
Max: 300
NumericLiterals: # top-classでのコメントを任意に
Style/Documentation:
Enabled: false Enabled: false
Documentation: # 1行if文を使用可に
Style/IfUnlessModifier:
Enabled: false Enabled: false
WordArray: # nestしたclass/moduleを許容
Style/ClassAndModuleChildren:
Enabled: false Enabled: false
MethodLength: # 後置rescueを許容
Max: 30 Style/RescueModifier:
Enabled: false
IfUnlessModifier: # and/orを許容
Style/AndOr:
Enabled: false Enabled: false
CyclomaticComplexity: # ABCチェックを無効
Max: 10 Metrics/AbcSize:
Enabled: false
RaiseArgs: # ???
Style/RaiseArgs:
Enabled: false Enabled: false
...@@ -11,6 +11,8 @@ env: ...@@ -11,6 +11,8 @@ env:
- AWS_S3_REGION="us-east-1" - AWS_S3_REGION="us-east-1"
- AWS_S3_BUCKET="rendezvous-travis-bundler" - AWS_S3_BUCKET="rendezvous-travis-bundler"
- RAILS_ENV=test - RAILS_ENV=test
- RV_RENDEZVOUS_APP_HOST=example.com
- RV_HIPCHAT_ROOM=Rendezvous%E3%83%86%E3%82%B9%E3%83%88
- secure: A72vqUWQiRal8fCMlobXhYrGVDImUXmrCQGuUc382glay7WdJ4ZsIiVvO1gp8mj7X4HUeejmgY4AUVJy6FmCL4LNxDhdRuOirQ+kOcdsuQKDlMPcbGdoYk23ZBlxeq1tqW9Qs8mNjZYHGx3BFf/qtNhgvTLMr+/wQMZi+110e3g= - secure: A72vqUWQiRal8fCMlobXhYrGVDImUXmrCQGuUc382glay7WdJ4ZsIiVvO1gp8mj7X4HUeejmgY4AUVJy6FmCL4LNxDhdRuOirQ+kOcdsuQKDlMPcbGdoYk23ZBlxeq1tqW9Qs8mNjZYHGx3BFf/qtNhgvTLMr+/wQMZi+110e3g=
services: services:
- mysql - mysql
...@@ -22,4 +24,6 @@ before_script: ...@@ -22,4 +24,6 @@ before_script:
- mysql -e 'CREATE DATABASE rendezvous_test;' - mysql -e 'CREATE DATABASE rendezvous_test;'
after_script: after_script:
- ruby script/travis/bundle_cache.rb - ruby script/travis/bundle_cache.rb
script: bundle exec rake db:create db:test:load spec teaspoon script:
- bundle exec rake db:create db:test:load spec
- bundle exec rubocop
...@@ -23,7 +23,7 @@ gem 'therubyracer', platforms: :ruby ...@@ -23,7 +23,7 @@ gem 'therubyracer', platforms: :ruby
# gem 'turbolinks' # gem 'turbolinks'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder # Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder' # gem 'jbuilder'
gem 'i18n_generators' gem 'i18n_generators'
...@@ -69,8 +69,6 @@ group :development do ...@@ -69,8 +69,6 @@ group :development do
# profiler # profiler
gem 'rack-mini-profiler' gem 'rack-mini-profiler'
# rubocop
gem 'rubocop'
gem 'guard-rspec', require: false gem 'guard-rspec', require: false
gem 'guard-rubocop' gem 'guard-rubocop'
# gem 'guard-spring' # gem 'guard-spring'
...@@ -82,6 +80,8 @@ group :development do ...@@ -82,6 +80,8 @@ group :development do
gem 'capistrano-rails', '~> 1.1' gem 'capistrano-rails', '~> 1.1'
gem 'capistrano-rbenv', '~> 2.0' gem 'capistrano-rbenv', '~> 2.0'
gem 'capistrano3-unicorn' gem 'capistrano3-unicorn'
gem 'travis'
end end
group :development, :test do group :development, :test do
...@@ -95,6 +95,8 @@ group :development, :test do ...@@ -95,6 +95,8 @@ group :development, :test do
gem 'byebug' gem 'byebug'
gem 'dotenv-rails' gem 'dotenv-rails'
gem 'rubocop'
end end
group :test do group :test do
...@@ -139,25 +141,23 @@ gem 'breadcrumble' ...@@ -139,25 +141,23 @@ gem 'breadcrumble'
gem 'slim' gem 'slim'
gem 'annotate', ">=2.6.0" gem 'annotate', '>=2.6.0'
gem 'kaminari', github: 'amatsuda/kaminari' gem 'kaminari', github: 'amatsuda/kaminari'
gem 'jwt', '0.1.11' gem 'jwt', '0.1.11'
# Optional # Optional
# For notifing to HipChat # For notifing to HipChat
gem 'hipchat' gem 'hipchat'
# For PDF upload # For PDF upload
gem 'rmagick', :require => 'RMagick' gem 'rmagick', require: 'RMagick'
# for heroku # for heroku
gem 'rails_12factor', group: :production gem 'rails_12factor', group: :production
gem 'mysql' # gem 'mysql'
# for IP restriction # for IP restriction
gem 'rack-contrib', require: 'rack/contrib' gem 'rack-contrib', require: 'rack/contrib'
...@@ -67,6 +67,7 @@ GEM ...@@ -67,6 +67,7 @@ GEM
aws-sdk (1.39.0) aws-sdk (1.39.0)
json (~> 1.4) json (~> 1.4)
nokogiri (>= 1.4.4) nokogiri (>= 1.4.4)
backports (3.6.3)
bcrypt (3.1.9) bcrypt (3.1.9)
better_errors (2.0.0) better_errors (2.0.0)
coderay (>= 1.0.0) coderay (>= 1.0.0)
...@@ -147,6 +148,8 @@ GEM ...@@ -147,6 +148,8 @@ GEM
activesupport (>= 3.0) activesupport (>= 3.0)
request_store (~> 1.0) request_store (~> 1.0)
erubis (2.7.0) erubis (2.7.0)
ethon (0.7.1)
ffi (>= 1.3.0)
eventmachine (1.0.3) eventmachine (1.0.3)
execjs (2.2.2) execjs (2.2.2)
factory_girl (4.5.0) factory_girl (4.5.0)
...@@ -156,8 +159,17 @@ GEM ...@@ -156,8 +159,17 @@ GEM
railties (>= 3.0.0) railties (>= 3.0.0)
faraday (0.9.0) faraday (0.9.0)
multipart-post (>= 1.2, < 3) multipart-post (>= 1.2, < 3)
faraday_middleware (0.9.1)
faraday (>= 0.7.4, < 0.10)
ffi (1.9.6) ffi (1.9.6)
formatador (0.2.5) formatador (0.2.5)
gh (0.13.2)
addressable
backports
faraday (~> 0.8)
multi_json (~> 1.0)
net-http-persistent (>= 2.7)
net-http-pipeline
gherkin (2.12.2) gherkin (2.12.2)
multi_json (~> 1.3) multi_json (~> 1.3)
github-markdown (0.6.7) github-markdown (0.6.7)
...@@ -179,6 +191,7 @@ GEM ...@@ -179,6 +191,7 @@ GEM
guard (~> 2.2) guard (~> 2.2)
teaspoon (>= 0.8.0) teaspoon (>= 0.8.0)
hashie (3.3.1) hashie (3.3.1)
highline (1.6.21)
hike (1.2.3) hike (1.2.3)
hipchat (1.4.0) hipchat (1.4.0)
httparty httparty
...@@ -193,114 +206,6 @@ GEM ...@@ -193,114 +206,6 @@ GEM
i18n_generators (1.2.1) i18n_generators (1.2.1)
mechanize mechanize
rails (>= 3.0.0) rails (>= 3.0.0)
rails (>= 3.0.0)
rails (>= 3.0.0)
rails (>= 3.0.0)
rails (>= 3.0.0)
rails (>= 3.0.0)
rails (>= 3.0.0)
rails (>= 3.0.0)
rails (>= 3.0.0)
rails (>= 3.0.0)
rails (>= 3.0.0)
rails (>= 3.0.0)
rails (>= 3.0.0)
rails (>= 3.0.0)
rails (>= 3.0.0)
rails (>= 3.0.0)
rails (>= 3.0.0)
rails (>= 3.0.0)
rails (>= 3.0.0)
rails (>= 3.0.0)
rails (>= 3.0.0)
rails (>= 3.0.0)
rails (>= 3.0.0)
rails (>= 3.0.0)
rails (>= 3.0.0)
rails (>= 3.0.0)
rails (>= 3.0.0)
rails (>= 3.0.0)
rails (>= 3.0.0)
rails (>= 3.0.0)
rails (>= 3.0.0)
rails (>= 3.0.0)
rails (>= 3.0.0)
rails (>= 3.0.0)
rails (>= 3.0.0)
rails (>= 3.0.0)
rails (>= 3.0.0)
rails (>= 3.0.0)
rails (>= 3.0.0)
rails (>= 3.0.0)
rails (>= 3.0.0)
rails (>= 3.0.0)
rails (>= 3.0.0)
rails (>= 3.0.0)
rails (>= 3.0.0)
rails (>= 3.0.0)
rails (>= 3.0.0)
rails (>= 3.0.0)
rails (>= 3.0.0)
rails (>= 3.0.0)
rails (>= 3.0.0)
rails (>= 3.0.0)
rails (>= 3.0.0)
rails (>= 3.0.0)
rails (>= 3.0.0)
rails (>= 3.0.0)
rails (>= 3.0.0)
rails (>= 3.0.0)
rails (>= 3.0.0)
rails (>= 3.0.0)
rails (>= 3.0.0)
rails (>= 3.0.0)
rails (>= 3.0.0)
rails (>= 3.0.0)
rails (>= 3.0.0)
rails (>= 3.0.0)
rails (>= 3.0.0)
rails (>= 3.0.0)
rails (>= 3.0.0)
rails (>= 3.0.0)
rails (>= 3.0.0)
rails (>= 3.0.0)
rails (>= 3.0.0)
rails (>= 3.0.0)
rails (>= 3.0.0)
rails (>= 3.0.0)
rails (>= 3.0.0)
rails (>= 3.0.0)
rails (>= 3.0.0)
rails (>= 3.0.0)
rails (>= 3.0.0)
rails (>= 3.0.0)
rails (>= 3.0.0)
rails (>= 3.0.0)
rails (>= 3.0.0)
rails (>= 3.0.0)
rails (>= 3.0.0)
rails (>= 3.0.0)
rails (>= 3.0.0)
rails (>= 3.0.0)
rails (>= 3.0.0)
rails (>= 3.0.0)
rails (>= 3.0.0)
rails (>= 3.0.0)
rails (>= 3.0.0)
rails (>= 3.0.0)
rails (>= 3.0.0)
rails (>= 3.0.0)
rails (>= 3.0.0)
rails (>= 3.0.0)
rails (>= 3.0.0)
rails (>= 3.0.0)
rails (>= 3.0.0)
rails (>= 3.0.0)
rails (>= 3.0.0)
rails (>= 3.0.0)
jbuilder (2.2.4)
activesupport (>= 3.0.0, < 5)
multi_json (~> 1.2)
jquery-rails (3.1.2) jquery-rails (3.1.2)
railties (>= 3.0, < 5.0) railties (>= 3.0, < 5.0)
thor (>= 0.14, < 2.0) thor (>= 0.14, < 2.0)
...@@ -334,10 +239,10 @@ GEM ...@@ -334,10 +239,10 @@ GEM
multi_json (1.10.1) multi_json (1.10.1)
multi_xml (0.5.5) multi_xml (0.5.5)
multipart-post (2.0.0) multipart-post (2.0.0)
mysql (2.9.1)
mysql2 (0.3.16) mysql2 (0.3.16)
net-http-digest_auth (1.4) net-http-digest_auth (1.4)
net-http-persistent (2.9.4) net-http-persistent (2.9.4)
net-http-pipeline (1.0.1)
net-scp (1.2.1) net-scp (1.2.1)
net-ssh (>= 2.6.5) net-ssh (>= 2.6.5)
net-ssh (2.9.1) net-ssh (2.9.1)
...@@ -386,6 +291,9 @@ GEM ...@@ -386,6 +291,9 @@ GEM
slop (~> 3.4) slop (~> 3.4)
pry-rails (0.3.2) pry-rails (0.3.2)
pry (>= 0.9.10) pry (>= 0.9.10)
pusher-client (0.6.0)
json
websocket (~> 1.0)
rack (1.5.2) rack (1.5.2)
rack-contrib (1.2.0) rack-contrib (1.2.0)
rack (>= 0.9.1) rack (>= 0.9.1)
...@@ -501,9 +409,22 @@ GEM ...@@ -501,9 +409,22 @@ GEM
timers (4.0.1) timers (4.0.1)
hitimes hitimes
tins (1.3.3) tins (1.3.3)
travis (1.6.11)
addressable (~> 2.3)
backports
faraday (~> 0.9)
faraday_middleware (~> 0.9)
gh (~> 0.13)
highline (~> 1.6)
launchy (~> 2.1)
pry (~> 0.9)
pusher-client (~> 0.4)
typhoeus (~> 0.6, >= 0.6.8)
turnip (1.2.4) turnip (1.2.4)
gherkin (>= 2.5) gherkin (>= 2.5)
rspec (>= 2.14.0, < 4.0) rspec (>= 2.14.0, < 4.0)
typhoeus (0.6.9)
ethon (>= 0.7.1)
tzinfo (1.2.2) tzinfo (1.2.2)
thread_safe (~> 0.1) thread_safe (~> 0.1)
uglifier (2.5.3) uglifier (2.5.3)
...@@ -521,6 +442,7 @@ GEM ...@@ -521,6 +442,7 @@ GEM
warden (1.2.3) warden (1.2.3)
rack (>= 1.0) rack (>= 1.0)
webrobots (0.1.1) webrobots (0.1.1)
websocket (1.2.1)
websocket-driver (0.3.5) websocket-driver (0.3.5)
xpath (2.0.0) xpath (2.0.0)
nokogiri (~> 1.3) nokogiri (~> 1.3)
...@@ -558,13 +480,11 @@ DEPENDENCIES ...@@ -558,13 +480,11 @@ DEPENDENCIES
guard-teaspoon guard-teaspoon
hipchat hipchat
i18n_generators i18n_generators
jbuilder
jquery-rails jquery-rails
jwt (= 0.1.11) jwt (= 0.1.11)
kaminari! kaminari!
launchy launchy
mail mail
mysql
mysql2 mysql2
newrelic_rpm newrelic_rpm
nokogiri nokogiri
...@@ -587,6 +507,7 @@ DEPENDENCIES ...@@ -587,6 +507,7 @@ DEPENDENCIES
teaspoon teaspoon
therubyracer therubyracer
thin thin
travis
turnip turnip
uglifier uglifier
unicorn unicorn
......
...@@ -9,16 +9,16 @@ ...@@ -9,16 +9,16 @@
guard :rspec, cmd: 'bundle exec rspec' do guard :rspec, cmd: 'bundle exec rspec' do
watch(%r{^spec/.+_spec\.rb$}) watch(%r{^spec/.+_spec\.rb$})
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" } watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
watch('spec/spec_helper.rb') { "spec" } watch('spec/spec_helper.rb') { 'spec' }
# Rails example # Rails example
watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" } watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
watch(%r{^app/(.*)(\.erb|\.haml|\.slim)$}) { |m| "spec/#{m[1]}#{m[2]}_spec.rb" } watch(%r{^app/(.*)(\.erb|\.haml|\.slim)$}) { |m| "spec/#{m[1]}#{m[2]}_spec.rb" }
watch(%r{^app/controllers/(.+)_(controller)\.rb$}) { |m| ["spec/routing/#{m[1]}_routing_spec.rb", "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", "spec/acceptance/#{m[1]}_spec.rb"] } watch(%r{^app/controllers/(.+)_(controller)\.rb$}) { |m| ["spec/routing/#{m[1]}_routing_spec.rb", "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", "spec/acceptance/#{m[1]}_spec.rb"] }
watch(%r{^spec/support/(.+)\.rb$}) { "spec" } watch(%r{^spec/support/(.+)\.rb$}) { 'spec' }
watch('config/routes.rb') { "spec/routing" } watch('config/routes.rb') { 'spec/routing' }
watch('app/controllers/application_controller.rb') { "spec/controllers" } watch('app/controllers/application_controller.rb') { 'spec/controllers' }
watch('spec/rails_helper.rb') { "spec" } watch('spec/rails_helper.rb') { 'spec' }
# Capybara features specs # Capybara features specs
watch(%r{^app/views/(.+)/.*\.(erb|haml|slim)$}) { |m| "spec/features/#{m[1]}_spec.rb" } watch(%r{^app/views/(.+)/.*\.(erb|haml|slim)$}) { |m| "spec/features/#{m[1]}_spec.rb" }
...@@ -28,7 +28,6 @@ guard :rspec, cmd: 'bundle exec rspec' do ...@@ -28,7 +28,6 @@ guard :rspec, cmd: 'bundle exec rspec' do
watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) { |m| Dir[File.join("**/#{m[1]}.feature")][0] || 'spec/acceptance' } watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) { |m| Dir[File.join("**/#{m[1]}.feature")][0] || 'spec/acceptance' }
end end
# guard :rubocop do # guard :rubocop do
# watch(%r{.+\.rb$}) # watch(%r{.+\.rb$})
# watch(%r{(?:.+/)?\.rubocop\.yml$}) { |m| File.dirname(m[0]) } # watch(%r{(?:.+/)?\.rubocop\.yml$}) { |m| File.dirname(m[0]) }
......

1.87 MB | W: | H:

70 KB | W: | H:

app/assets/images/compass.jpg
app/assets/images/compass.jpg
app/assets/images/compass.jpg
app/assets/images/compass.jpg
  • 2-up
  • Swipe
  • Onion skin

122 KB | W: | H:

9.4 KB | W: | H:

app/assets/images/font.jpg
app/assets/images/font.jpg
app/assets/images/font.jpg
app/assets/images/font.jpg
  • 2-up
  • Swipe
  • Onion skin

204 KB | W: | H:

35.9 KB | W: | H:

app/assets/images/paper.jpg
app/assets/images/paper.jpg
app/assets/images/paper.jpg
app/assets/images/paper.jpg
  • 2-up
  • Swipe
  • Onion skin

156 KB | W: | H:

17 KB | W: | H:

app/assets/images/pc.jpg
app/assets/images/pc.jpg
app/assets/images/pc.jpg
app/assets/images/pc.jpg
  • 2-up
  • Swipe
  • Onion skin
@import url(http://fonts.googleapis.com/css?family=Flamenco:300,400); @import url(https://fonts.googleapis.com/css?family=Flamenco:300,400);
@import url(http://fonts.googleapis.com/css?family=Quicksand:300,400,700); @import url(https://fonts.googleapis.com/css?family=Quicksand:300,400,700);
$set_prefix: -webkit-, -moz-, -ms-, -o-, ''; $set_prefix: -webkit-, -moz-, -ms-, -o-, '';
$main-color: #75b3c8; $main-color: #75b3c8;
......
@import 'values'; @import 'values';
@import url(http://fonts.googleapis.com/css?family=Flamenco:300,400); @import url(https://fonts.googleapis.com/css?family=Flamenco:300,400);
@import url(http://fonts.googleapis.com/css?family=Quicksand:300,400,700); @import url(https://fonts.googleapis.com/css?family=Quicksand:300,400,700);
p, h1, h2, h3, h4, h5, h6, span { p, h1, h2, h3, h4, h5, h6, span {
// font-family: 'メイリオ', 'meiryo', hiragino kaku go; // font-family: 'メイリオ', 'meiryo', hiragino kaku go;
// letter-spacing: 2pt; // letter-spacing: 2pt;
......
...@@ -17,8 +17,8 @@ $main-color: #75b3c8; ...@@ -17,8 +17,8 @@ $main-color: #75b3c8;
#{$prefix}transition: all $transition_value $move_type #{$prefix}transition: all $transition_value $move_type
} }
} }
@import url(http://fonts.googleapis.com/css?family=Flamenco:300,400); @import url(https://fonts.googleapis.com/css?family=Flamenco:300,400);
@import url(http://fonts.googleapis.com/css?family=Quicksand:300,400,700); @import url(https://fonts.googleapis.com/css?family=Quicksand:300,400,700);
.btn-original { .btn-original {
background: transparent!important; background: transparent!important;
border: 1px solid #fff; border: 1px solid #fff;
......
...@@ -6,8 +6,8 @@ ...@@ -6,8 +6,8 @@
* app_header * app_header
*************************************************************************/ *************************************************************************/
@import 'values'; @import 'values';
@import url(http://fonts.googleapis.com/css?family=Flamenco:300,400); @import url(https://fonts.googleapis.com/css?family=Flamenco:300,400);
@import url(http://fonts.googleapis.com/css?family=Quicksand:300,400,700); @import url(https://fonts.googleapis.com/css?family=Quicksand:300,400,700);
$main-color: #75b3c8; $main-color: #75b3c8;
.navbar-original { .navbar-original {
......
@import url(http://fonts.googleapis.com/css?family=Quicksand:300,400,700); @import url(https://fonts.googleapis.com/css?family=Quicksand:300,400,700);
$main-color: #75b3c8; $main-color: #75b3c8;
.background-image { .background-image {
width: 100%; width: 100%;
......
require 'digest/md5' require 'digest/md5'
class ApisController < ApplicationController class ApisController < ApplicationController
# TODO: not to use # TODO: not to use
include ApplicationHelper include ApplicationHelper
...@@ -26,15 +25,15 @@ class ApisController < ApplicationController ...@@ -26,15 +25,15 @@ class ApisController < ApplicationController
# Skip uploading if file ext is not listed. # Skip uploading if file ext is not listed.
next unless file.original_filename =~ /\.(jpe?g|png|gif|pdf)\Z/ next unless file.original_filename =~ /\.(jpe?g|png|gif|pdf)\Z/
object_file_name = "#{Digest::MD5.file(file.path).to_s}#{File.extname(file.original_filename)}" object_file_name = "#{Digest::MD5.file(file.path)}#{File.extname(file.original_filename)}"
res = s3_uploader.upload!(file: file.path, name: object_file_name) res = s3_uploader.upload!(file: file.path, name: object_file_name)
case file.original_filename case file.original_filename
when /\.(jpe?g|png|gif)\Z/ when /\.(jpe?g|png|gif)\Z/
s3_files << { type: 'image', name: file.original_filename, image: res.public_url.to_s } s3_files << { type: 'image', name: file.original_filename, image: res.public_url.to_s }
when /\.pdf\Z/ when /\.pdf\Z/
if Settings.respond_to?(:pdf_uploading) && Settings.pdf_uploading if Settings.enable_pdf_uploading
cover_image_name = "#{Digest::MD5.file(file.path).to_s}-cover.png" cover_image_name = "#{Digest::MD5.file(file.path)}-cover.png"
pdf = Magick::ImageList.new(file.path + '[0]') pdf = Magick::ImageList.new(file.path + '[0]')
cover_tmp = Rails.root.join('tmp', cover_image_name) cover_tmp = Rails.root.join('tmp', cover_image_name)
pdf[0].write(cover_tmp) pdf[0].write(cover_tmp)
...@@ -49,7 +48,7 @@ class ApisController < ApplicationController ...@@ -49,7 +48,7 @@ class ApisController < ApplicationController
end end
def user_mention def user_mention
name_list = User.search(params[:q]).map{ |_user| "#{_user.nickname}[#{_user.name}]" } name_list = User.search(params[:q]).map { |user| "#{user.nickname}[#{user.name}]" }
render json: name_list render json: name_list
end end
......
...@@ -3,16 +3,16 @@ class ApplicationController < ActionController::Base ...@@ -3,16 +3,16 @@ class ApplicationController < ActionController::Base
# For APIs, you may want to use :null_session instead. # For APIs, you may want to use :null_session instead.
protect_from_forgery with: :exception protect_from_forgery with: :exception
add_breadcrumb("Rendezvous", '/') add_breadcrumb('Rendezvous', '/')
before_action :redirect_unless_signed_in before_action :redirect_unless_signed_in
def redirect_unless_signed_in def redirect_unless_signed_in
unless user_signed_in? return if user_signed_in?
flash[:alert] = 'You need Login!'
session[:login_redirect_to] = request.url flash[:alert] = 'You need Login!'
redirect_to root_path session[:login_redirect_to] = request.url
end redirect_to root_path
end end
def after_sign_in_path_for(resource) def after_sign_in_path_for(resource)
......
...@@ -14,10 +14,10 @@ module RV::Mailer ...@@ -14,10 +14,10 @@ module RV::Mailer
html_body = generate_html_mail(post) html_body = generate_html_mail(post)
mail = Mail.new do mail = Mail.new do
from opts[:user].email from opts[:user].email
to opts[:to] to opts[:to]
subject post.title subject post.title
body post.body body post.body
html_part do html_part do
content_type 'text/html; charset=UTF-8' content_type 'text/html; charset=UTF-8'
...@@ -40,10 +40,10 @@ module RV::Mailer ...@@ -40,10 +40,10 @@ module RV::Mailer
template = File.open(path).read template = File.open(path).read
html_body = template html_body = template
.sub('__POST_URL__', Settings.rendezvous.app_host + post.decorate.show_path) .sub('__POST_URL__', Settings.rendezvous.app_host + post.decorate.show_path)
.sub('__HTML_TITLE__', MarkdownRenderer.new(post.title).render) .sub('__HTML_TITLE__', MarkdownRenderer.new(post.title).render)
.sub('__HTML_BODY__', MarkdownRenderer.new(post.body).render) .sub('__HTML_BODY__', MarkdownRenderer.new(post.body).render)
.sub('__RV_URL__', Settings.rendezvous.app_host + '/') .sub('__RV_URL__', Settings.rendezvous.app_host + '/')
premailer = Premailer.new(html_body, with_html_string: true, adapter: :nokogiri) premailer = Premailer.new(html_body, with_html_string: true, adapter: :nokogiri)
premailer.to_inline_css premailer.to_inline_css
......
class FlowController < ApplicationController class FlowController < ApplicationController
def show def show
@posts = Post.includes(:tags, :author).where(is_draft: false).order(updated_at: :desc).page(params[:page]).decorate @posts = Post.includes(:tags, :author).where(is_draft: false).order(updated_at: :desc).page(params[:page]).decorate
end end
......
...@@ -11,5 +11,4 @@ class NotificationsController < ApplicationController ...@@ -11,5 +11,4 @@ class NotificationsController < ApplicationController
def set_notification def set_notification
@notification = Notification.find(params[:id]) @notification = Notification.find(params[:id])
end end
end end
...@@ -10,8 +10,8 @@ class PostsController < ApplicationController ...@@ -10,8 +10,8 @@ class PostsController < ApplicationController
def show def show
current_user.visit_post!(@post) current_user.visit_post!(@post)
@post.tags.each do |_tag| @post.tags.each do |tag|
add_breadcrumb("##{_tag.name}", _tag.decorate.show_path) add_breadcrumb("##{tag.name}", tag.decorate.show_path)
end end
add_breadcrumb(@post.title) add_breadcrumb(@post.title)
end end
...@@ -131,17 +131,17 @@ class PostsController < ApplicationController ...@@ -131,17 +131,17 @@ class PostsController < ApplicationController
# Never trust parameters from the scary internet, only allow the white list through. # Never trust parameters from the scary internet, only allow the white list through.
def post_params def post_params
@post_params ||= begin @post_params ||= begin
_param_hash = params.require(:post).permit(:title, :body, :tags, :is_draft, :specified_date).to_hash param_hash = params.require(:post).permit(:title, :body, :tags, :is_draft, :specified_date).to_hash
# tags_text == 'Javascript,Ruby' # tags_text == 'Javascript,Ruby'
tags_text = _param_hash.delete('tags') tags_text = param_hash.delete('tags')
tags = tags_text.split(',').map do |_tag_name| tags = tags_text.split(',').map do |tag_name|
Tag.find_or_create_by(name: _tag_name) Tag.find_or_create_by(name: tag_name)
end end
_param_hash['tag_ids'] = tags.map(&:id) param_hash['tag_ids'] = tags.map(&:id)
_param_hash param_hash
end end
end end
......
class SearchController < ApplicationController class SearchController < ApplicationController
def show def show
if params[:q].present? if params[:q].present?
scope = Post.search(params[:q]) scope = Post.search(params[:q])
......
...@@ -52,7 +52,7 @@ class TagsController < ApplicationController ...@@ -52,7 +52,7 @@ class TagsController < ApplicationController
# すべてのPostを移動先のタグに移動し # すべてのPostを移動先のタグに移動し
# このタグを削除する # このタグを削除する
def merge_to def merge_to
@merge_to_tag = Tag.find_by(name: params[:merge_to_name]) or raise ActiveRecord::RecordNotFound @merge_to_tag = Tag.find_by(name: params[:merge_to_name]) or fail ActiveRecord::RecordNotFound
@tag.move_all_posts_to!(@merge_to_tag) @tag.move_all_posts_to!(@merge_to_tag)
@tag.delete @tag.delete
...@@ -64,9 +64,9 @@ class TagsController < ApplicationController ...@@ -64,9 +64,9 @@ class TagsController < ApplicationController
# このタグを他のタグの下に移動 # このタグを他のタグの下に移動
def move_to def move_to
@move_to_tag = Tag.find_by(name: params[:move_to_name]) or raise ActiveRecord::RecordNotFound @move_to_tag = Tag.find_by(name: params[:move_to_name]) or fail ActiveRecord::RecordNotFound
@tag.set_parent!(@move_to_tag) @tag.parent_tag = @move_to_tag
flash[:notice] = "「#{@tag.name}」は「#{@move_to_tag.name}」の下に移動しました" flash[:notice] = "「#{@tag.name}」は「#{@move_to_tag.name}」の下に移動しました"
...@@ -76,12 +76,11 @@ class TagsController < ApplicationController ...@@ -76,12 +76,11 @@ class TagsController < ApplicationController
private private
def set_tag def set_tag
tag = Tag.find_by(name: params[:name]) or raise ActiveRecord::RecordNotFound tag = Tag.find_by(name: params[:name]) or fail ActiveRecord::RecordNotFound
@tag = tag.decorate @tag = tag.decorate
end end
def tag_params def tag_params
params.require(:tag).permit(:name, :body).to_hash params.require(:tag).permit(:name, :body).to_hash
end end
end end
class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController
skip_before_action :redirect_unless_signed_in skip_before_action :redirect_unless_signed_in
def google_oauth2 def google_oauth2
email = request.env['omniauth.auth'].info['email'] email = request.env['omniauth.auth'].info['email']
# reject if email is not zigexn nor ventura. # reject if email is not zigexn nor ventura.
......
class UsersController < ApplicationController class UsersController < ApplicationController
before_action :set_user, only: [:edit, :update] before_action :set_user, only: [:edit, :update]
def edit def edit
......
class WelcomeController < ApplicationController class WelcomeController < ApplicationController
skip_before_action :redirect_unless_signed_in skip_before_action :redirect_unless_signed_in
def top def top
......
...@@ -9,5 +9,4 @@ class ApisDecorator < Draper::Decorator ...@@ -9,5 +9,4 @@ class ApisDecorator < Draper::Decorator
# object.created_at.strftime("%a %m/%d/%y") # object.created_at.strftime("%a %m/%d/%y")
# end # end
# end # end
end end
...@@ -9,5 +9,4 @@ class FlowDecorator < Draper::Decorator ...@@ -9,5 +9,4 @@ class FlowDecorator < Draper::Decorator
# object.created_at.strftime("%a %m/%d/%y") # object.created_at.strftime("%a %m/%d/%y")
# end # end
# end # end
end end
...@@ -12,12 +12,12 @@ class PostDecorator < Draper::Decorator ...@@ -12,12 +12,12 @@ class PostDecorator < Draper::Decorator
# 読了時間 # 読了時間
# 500文字/1分換算 # 500文字/1分換算
def read_time def read_time
_time_min = model.body.length / 500 time_min = model.body.length / 500
case _time_min case time_min
when 0 when 0
'< 1 min.' '< 1 min.'
when 1..10 when 1..10
"#{_time_min} min." "#{time_min} min."
else else
'> 10 min.' '> 10 min.'
end end
...@@ -46,5 +46,4 @@ class PostDecorator < Draper::Decorator ...@@ -46,5 +46,4 @@ class PostDecorator < Draper::Decorator
'' ''
end end
end end
end end
class PostsDecorator < Draper::CollectionDecorator class PostsDecorator < Draper::CollectionDecorator
def related_tags def related_tags
_tags = self.map do |_post| tags = map(&:tags).flatten.uniq
_post.tags
end.flatten.uniq
TagDecorator.decorate_collection(_tags) TagDecorator.decorate_collection(tags)
end end
def related_authors def related_authors
self.map do |_post| map(&:author).flatten.uniq.map(&:decorate)
_post.author
end.flatten.uniq.map do |_author|
_author.decorate
end
end end
end end
...@@ -9,5 +9,4 @@ class SearchDecorator < Draper::Decorator ...@@ -9,5 +9,4 @@ class SearchDecorator < Draper::Decorator
# object.created_at.strftime("%a %m/%d/%y") # object.created_at.strftime("%a %m/%d/%y")
# end # end
# end # end
end end
...@@ -9,5 +9,4 @@ class StockDecorator < Draper::Decorator ...@@ -9,5 +9,4 @@ class StockDecorator < Draper::Decorator
# object.created_at.strftime("%a %m/%d/%y") # object.created_at.strftime("%a %m/%d/%y")
# end # end
# end # end
end end
...@@ -28,23 +28,22 @@ class TagDecorator < Draper::Decorator ...@@ -28,23 +28,22 @@ class TagDecorator < Draper::Decorator
# tagをtree viewで表示する # tagをtree viewで表示する
def tree_view_node def tree_view_node
_html = '' html = ''
_html += %Q{ html += %(
<a href="#{ self.show_path }" data-name="#{model.name}"> <a href="#{ show_path }" data-name="#{model.name}">
#{model.name} <span class="badge">#{model.posts.size}</span> #{model.name} <span class="badge">#{model.posts.size}</span>
</a> </a>
} )
_html += '<ul>' html += '<ul>'
model.children.each do |_child| model.children.each do |child|
_html += '<li>' html += '<li>'
_html << _child.decorate.tree_view_node html << child.decorate.tree_view_node
_html += '</li>' html += '</li>'
end end
_html += '</ul>' html += '</ul>'
_html.html_safe html.html_safe
end end
end end
class TagsDecorator < Draper::CollectionDecorator class TagsDecorator < Draper::CollectionDecorator
# tagをtree viewで表示する # tagをtree viewで表示する
def tree_view def tree_view
_html = '' html = ''
_html += %Q{ html += %(
<ul class="mod-tag-tree"> <ul class="mod-tag-tree">
<input type="search" class="mod-tag-tree-filter form-control" placeholder="filter..."> <input type="search" class="mod-tag-tree-filter form-control" placeholder="filter...">
} )
self.each do |_node| each do |node|
_html += %Q{ html += %(
<li> <li>
#{_node.decorate.tree_view_node} #{node.decorate.tree_view_node}
</li> </li>
} )
end end
_html += "</ul>" html += '</ul>'
_html.html_safe html.html_safe
end end
end end
...@@ -9,5 +9,4 @@ class TemplateDecorator < Draper::Decorator ...@@ -9,5 +9,4 @@ class TemplateDecorator < Draper::Decorator
# object.created_at.strftime("%a %m/%d/%y") # object.created_at.strftime("%a %m/%d/%y")
# end # end
# end # end
end end
...@@ -9,5 +9,4 @@ class UsersDecorator < Draper::Decorator ...@@ -9,5 +9,4 @@ class UsersDecorator < Draper::Decorator
# object.created_at.strftime("%a %m/%d/%y") # object.created_at.strftime("%a %m/%d/%y")
# end # end
# end # end
end end
...@@ -9,5 +9,4 @@ class WatchingDecorator < Draper::Decorator ...@@ -9,5 +9,4 @@ class WatchingDecorator < Draper::Decorator
# object.created_at.strftime("%a %m/%d/%y") # object.created_at.strftime("%a %m/%d/%y")
# end # end
# end # end
end end
module ApplicationHelper module ApplicationHelper
def h_application_format_markdown(text)
raise "deplicated error"
text = GitHub::Markdown.render_gfm(text)
text.html_safe
end
end end
...@@ -33,6 +33,7 @@ class Comment < ActiveRecord::Base ...@@ -33,6 +33,7 @@ class Comment < ActiveRecord::Base
###################################################################### ######################################################################
# Instance method # Instance method
###################################################################### ######################################################################
private private
def notify_watchers! def notify_watchers!
......
module HipchatIntegration module HipchatIntegration
# Call Hipchat API # Call Hipchat API
def notify_hipchat! def notify_hipchat!
require 'uri'
return if is_draft return if is_draft
client = HipChat::Client.new(Settings.hipchat.token) client = HipChat::Client.new(Settings.hipchat.token)
client[Settings.hipchat.room].send('Rendezvous', notify_hipchat_body, message_format:'text', notify: 1) room = URI.unescape(Settings.hipchat.room)
client[room].send('Rendezvous', notify_hipchat_body, message_format: 'text', notify: 1)
end end
# @return [String] notification body # @return [String] notification body
def notify_hipchat_body def notify_hipchat_body
<<EOF <<EOF
#{author.name}が「#{title}」を投稿しました。 #{author.name}が「#{title}」を投稿しました。
#{self.decorate.show_url} #{decorate.show_url}
-- --
#{body} #{body}
EOF EOF
......
...@@ -6,15 +6,15 @@ class MarkdownRenderer ...@@ -6,15 +6,15 @@ class MarkdownRenderer
# pdf viewerの変換 # pdf viewerの変換
# !slide!(file-url) -> %%slide:0%% -> <iframe>...</iframe> # !slide!(file-url) -> %%slide:0%% -> <iframe>...</iframe>
def render def render
# slideのurlを一時保管 # slideのurlを一時保管
slide_urls = [] slide_urls = []
text = @text.gsub(/!slide!\(([^\)]+)\)/) do |_| text = @text.gsub(/!slide!\(([^\)]+)\)/) do |_|
slide_urls << %Q{ slide_urls << %(
<div class="embed-responsive embed-responsive-4by3"> <div class="embed-responsive embed-responsive-4by3">
<iframe style="text-align:center;" src="/ViewerJS/##{$1}" width="400" height="300" allowfullscreen="true" webkitallowfullscreen="true"></iframe> <iframe style="text-align:center;" src="/ViewerJS/##{Regexp.last_match[1]}"
width="400" height="300" allowfullscreen="true" webkitallowfullscreen="true"></iframe>
</div> </div>
} )
"%%slide:#{slide_urls.size - 1}%%" "%%slide:#{slide_urls.size - 1}%%"
end end
...@@ -22,7 +22,7 @@ class MarkdownRenderer ...@@ -22,7 +22,7 @@ class MarkdownRenderer
# 保管したslide urlを取り出す # 保管したslide urlを取り出す
text = text.gsub(/%%slide:(\d+)%%/) do |_| text = text.gsub(/%%slide:(\d+)%%/) do |_|
slide_urls[$1.to_i] slide_urls[Regexp.last_match[1].to_i]
end end
text.html_safe text.html_safe
......
...@@ -19,13 +19,13 @@ class Notification < ActiveRecord::Base ...@@ -19,13 +19,13 @@ class Notification < ActiveRecord::Base
# Named scope # Named scope
###################################################################### ######################################################################
scope :unread, -> { scope :unread, (lambda do
where(is_read: false) where(is_read: false)
} end)
scope :recent, -> { scope :recent, (lambda do
where(arel_table[:created_at].gt 7.day.ago) where(arel_table[:created_at].gt 7.day.ago)
} end)
###################################################################### ######################################################################
# Instance method # Instance method
......
...@@ -27,8 +27,8 @@ class Post < ActiveRecord::Base ...@@ -27,8 +27,8 @@ class Post < ActiveRecord::Base
has_many :comments has_many :comments
has_many :footprints has_many :footprints
has_many :watches, :as => :watchable, :dependent => :destroy has_many :watches, as: :watchable, dependent: :destroy
has_many :watchers, :through => :watches has_many :watchers, through: :watches
###################################################################### ######################################################################
# Validations # Validations
...@@ -41,46 +41,46 @@ class Post < ActiveRecord::Base ...@@ -41,46 +41,46 @@ class Post < ActiveRecord::Base
###################################################################### ######################################################################
after_save :set_watcher! after_save :set_watcher!
after_save :notify_watchers! after_save :notify_watchers!
after_create :notify_hipchat! if Settings.respond_to?(:hipchat) after_create :notify_hipchat! if Settings.hipchat.token.present? && Settings.hipchat.room.present?
###################################################################### ######################################################################
# Named scope # Named scope
###################################################################### ######################################################################
scope :search, (lambda do |query| scope :search, (lambda do |query|
_where_list = includes(:author, :tags).order(updated_at: :desc) where_list = includes(:author, :tags).order(updated_at: :desc)
# Convert spaces to one space. # Convert spaces to one space.
query_list = query.split(/[\s ]+/) query_list = query.split(/[\s ]+/)
query_list.each do |_query| query_list.each do |where_query|
case _query case where_query
when /\Aid:(.+)/ when /\Aid:(.+)/
_where_list = _where_list.where(id: Regexp.last_match[1]) where_list = where_list.where(id: Regexp.last_match[1])
when /\Atitle:(.+)/ when /\Atitle:(.+)/
_where_list = _where_list.where('posts.title LIKE ?', "%#{Regexp.last_match[1]}%") where_list = where_list.where('posts.title LIKE ?', "%#{Regexp.last_match[1]}%")
when /\Abody:(.+)/ when /\Abody:(.+)/
_where_list = _where_list.where('posts.body LIKE ?', "%#{Regexp.last_match[1]}%") where_list = where_list.where('posts.body LIKE ?', "%#{Regexp.last_match[1]}%")
when /\A@(.+)/ when /\A@(.+)/
_where_list = _where_list.where(users: { nickname: Regexp.last_match[1] }) where_list = where_list.where(users: { nickname: Regexp.last_match[1] })
when /\A#(.+)/ when /\A#(.+)/
_where_list = _where_list.where(tags: { name: Regexp.last_match[1] }) where_list = where_list.where(tags: { name: Regexp.last_match[1] })
when /\Adate:(\d+)-(\d+)-(\d+)/ when /\Adate:(\d+)-(\d+)-(\d+)/
_date = Time.new(Regexp.last_match[1], Regexp.last_match[2], Regexp.last_match[3]) date = Time.new(Regexp.last_match[1], Regexp.last_match[2], Regexp.last_match[3])
_where_list = _where_list.where('posts.updated_at > ? AND posts.updated_at < ?', _date, _date + 1.day) where_list = where_list.where('posts.updated_at > ? AND posts.updated_at < ?', date, date + 1.day)
when /\Adraft:1/ when /\Adraft:1/
_where_list = _where_list.where(is_draft: true) where_list = where_list.where(is_draft: true)
else else
_where_list = _where_list.where('posts.title LIKE ? OR posts.body LIKE ?', "%#{_query}%", "%#{_query}%") where_list = where_list.where('posts.title LIKE ? OR posts.body LIKE ?', "%#{where_query}%", "%#{where_query}%")
end end
end end
_where_list where_list
end) end)
# 最新のPostを取得 # 最新のPostを取得
scope :recent, -> (limit = 10) { scope :recent, (lambda do |limit = 10|
order(updated_at: :desc).limit(limit) order(updated_at: :desc).limit(limit)
} end)
###################################################################### ######################################################################
# Instance method # Instance method
...@@ -88,35 +88,34 @@ class Post < ActiveRecord::Base ...@@ -88,35 +88,34 @@ class Post < ActiveRecord::Base
# generate forked post (not saved) # generate forked post (not saved)
def generate_fork(user) def generate_fork(user)
# `id`以外をコピーする # `id`以外をコピーする
_forked_post = Post.new(self.attributes.except('id')) forked_post = Post.new(attributes.except('id'))
# `%name`をユーザー名に置換 # `%name`をユーザー名に置換
_forked_post.title = _forked_post.title.gsub(/%name/, user.name) forked_post.title = forked_post.title.gsub(/%name/, user.name)
# `%Y`などを日付に変換 # `%Y`などを日付に変換
_forked_post.title = Time.now.strftime(_forked_post.title) # TODO forked_post.title = Time.now.strftime(forked_post.title) # TODO
_forked_post.title = _forked_post.title forked_post.title = forked_post.title
_forked_post.tag_ids = self.tag_ids forked_post.tag_ids = tag_ids
_forked_post.author = user forked_post.author = user
_forked_post.specified_date = Date.today forked_post.specified_date = Date.today
_forked_post forked_post
end end
# slideshow用のbody # slideshow用のbody
def body_for_slideshow def body_for_slideshow
self.body.gsub(/^#/, "---\n\n#") body.gsub(/^#/, "---\n\n#")
end end
def visited_user_count def visited_user_count
footprints.select(:user_id).uniq.count footprints.select(:user_id).uniq.count
end end
# FIXME: # FIXME: 正常に動作しないため動作しないため一時的にメソッドを作成
# has_many :watchers, :through => :watches # has_many :watchers, :through => :watches
# 正常に動作しないため動作しないため一時的にメソッドを作成 #
# def watchers # def watchers
# watches.map { |watch| watch.watcher } # watches.map { |watch| watch.watcher }
# end # end
......
...@@ -6,7 +6,7 @@ class S3Uploader ...@@ -6,7 +6,7 @@ class S3Uploader
# @param [String] bucket: uploading backet name. # @param [String] bucket: uploading backet name.
def initialize(access_key_id: Settings.s3.access_key_id, def initialize(access_key_id: Settings.s3.access_key_id,
secret_access_key: Settings.s3.secret_access_key, secret_access_key: Settings.s3.secret_access_key,
region: "ap-northeast-1", region: 'ap-northeast-1',
bucket:) bucket:)
@s3 = AWS::S3.new(access_key_id: access_key_id, @s3 = AWS::S3.new(access_key_id: access_key_id,
secret_access_key: secret_access_key, secret_access_key: secret_access_key,
......
...@@ -21,40 +21,36 @@ class Tag < ActiveRecord::Base ...@@ -21,40 +21,36 @@ class Tag < ActiveRecord::Base
# for versioning # for versioning
has_paper_trail has_paper_trail
default_scope { order(:updated_at => :desc) } default_scope { order(updated_at: :desc) }
scope :posts_exist, lambda { scope :posts_exist, lambda {
select('tags.*, count(posts.id) as posts_count'). select('tags.*, count(posts.id) as posts_count')
joins(:posts). .joins(:posts)
group('tags.id'). .group('tags.id')
having('posts_count > 0') .having('posts_count > 0')
} }
class << self class << self
# 最近投稿されたTagを取得 # 最近投稿されたTagを取得
def recent(limit=10) def recent(limit = 10)
Post.recent(20).map do |post| Post.recent(20).map(&:tags).flatten.compact.uniq.take(limit)
post.tags
end.flatten.compact.uniq.take(limit)
end end
end end
def recent_posts(limit = 30) def recent_posts(limit = 30)
self.posts.recent(limit) posts.recent(limit)
end end
# 自分のタグに紐づくPostをすべて`other_tag`へ移動する # 自分のタグに紐づくPostをすべて`other_tag`へ移動する
def move_all_posts_to!(other_tag) def move_all_posts_to!(other_tag)
self.posts.each do |_post| posts.each do |moving_post|
_post.tags.delete(self) moving_post.tags.delete(self)
_post.tags << other_tag unless _post.tags.include?(other_tag) moving_post.tags << other_tag unless moving_post.tags.include?(other_tag)
end end
end end
# 親タグを設定する # 親タグを設定する
def set_parent!(other_tag) def parent_tag=(other_tag)
self.parent = other_tag self.parent = other_tag
self.save! self.save!
end end
......
...@@ -41,19 +41,18 @@ class User < ActiveRecord::Base ...@@ -41,19 +41,18 @@ class User < ActiveRecord::Base
has_many :footprints has_many :footprints
has_many :watchings, class_name: 'Watch', foreign_key: 'watcher_id' has_many :watchings, class_name: 'Watch', foreign_key: 'watcher_id'
has_many :watching_posts, :through => :watchings, :source => :watchable, :source_type => "Post" has_many :watching_posts, through: :watchings, source: :watchable, source_type: 'Post'
###################################################################### ######################################################################
# scope # scope
###################################################################### ######################################################################
scope :post_recently, -> { scope :post_recently, (lambda do
User.joins(:posts).group('id').order('posts.updated_at desc') User.joins(:posts).group('id').order('posts.updated_at desc')
}
scope :search, (lambda do |_query|
where('name LIKE ? OR nickname LIKE ?', "%#{_query}%", "%#{_query}%")
end) end)
scope :search, (lambda do |query|
where('name LIKE ? OR nickname LIKE ?', "%#{query}%", "%#{query}%")
end)
###################################################################### ######################################################################
# Validations # Validations
...@@ -66,13 +65,12 @@ class User < ActiveRecord::Base ...@@ -66,13 +65,12 @@ class User < ActiveRecord::Base
validates :nickname, uniqueness: true validates :nickname, uniqueness: true
# Device # Device
def self.find_for_google_oauth2(access_token, signed_in_resource = nil) def self.find_for_google_oauth2(access_token, _signed_in_resource = nil)
user = where(email: access_token.info['email']).first_or_create do |u|
user = self.where(email: access_token.info['email']).first_or_create do |_user| u.name = access_token.info['name']
_user.name = access_token.info['name'] u.image_url = access_token.info['image']
_user.image_url = access_token.info['image'] u.password = Devise.friendly_token[0, 20]
_user.password = Devise.friendly_token[0, 20] u.nickname = (('a'..'z').to_a + ('A'..'Z').to_a + (0..9).to_a).shuffle[0..4].join
_user.nickname = (("a".."z").to_a + ("A".."Z").to_a + (0..9).to_a).shuffle[0..4].join
end end
user.update( user.update(
...@@ -96,8 +94,8 @@ class User < ActiveRecord::Base ...@@ -96,8 +94,8 @@ class User < ActiveRecord::Base
# refresh google oauth token # refresh google oauth token
def google_oauth_token_refresh! def google_oauth_token_refresh!
conn = Faraday.new(url: 'https://accounts.google.com') do |builder| conn = Faraday.new(url: 'https://accounts.google.com') do |builder|
builder.request :url_encoded builder.request :url_encoded
builder.adapter :net_http builder.adapter :net_http
end end
response = conn.post '/o/oauth2/token', response = conn.post '/o/oauth2/token',
client_id: Settings.google_api.client_id, client_id: Settings.google_api.client_id,
...@@ -115,9 +113,9 @@ class User < ActiveRecord::Base ...@@ -115,9 +113,9 @@ class User < ActiveRecord::Base
# push通知を追加 # push通知を追加
def push_notification(detail_path, body) def push_notification(detail_path, body)
unless notifications.where(detail_path: detail_path).unread.exists? return if notifications.where(detail_path: detail_path).unread.exists?
notifications.create(detail_path: detail_path, body: body, is_read: false)
end notifications.create(detail_path: detail_path, body: body, is_read: false)
end end
# record footprint # record footprint
...@@ -129,11 +127,11 @@ class User < ActiveRecord::Base ...@@ -129,11 +127,11 @@ class User < ActiveRecord::Base
if hash[:post] if hash[:post]
watching_posts << hash[:post] unless watching_posts.include?(hash[:post]) watching_posts << hash[:post] unless watching_posts.include?(hash[:post])
elsif hash[:tag] elsif hash[:tag]
raise 'Not Implemented.' fail 'Not Implemented.'
elsif hash[:user] elsif hash[:user]
raise 'Not Implemented.' fail 'Not Implemented.'
else else
raise 'No hash argument set.' fail 'No hash argument set.'
end end
end end
...@@ -141,11 +139,11 @@ class User < ActiveRecord::Base ...@@ -141,11 +139,11 @@ class User < ActiveRecord::Base
if hash[:post] if hash[:post]
hash[:post].watches.where(watcher: self).destroy_all hash[:post].watches.where(watcher: self).destroy_all
elsif hash[:tag] elsif hash[:tag]
raise 'Not Implemented.' fail 'Not Implemented.'
elsif hash[:user] elsif hash[:user]
raise 'Not Implemented.' fail 'Not Implemented.'
else else
raise 'No hash argument set.' fail 'No hash argument set.'
end end
end end
...@@ -155,11 +153,11 @@ class User < ActiveRecord::Base ...@@ -155,11 +153,11 @@ class User < ActiveRecord::Base
if hash[:post] if hash[:post]
hash[:post].watches.where(watcher: self).exists? hash[:post].watches.where(watcher: self).exists?
elsif hash[:tag] elsif hash[:tag]
raise 'Not Implemented.' fail 'Not Implemented.'
elsif hash[:user] elsif hash[:user]
raise 'Not Implemented.' fail 'Not Implemented.'
else else
raise 'No hash argument set.' fail 'No hash argument set.'
end end
end end
......
class Watch < ActiveRecord::Base class Watch < ActiveRecord::Base
###################################################################### ######################################################################
# Associations # Associations
###################################################################### ######################################################################
...@@ -10,5 +9,4 @@ class Watch < ActiveRecord::Base ...@@ -10,5 +9,4 @@ class Watch < ActiveRecord::Base
# Validations # Validations
###################################################################### ######################################################################
validates :watcher_id, uniqueness: { scope: [:watchable_type, :watchable_id] } validates :watcher_id, uniqueness: { scope: [:watchable_type, :watchable_id] }
end end
...@@ -9,6 +9,7 @@ html lang="ja" ...@@ -9,6 +9,7 @@ html lang="ja"
link href="//cdnjs.cloudflare.com/ajax/libs/fullcalendar/1.6.4/fullcalendar.css" rel="stylesheet" / link href="//cdnjs.cloudflare.com/ajax/libs/fullcalendar/1.6.4/fullcalendar.css" rel="stylesheet" /
link href="//cdnjs.cloudflare.com/ajax/libs/fullcalendar/1.6.4/fullcalendar.print.css" rel="stylesheet" / link href="//cdnjs.cloudflare.com/ajax/libs/fullcalendar/1.6.4/fullcalendar.print.css" rel="stylesheet" /
link href="//netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css" rel="stylesheet" link href="//netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css" rel="stylesheet"
= favicon_link_tag 'favicon.ico'
script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js" script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"
= render partial: 'partials/google_analytics' = render partial: 'partials/google_analytics'
= stylesheet_link_tag "application", media: "all" = stylesheet_link_tag "application", media: "all"
......
- if Settings.respond_to?(:google_analytics) && Settings.google_analytics.present? - if Settings.google_analytics.present?
javascript: javascript:
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
......
File mode changed from 100644 to 100755
...@@ -4,7 +4,7 @@ require 'rails/all' ...@@ -4,7 +4,7 @@ require 'rails/all'
# Require the gems listed in Gemfile, including any gems # Require the gems listed in Gemfile, including any gems
# you've limited to :test, :development, or :production. # you've limited to :test, :development, or :production.
Bundler.require(:default, Rails.env) Bundler.require(*Rails.groups)
module Rendezvous module Rendezvous
class Application < Rails::Application class Application < Rails::Application
...@@ -14,14 +14,11 @@ module Rendezvous ...@@ -14,14 +14,11 @@ module Rendezvous
# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone. # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
# Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC. # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
config.time_zone = 'Tokyo' # config.time_zone = 'Central Time (US & Canada)'
config.active_record.default_timezone = :local
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded. # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s] # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
I18n.enforce_available_locales = true # config.i18n.default_locale = :de
config.i18n.default_locale = 'ja'
# config.action_mailer.delivery_method = :action_gmailer # config.action_mailer.delivery_method = :action_gmailer
config.action_mailer.smtp_settings = { config.action_mailer.smtp_settings = {
...@@ -35,8 +32,7 @@ module Rendezvous ...@@ -35,8 +32,7 @@ module Rendezvous
# IP restriction. # IP restriction.
if Rails.env.production? && ENV['RV_ALLOW_IPS'] if Rails.env.production? && ENV['RV_ALLOW_IPS']
config.middleware.use Rack::Access, { "/" => ENV['RV_ALLOW_IPS'].split(/,/) } config.middleware.use Rack::Access, '/' => ENV['RV_ALLOW_IPS'].split(/,/)
end end
end end
end end
# Set up gems listed in the Gemfile. # Set up gems listed in the Gemfile.
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
require 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE']) require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])
...@@ -24,10 +24,10 @@ set :deploy_to, '/var/www/rendezvous' ...@@ -24,10 +24,10 @@ set :deploy_to, '/var/www/rendezvous'
# set :pty, true # set :pty, true
# Default value for :linked_files is [] # Default value for :linked_files is []
set :linked_files, %w{config/database.yml config/settings.yml} set :linked_files, %w(config/database.yml config/settings.yml)
# Default value for linked_dirs is [] # Default value for linked_dirs is []
set :linked_dirs, %w{bin log tmp/pids tmp/cache tmp/sockets vendor/bundle public/system} set :linked_dirs, %w(bin log tmp/pids tmp/cache tmp/sockets vendor/bundle public/system)
# Default value for default_env is {} # Default value for default_env is {}
# set :default_env, { path: "/opt/ruby/bin:$PATH" } # set :default_env, { path: "/opt/ruby/bin:$PATH" }
...@@ -38,7 +38,7 @@ set :keep_releases, 5 ...@@ -38,7 +38,7 @@ set :keep_releases, 5
set :rbenv_type, :system set :rbenv_type, :system
set :rbenv_ruby, '2.1.2' set :rbenv_ruby, '2.1.2'
set :rbenv_prefix, "RBENV_ROOT=#{fetch(:rbenv_path)} RBENV_VERSION=#{fetch(:rbenv_ruby)} #{fetch(:rbenv_path)}/bin/rbenv exec" set :rbenv_prefix, "RBENV_ROOT=#{fetch(:rbenv_path)} RBENV_VERSION=#{fetch(:rbenv_ruby)} #{fetch(:rbenv_path)}/bin/rbenv exec"
set :rbenv_map_bins, %w{rake gem bundle ruby rails} set :rbenv_map_bins, %w(rake gem bundle ruby rails)
set :rbenv_roles, :all # default value set :rbenv_roles, :all # default value
# namespace :deploy do # namespace :deploy do
......
...@@ -4,9 +4,9 @@ ...@@ -4,9 +4,9 @@
# server in each group is considered to be the first # server in each group is considered to be the first
# unless any hosts have the primary property set. # unless any hosts have the primary property set.
# Don't declare `role :all`, it's a meta role # Don't declare `role :all`, it's a meta role
role :app, %w{rendezvous} role :app, %w(rendezvous)
role :web, %w{rendezvous} role :web, %w(rendezvous)
role :db, %w{rendezvous} role :db, %w(rendezvous)
# Extended Server Syntax # Extended Server Syntax
# ====================== # ======================
...@@ -20,11 +20,11 @@ role :db, %w{rendezvous} ...@@ -20,11 +20,11 @@ role :db, %w{rendezvous}
# it's possible to pass any option but you need to keep in mind that net/ssh understand limited list of options # it's possible to pass any option but you need to keep in mind that net/ssh understand limited list of options
# you can see them in [net/ssh documentation](http://net-ssh.github.io/net-ssh/classes/Net/SSH.html#method-c-start) # you can see them in [net/ssh documentation](http://net-ssh.github.io/net-ssh/classes/Net/SSH.html#method-c-start)
# set it globally # set it globally
set :ssh_options, { set :ssh_options,
keys: %w(~/.ssh/id_rsa), keys: %w(~/.ssh/id_rsa),
forward_agent: true, forward_agent: true,
auth_methods: %w(publickey) auth_methods: %w(publickey)
}
# and/or per server # and/or per server
# server 'example.com', # server 'example.com',
# user: 'user_name', # user: 'user_name',
......
...@@ -4,9 +4,9 @@ ...@@ -4,9 +4,9 @@
# server in each group is considered to be the first # server in each group is considered to be the first
# unless any hosts have the primary property set. # unless any hosts have the primary property set.
# Don't declare `role :all`, it's a meta role # Don't declare `role :all`, it's a meta role
role :app, %w{rendezvous} role :app, %w(rendezvous)
role :web, %w{rendezvous} role :web, %w(rendezvous)
role :db, %w{rendezvous} role :db, %w(rendezvous)
# Extended Server Syntax # Extended Server Syntax
# ====================== # ======================
...@@ -14,7 +14,7 @@ role :db, %w{rendezvous} ...@@ -14,7 +14,7 @@ role :db, %w{rendezvous}
# definition into the server list. The second argument # definition into the server list. The second argument
# something that quacks like a hash can be used to set # something that quacks like a hash can be used to set
# extended properties on the server. # extended properties on the server.
server 'example.com', user: 'deploy', roles: %w{web app}, my_property: :my_value server 'example.com', user: 'deploy', roles: %w(web app), my_property: :my_value
# you can set custom ssh options # you can set custom ssh options
# it's possible to pass any option but you need to keep in mind that net/ssh understand limited list of options # it's possible to pass any option but you need to keep in mind that net/ssh understand limited list of options
......
...@@ -2,4 +2,4 @@ ...@@ -2,4 +2,4 @@
require File.expand_path('../application', __FILE__) require File.expand_path('../application', __FILE__)
# Initialize the Rails application. # Initialize the Rails application.
Rendezvous::Application.initialize! Rails.application.initialize!
Rendezvous::Application.configure do Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb. # Settings specified here will take precedence over those in config/application.rb.
# In the development environment your application's code is reloaded on # In the development environment your application's code is reloaded on
...@@ -19,7 +19,7 @@ Rendezvous::Application.configure do ...@@ -19,7 +19,7 @@ Rendezvous::Application.configure do
# Print deprecation notices to the Rails logger. # Print deprecation notices to the Rails logger.
config.active_support.deprecation = :log config.active_support.deprecation = :log
# Raise an error on page load if there are pending migrations # Raise an error on page load if there are pending migrations.
config.active_record.migration_error = :page_load config.active_record.migration_error = :page_load
# Debug mode disables concatenation and preprocessing of assets. # Debug mode disables concatenation and preprocessing of assets.
...@@ -27,6 +27,14 @@ Rendezvous::Application.configure do ...@@ -27,6 +27,14 @@ Rendezvous::Application.configure do
# number of complex assets. # number of complex assets.
config.assets.debug = true config.assets.debug = true
# Adds additional error checking when serving assets at runtime.
# Checks for improperly declared sprockets dependencies.
# Raises helpful error messages.
config.assets.raise_runtime_errors = true
# Raises error for missing translations
# config.action_view.raise_on_missing_translations = true
# Devise # Devise
config.action_mailer.default_url_options = { host: 'localhost:3000' } config.action_mailer.default_url_options = { host: 'localhost:3000' }
end end
Rendezvous::Application.configure do Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb. # Settings specified here will take precedence over those in config/application.rb.
# Code is not reloaded between requests. # Code is not reloaded between requests.
config.cache_classes = true config.cache_classes = true
# Eager load code on boot. This eager loads most of Rails and # Eager load code on boot. This eager loads most of Rails and
# your application in memory, allowing both thread web servers # your application in memory, allowing both threaded web servers
# and those relying on copy on write to perform better. # and those relying on copy on write to perform better.
# Rake tasks automatically ignore this option for performance. # Rake tasks automatically ignore this option for performance.
config.eager_load = true config.eager_load = true
...@@ -20,27 +20,26 @@ Rendezvous::Application.configure do ...@@ -20,27 +20,26 @@ Rendezvous::Application.configure do
# config.action_dispatch.rack_cache = true # config.action_dispatch.rack_cache = true
# Disable Rails's static asset server (Apache or nginx will already do this). # Disable Rails's static asset server (Apache or nginx will already do this).
config.serve_static_assets = true config.serve_static_assets = false
# Compress JavaScripts and CSS. # Compress JavaScripts and CSS.
config.assets.js_compressor = :uglifier config.assets.js_compressor = :uglifier
# config.assets.css_compressor = :sass # config.assets.css_compressor = :sass
# Do not fallback to assets pipeline if a precompiled asset is missed. # Do not fallback to assets pipeline if a precompiled asset is missed.
config.assets.compile = true config.assets.compile = false
# Generate digests for assets URLs. # Generate digests for assets URLs.
config.assets.digest = true config.assets.digest = true
# Version of your assets, change this if you want to expire all your assets. # `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb
config.assets.version = '1.0'
# Specifies the header that your server uses for sending files. # Specifies the header that your server uses for sending files.
# config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache # config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache
# config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx
# Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
# config.force_ssl = true config.force_ssl = true
# Set to :debug to see everything in the log. # Set to :debug to see everything in the log.
config.log_level = :info config.log_level = :info
...@@ -57,16 +56,12 @@ Rendezvous::Application.configure do ...@@ -57,16 +56,12 @@ Rendezvous::Application.configure do
# Enable serving of images, stylesheets, and JavaScripts from an asset server. # Enable serving of images, stylesheets, and JavaScripts from an asset server.
# config.action_controller.asset_host = "http://assets.example.com" # config.action_controller.asset_host = "http://assets.example.com"
# Precompile additional assets.
# application.js, application.css, and all non-JS/CSS in app/assets folder are already added.
# config.assets.precompile += %w( search.js )
# Ignore bad email addresses and do not raise email delivery errors. # Ignore bad email addresses and do not raise email delivery errors.
# Set this to true and configure the email server for immediate delivery to raise delivery errors. # Set this to true and configure the email server for immediate delivery to raise delivery errors.
# config.action_mailer.raise_delivery_errors = false # config.action_mailer.raise_delivery_errors = false
# Enable locale fallbacks for I18n (makes lookups for any locale fall back to # Enable locale fallbacks for I18n (makes lookups for any locale fall back to
# the I18n.default_locale when a translation can not be found). # the I18n.default_locale when a translation cannot be found).
config.i18n.fallbacks = true config.i18n.fallbacks = true
# Send deprecation notices to registered listeners. # Send deprecation notices to registered listeners.
...@@ -77,4 +72,7 @@ Rendezvous::Application.configure do ...@@ -77,4 +72,7 @@ Rendezvous::Application.configure do
# Use default logging formatter so that PID and timestamp are not suppressed. # Use default logging formatter so that PID and timestamp are not suppressed.
config.log_formatter = ::Logger::Formatter.new config.log_formatter = ::Logger::Formatter.new
# Do not dump schema after migrations.
config.active_record.dump_schema_after_migration = false
end end
Rendezvous::Application.configure do Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb. # Settings specified here will take precedence over those in config/application.rb.
# The test environment is used exclusively to run your application's # The test environment is used exclusively to run your application's
...@@ -33,4 +33,7 @@ Rendezvous::Application.configure do ...@@ -33,4 +33,7 @@ Rendezvous::Application.configure do
# Print deprecation notices to the stderr. # Print deprecation notices to the stderr.
config.active_support.deprecation = :stderr config.active_support.deprecation = :stderr
# Raises error for missing translations
# config.action_view.raise_on_missing_translations = true
end end
# Be sure to restart your server when you modify this file.
# Version of your assets, change this if you want to expire all your assets.
Rails.application.config.assets.version = '1.0'
# Precompile additional assets.
# application.js, application.css, and all non-JS/CSS in app/assets folder are already added.
# Rails.application.config.assets.precompile += %w( search.js )
# Be sure to restart your server when you modify this file.
Rails.application.config.action_dispatch.cookies_serializer = :json
...@@ -2,4 +2,3 @@ ...@@ -2,4 +2,3 @@
# Add new mime types for use in respond_to blocks: # Add new mime types for use in respond_to blocks:
# Mime::Type.register "text/richtext", :rtf # Mime::Type.register "text/richtext", :rtf
# Mime::Type.register_alias "text/html", :iphone
# Be sure to restart your server when you modify this file. # Be sure to restart your server when you modify this file.
Rendezvous::Application.config.session_store :cookie_store, Rails.application.config.session_store :cookie_store, key: '__rv'
key: '__rv__'
...@@ -15,7 +15,7 @@ common: &default_settings ...@@ -15,7 +15,7 @@ common: &default_settings
# You must specify the license key associated with your New Relic # You must specify the license key associated with your New Relic
# account. This key binds your Agent's data to your account in the # account. This key binds your Agent's data to your account in the
# New Relic service. # New Relic service.
license_key: '7bd008493661cbb36f85d52068addbe8ffecaf04' license_key: <%= ENV['RV_NEWRELIC_LICENSE_KEY'] %>
# Agent Enabled (Ruby/Rails Only) # Agent Enabled (Ruby/Rails Only)
# Use this setting to force the agent to run or not run. # Use this setting to force the agent to run or not run.
......
Rendezvous::Application.routes.draw do Rails.application.routes.draw do
# The priority is based upon order of creation: first created -> highest priority.
# See how all your routes lay out with "rake routes".
post 'apis/markdown_preview' post 'apis/markdown_preview'
post 'apis/file_receiver' post 'apis/file_receiver'
get 'apis/user_mention' get 'apis/user_mention'
get 'tags/:name/events' => 'tags#events', as: 'event_tag' get 'tags/:name/events' => 'tags#events', as: 'event_tag'
root 'welcome#top', as: 'root' root 'welcome#top', as: 'root'
get 'stock' => 'stock#show', as: 'stock' get 'stock' => 'stock#show', as: 'stock'
get 'flow' => 'flow#show', as: 'flow' get 'flow' => 'flow#show', as: 'flow'
get 'search' => 'search#show', as: 'search' get 'search' => 'search#show', as: 'search'
get 'templates' => 'templates#show', as: 'templates' get 'templates' => 'templates#show', as: 'templates'
get 'watchings' => 'watchings#show', as: 'watching' get 'watchings' => 'watchings#show', as: 'watching'
get 'posts/:id/fork' => 'posts#fork', as: 'fork_post' get 'posts/:id/fork' => 'posts#fork', as: 'fork_post'
post 'posts/:id/mail' => 'posts#mail', as: 'mail_post' post 'posts/:id/mail' => 'posts#mail', as: 'mail_post'
post 'posts/:id/comment' => 'posts#comment', as: 'comment_post' post 'posts/:id/comment' => 'posts#comment', as: 'comment_post'
get 'posts/:id/slideshow' => 'posts#slideshow', as: 'slideshow_post' get 'posts/:id/slideshow' => 'posts#slideshow', as: 'slideshow_post'
get 'posts/:id/watch' => 'posts#watch', as: 'watch_post' get 'posts/:id/watch' => 'posts#watch', as: 'watch_post'
resources :posts, except: [:index] resources :posts, except: [:index]
get 'notification_bridge/:id' => 'notifications#bridge', as: 'notification_bridge' get 'notification_bridge/:id' => 'notifications#bridge', as: 'notification_bridge'
post 'tags/:name/merge_to/:merge_to_name' => 'tags#merge_to', as: 'merge_to_tag' post 'tags/:name/merge_to/:merge_to_name' => 'tags#merge_to', as: 'merge_to_tag'
post 'tags/:name/move_to/:move_to_name' => 'tags#move_to', as: 'move_to_tag' post 'tags/:name/move_to/:move_to_name' => 'tags#move_to', as: 'move_to_tag'
resources :tags, :param => :name, except: [:index] resources :tags, param: :name, except: [:index]
devise_for :users, devise_for :users,
controllers: { controllers: {
omniauth_callbacks: 'users/omniauth_callbacks', omniauth_callbacks: 'users/omniauth_callbacks',
registrations: 'users/registrations' registrations: 'users/registrations'
}, },
skip: [ skip: [
:passwords, :passwords,
:registrations, :registrations
] ]
resource :user resource :user
# The priority is based upon order of creation: first created -> highest priority.
# See how all your routes lay out with "rake routes".
# You can have the root of your site routed with "root"
# Example of regular route:
# get 'products/:id' => 'catalog#view'
# Example of named route that can be invoked with purchase_url(id: product.id)
# get 'products/:id/purchase' => 'catalog#purchase', as: :purchase
# Example resource route (maps HTTP verbs to controller actions automatically):
# resources :products
# Example resource route with options:
# resources :products do
# member do
# get 'short'
# post 'toggle'
# end
#
# collection do
# get 'sold'
# end
# end
# Example resource route with sub-resources:
# resources :products do
# resources :comments, :sales
# resource :seller
# end
# Example resource route with more complex sub-resources:
# resources :products do
# resources :comments
# resources :sales do
# get 'recent', on: :collection
# end
# end
# Example resource route with concerns:
# concern :toggleable do
# post 'toggle'
# end
# resources :posts, concerns: :toggleable
# resources :photos, concerns: :toggleable
# Example resource route within a namespace:
# namespace :admin do
# # Directs /admin/products/* to Admin::ProductsController
# # (app/controllers/admin/products_controller.rb)
# resources :products
# end
end end
# Be sure to restart your server when you modify this file.
# Your secret key is used for verifying the integrity of signed cookies.
# If you change this key, all old signed cookies will become invalid!
# Make sure the secret is at least 30 characters and all random,
# no regular words or you'll be exposed to dictionary attacks.
# You can use `rake secret` to generate a secure secret key.
# Make sure the secrets in this file are kept private
# if you're sharing your code publicly.
development:
secret_key_base: 10b315a2bec1368349f72dbf72bf4a630fc84f0bebe9bd1abfe17998b001eabdb6a0f0495c575940ca10e40e1b0dd97bd020bccfed1a3fa99906280134f133a8
test:
secret_key_base: d3747f57595efccd82aaa1e6840a1b12097393859eec15c69bcad38830d9d48dd9eef2061d27b3a26730c8e279b87e134447e0624eb5b2fb356183e9c58efa21
# Do not keep production secrets in the repository,
# instead read values from the environment.
production:
secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>
...@@ -16,15 +16,15 @@ defaults: &defaults ...@@ -16,15 +16,15 @@ defaults: &defaults
bucket_name: <%= ENV['RV_S3_BACKET_NAME'] %> bucket_name: <%= ENV['RV_S3_BACKET_NAME'] %>
# optional # optional
# hipchat: hipchat:
# token: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' token: <%= ENV['RV_HIPCHAT_TOKEN'] %>
# room: 'xxxxxxxxxxx' room: <%= ENV['RV_HIPCHAT_ROOM'] %>
# optional # optional
# google_analytics: google_analytics: <%= ENV['RV_GOOGLE_ANALYTICS_ID'] %>
# optional # optional
pdf_uploading: <%= ENV['RV_PDF_UPLOADING'].present? %> enable_pdf_uploading: <%= ENV['RV_PDF_UPLOADING'].present? %>
development: development:
<<: *defaults <<: *defaults
......
worker_processes Integer(ENV["WEB_CONCURRENCY"] || 3) worker_processes Integer(ENV['WEB_CONCURRENCY'] || 3)
timeout 15 timeout 15
preload_app true preload_app true
before_fork do |server, worker| before_fork do |_server, _worker|
Signal.trap 'TERM' do Signal.trap 'TERM' do
puts 'Unicorn master intercepting TERM and sending myself QUIT instead' puts 'Unicorn master intercepting TERM and sending myself QUIT instead'
Process.kill 'QUIT', Process.pid Process.kill 'QUIT', Process.pid
end end
defined?(ActiveRecord::Base) and defined?(ActiveRecord::Base) &&
ActiveRecord::Base.connection.disconnect! ActiveRecord::Base.connection.disconnect!
end end
after_fork do |server, worker| after_fork do |_server, _worker|
Signal.trap 'TERM' do Signal.trap 'TERM' do
puts 'Unicorn worker intercepting TERM and doing nothing. Wait for master to send QUIT' puts 'Unicorn worker intercepting TERM and doing nothing. Wait for master to send QUIT'
end end
defined?(ActiveRecord::Base) and defined?(ActiveRecord::Base) &&
ActiveRecord::Base.establish_connection ActiveRecord::Base.establish_connection
end end
# paths # paths
app_path = "/var/www/rendezvous" app_path = '/var/www/rendezvous'
working_directory "#{app_path}/current" working_directory "#{app_path}/current"
pid "#{app_path}/current/tmp/pids/unicorn.pid" pid "#{app_path}/current/tmp/pids/unicorn.pid"
# listen # listen
listen "/tmp/unicorn-rendezvous.socket", :backlog => 64 listen '/tmp/unicorn-rendezvous.socket', backlog: 64
# logging # logging
stderr_path "log/unicorn.stderr.log" stderr_path 'log/unicorn.stderr.log'
stdout_path "log/unicorn.stdout.log" stdout_path 'log/unicorn.stdout.log'
# workers # workers
worker_processes 3 worker_processes 3
# use correct Gemfile on restarts # use correct Gemfile on restarts
before_exec do |server| before_exec do |_server|
ENV['BUNDLE_GEMFILE'] = "#{app_path}/current/Gemfile" ENV['BUNDLE_GEMFILE'] = "#{app_path}/current/Gemfile"
end end
# preload # preload
preload_app true preload_app true
before_fork do |server, worker| before_fork do |server, _worker|
# the following is highly recomended for Rails + "preload_app true" # the following is highly recomended for Rails + "preload_app true"
# as there's no need for the master process to hold a connection # as there's no need for the master process to hold a connection
if defined?(ActiveRecord::Base) if defined?(ActiveRecord::Base)
...@@ -31,16 +31,16 @@ before_fork do |server, worker| ...@@ -31,16 +31,16 @@ before_fork do |server, worker|
# Before forking, kill the master process that belongs to the .oldbin PID. # Before forking, kill the master process that belongs to the .oldbin PID.
# This enables 0 downtime deploys. # This enables 0 downtime deploys.
old_pid = "#{server.config[:pid]}.oldbin" old_pid = "#{server.config[:pid]}.oldbin"
if File.exists?(old_pid) && server.pid != old_pid if File.exist?(old_pid) && server.pid != old_pid
begin begin
Process.kill("QUIT", File.read(old_pid).to_i) Process.kill('QUIT', File.read(old_pid).to_i)
rescue Errno::ENOENT, Errno::ESRCH rescue Errno::ENOENT, Errno::ESRCH
# someone else did our job for us # someone else did our job for us
end end
end end
end end
after_fork do |server, worker| after_fork do |_server, _worker|
if defined?(ActiveRecord::Base) if defined?(ActiveRecord::Base)
ActiveRecord::Base.establish_connection ActiveRecord::Base.establish_connection
end end
......
...@@ -6,18 +6,18 @@ class AddDeviseToUsers < ActiveRecord::Migration ...@@ -6,18 +6,18 @@ class AddDeviseToUsers < ActiveRecord::Migration
t.string :encrypted_password, null: false, default: '' t.string :encrypted_password, null: false, default: ''
## Recoverable ## Recoverable
t.string :reset_password_token t.string :reset_password_token
t.datetime :reset_password_sent_at t.datetime :reset_password_sent_at
## Rememberable ## Rememberable
t.datetime :remember_created_at t.datetime :remember_created_at
## Trackable ## Trackable
t.integer :sign_in_count, default: 0, null: false t.integer :sign_in_count, default: 0, null: false
t.datetime :current_sign_in_at t.datetime :current_sign_in_at
t.datetime :last_sign_in_at t.datetime :last_sign_in_at
t.string :current_sign_in_ip t.string :current_sign_in_ip
t.string :last_sign_in_ip t.string :last_sign_in_ip
## Confirmable ## Confirmable
# t.string :confirmation_token # t.string :confirmation_token
......
class CreateVersions < ActiveRecord::Migration class CreateVersions < ActiveRecord::Migration
def self.up def self.up
create_table :versions do |t| create_table :versions do |t|
t.string :item_type, :null => false t.string :item_type, null: false
t.integer :item_id, :null => false t.integer :item_id, null: false
t.string :event, :null => false t.string :event, null: false
t.string :whodunnit t.string :whodunnit
t.text :object t.text :object
t.datetime :created_at t.datetime :created_at
end end
add_index :versions, [:item_type, :item_id] add_index :versions, [:item_type, :item_id]
......
...@@ -2,6 +2,6 @@ class AddNicknameToUsers < ActiveRecord::Migration ...@@ -2,6 +2,6 @@ class AddNicknameToUsers < ActiveRecord::Migration
def change def change
add_column :users, :nickname, :string, default: '', null: false add_column :users, :nickname, :string, default: '', null: false
add_index "users", ["nickname"] add_index 'users', ['nickname']
end end
end end
...@@ -2,7 +2,7 @@ class CreateWatches < ActiveRecord::Migration ...@@ -2,7 +2,7 @@ class CreateWatches < ActiveRecord::Migration
def change def change
create_table :watches do |t| create_table :watches do |t|
t.integer :watcher_id, null: false t.integer :watcher_id, null: false
t.string :watchable_type, null: false t.string :watchable_type, null: false
t.integer :watchable_id, null: false t.integer :watchable_id, null: false
t.timestamps t.timestamps
......
...@@ -13,117 +13,117 @@ ...@@ -13,117 +13,117 @@
ActiveRecord::Schema.define(version: 20140719145016) do ActiveRecord::Schema.define(version: 20140719145016) do
create_table "comments", force: true do |t| create_table 'comments', force: true do |t|
t.integer "author_id" t.integer 'author_id'
t.integer "post_id" t.integer 'post_id'
t.text "body" t.text 'body'
t.datetime "created_at" t.datetime 'created_at'
t.datetime "updated_at" t.datetime 'updated_at'
end end
add_index "comments", ["author_id", "updated_at"], name: "index_comments_on_author_id_and_updated_at", using: :btree add_index 'comments', ['author_id', 'updated_at'], name: 'index_comments_on_author_id_and_updated_at', using: :btree
add_index "comments", ["post_id", "updated_at"], name: "index_comments_on_post_id_and_updated_at", using: :btree add_index 'comments', ['post_id', 'updated_at'], name: 'index_comments_on_post_id_and_updated_at', using: :btree
create_table "footprints", force: true do |t| create_table 'footprints', force: true do |t|
t.integer "user_id", null: false t.integer 'user_id', null: false
t.integer "post_id", null: false t.integer 'post_id', null: false
t.datetime "created_at" t.datetime 'created_at'
t.datetime "updated_at" t.datetime 'updated_at'
end end
add_index "footprints", ["post_id"], name: "index_footprints_on_post_id", using: :btree add_index 'footprints', ['post_id'], name: 'index_footprints_on_post_id', using: :btree
add_index "footprints", ["user_id", "post_id"], name: "index_footprints_on_user_id_and_post_id", using: :btree add_index 'footprints', ['user_id', 'post_id'], name: 'index_footprints_on_user_id_and_post_id', using: :btree
create_table "notifications", force: true do |t| create_table 'notifications', force: true do |t|
t.integer "user_id" t.integer 'user_id'
t.datetime "read_at" t.datetime 'read_at'
t.boolean "is_read", default: false, null: false t.boolean 'is_read', default: false, null: false
t.string "detail_path" t.string 'detail_path'
t.text "body" t.text 'body'
t.datetime "created_at" t.datetime 'created_at'
t.datetime "updated_at" t.datetime 'updated_at'
end end
add_index "notifications", ["user_id", "is_read", "read_at"], name: "index_notifications_on_user_id_and_is_read_and_read_at", using: :btree add_index 'notifications', ['user_id', 'is_read', 'read_at'], name: 'index_notifications_on_user_id_and_is_read_and_read_at', using: :btree
create_table "post_tags", force: true do |t| create_table 'post_tags', force: true do |t|
t.integer "post_id", null: false t.integer 'post_id', null: false
t.integer "tag_id", null: false t.integer 'tag_id', null: false
t.datetime "created_at" t.datetime 'created_at'
t.datetime "updated_at" t.datetime 'updated_at'
end end
add_index "post_tags", ["post_id"], name: "index_post_tags_on_post_id", using: :btree add_index 'post_tags', ['post_id'], name: 'index_post_tags_on_post_id', using: :btree
add_index "post_tags", ["tag_id"], name: "index_post_tags_on_tag_id", using: :btree add_index 'post_tags', ['tag_id'], name: 'index_post_tags_on_tag_id', using: :btree
create_table "posts", force: true do |t| create_table 'posts', force: true do |t|
t.string "title" t.string 'title'
t.text "body" t.text 'body'
t.integer "author_id" t.integer 'author_id'
t.datetime "created_at" t.datetime 'created_at'
t.datetime "updated_at" t.datetime 'updated_at'
t.boolean "is_draft", default: false t.boolean 'is_draft', default: false
t.date "specified_date" t.date 'specified_date'
end end
add_index "posts", ["is_draft"], name: "index_posts_on_is_draft", using: :btree add_index 'posts', ['is_draft'], name: 'index_posts_on_is_draft', using: :btree
create_table "tags", force: true do |t| create_table 'tags', force: true do |t|
t.string "name" t.string 'name'
t.datetime "created_at" t.datetime 'created_at'
t.datetime "updated_at" t.datetime 'updated_at'
t.string "ancestry" t.string 'ancestry'
t.text "body" t.text 'body'
t.integer "posts_count", default: 0, null: false t.integer 'posts_count', default: 0, null: false
end end
add_index "tags", ["ancestry"], name: "index_tags_on_ancestry", using: :btree add_index 'tags', ['ancestry'], name: 'index_tags_on_ancestry', using: :btree
create_table "users", force: true do |t| create_table 'users', force: true do |t|
t.string "name" t.string 'name'
t.string "image_url" t.string 'image_url'
t.datetime "created_at" t.datetime 'created_at'
t.datetime "updated_at" t.datetime 'updated_at'
t.string "email", default: "", null: false t.string 'email', default: '', null: false
t.string "encrypted_password", default: "", null: false t.string 'encrypted_password', default: '', null: false
t.string "reset_password_token" t.string 'reset_password_token'
t.datetime "reset_password_sent_at" t.datetime 'reset_password_sent_at'
t.datetime "remember_created_at" t.datetime 'remember_created_at'
t.integer "sign_in_count", default: 0, null: false t.integer 'sign_in_count', default: 0, null: false
t.datetime "current_sign_in_at" t.datetime 'current_sign_in_at'
t.datetime "last_sign_in_at" t.datetime 'last_sign_in_at'
t.string "current_sign_in_ip" t.string 'current_sign_in_ip'
t.string "last_sign_in_ip" t.string 'last_sign_in_ip'
t.string "google_auth_token" t.string 'google_auth_token'
t.string "google_refresh_token" t.string 'google_refresh_token'
t.datetime "google_token_expires_at" t.datetime 'google_token_expires_at'
t.string "nickname", default: "", null: false t.string 'nickname', default: '', null: false
end end
add_index "users", ["email"], name: "index_users_on_email", unique: true, using: :btree add_index 'users', ['email'], name: 'index_users_on_email', unique: true, using: :btree
add_index "users", ["nickname"], name: "index_users_on_nickname", using: :btree add_index 'users', ['nickname'], name: 'index_users_on_nickname', using: :btree
add_index "users", ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true, using: :btree add_index 'users', ['reset_password_token'], name: 'index_users_on_reset_password_token', unique: true, using: :btree
create_table "versions", force: true do |t| create_table 'versions', force: true do |t|
t.string "item_type", null: false t.string 'item_type', null: false
t.integer "item_id", null: false t.integer 'item_id', null: false
t.string "event", null: false t.string 'event', null: false
t.string "whodunnit" t.string 'whodunnit'
t.text "object" t.text 'object'
t.datetime "created_at" t.datetime 'created_at'
end end
add_index "versions", ["item_type", "item_id"], name: "index_versions_on_item_type_and_item_id", using: :btree add_index 'versions', ['item_type', 'item_id'], name: 'index_versions_on_item_type_and_item_id', using: :btree
create_table "watches", force: true do |t| create_table 'watches', force: true do |t|
t.integer "watcher_id", null: false t.integer 'watcher_id', null: false
t.string "watchable_type", null: false t.string 'watchable_type', null: false
t.integer "watchable_id", null: false t.integer 'watchable_id', null: false
t.datetime "created_at" t.datetime 'created_at'
t.datetime "updated_at" t.datetime 'updated_at'
end end
add_index "watches", ["watchable_type", "watchable_id"], name: "index_watches_on_watchable_type_and_watchable_id", using: :btree add_index 'watches', ['watchable_type', 'watchable_id'], name: 'index_watches_on_watchable_type_and_watchable_id', using: :btree
add_index "watches", ["watcher_id", "watchable_type", "watchable_id"], name: "index_watches_on_watcher_id_and_watchable_type_and_watchable_id", unique: true, using: :btree add_index 'watches', ['watcher_id', 'watchable_type', 'watchable_id'], name: 'index_watches_on_watcher_id_and_watchable_type_and_watchable_id', unique: true, using: :btree
end end
...@@ -24,7 +24,7 @@ _tag_tree = [ ...@@ -24,7 +24,7 @@ _tag_tree = [
['OS', 'CentOS'], ['OS', 'CentOS'],
['OS', 'Ubuntu'], ['OS', 'Ubuntu'],
['OS', 'MacOS'], ['OS', 'MacOS'],
['OS', 'Windows'], ['OS', 'Windows']
] ]
tags = [] tags = []
......
...@@ -4,10 +4,8 @@ namespace :batch do ...@@ -4,10 +4,8 @@ namespace :batch do
desc 'Tagに関連するPostのcounter_cacheの再生成' desc 'Tagに関連するPostのcounter_cacheの再生成'
task reset_counters: :environment do task reset_counters: :environment do
puts "\t[START] batch:reset_counters" puts "\t[START] batch:reset_counters"
Tag.all.each{|t| Tag.reset_counters(t.id, :posts) } Tag.all.each { |t| Tag.reset_counters(t.id, :posts) }
puts "\t[FINISH] batch:reset_counters" puts "\t[FINISH] batch:reset_counters"
end end
end end
...@@ -3,11 +3,11 @@ namespace :migrations do ...@@ -3,11 +3,11 @@ namespace :migrations do
desc '001 nicknameを自動付与' desc '001 nicknameを自動付与'
task task_001_user_nickname: :environment do task task_001_user_nickname: :environment do
User.all.each do |_user| User.all.each do |user|
next if _user.nickname.present? next if user.nickname.present?
new_nickname = (("a".."z").to_a + ("A".."Z").to_a + (0..9).to_a).shuffle[0..4].join new_nickname = (('a'..'z').to_a + ('A'..'Z').to_a + (0..9).to_a).shuffle[0..4].join
_user.update_attributes!(nickname: new_nickname) user.update_attributes!(nickname: new_nickname)
end end
end end
......
# See http://www.robotstxt.org/wc/norobots.html for documentation on how to use the robots.txt file # See http://www.robotstxt.org/wc/norobots.html for documentation on how to use the robots.txt file
# #
# To ban all spiders from the entire site uncomment the next two lines: # To ban all spiders from the entire site uncomment the next two lines:
# User-agent: * User-agent: *
# Disallow: / Disallow: /
require "digest" require 'digest'
require "fog" require 'fog'
bucket_name = ENV["AWS_S3_BUCKET"] bucket_name = ENV['AWS_S3_BUCKET']
architecture = `uname -m`.strip architecture = `uname -m`.strip
file_name = "#{ENV['BUNDLE_ARCHIVE']}-#{architecture}.tgz" file_name = "#{ENV['BUNDLE_ARCHIVE']}-#{architecture}.tgz"
file_path = File.expand_path("~/#{file_name}") file_path = File.expand_path("~/#{file_name}")
lock_file = File.join(File.expand_path(ENV["TRAVIS_BUILD_DIR"]), "Gemfile.lock") lock_file = File.join(File.expand_path(ENV['TRAVIS_BUILD_DIR']), 'Gemfile.lock')
digest_filename = "#{file_name}.sha2" digest_filename = "#{file_name}.sha2"
old_digest = File.expand_path("~/remote_#{digest_filename}") old_digest = File.expand_path("~/remote_#{digest_filename}")
puts "Checking for changes" puts 'Checking for changes'
bundle_digest = Digest::SHA2.file(lock_file).hexdigest bundle_digest = Digest::SHA2.file(lock_file).hexdigest
old_digest = File.exists?(old_digest) ? File.read(old_digest) : "" old_digest = File.exist?(old_digest) ? File.read(old_digest) : ''
if bundle_digest == old_digest if bundle_digest == old_digest
puts "=> There were no changes, doing nothing" puts '=> There were no changes, doing nothing'
else else
if old_digest == "" if old_digest == ''
puts "=> There was no existing digest, uploading a new version of the archive" puts '=> There was no existing digest, uploading a new version of the archive'
else else
puts "=> There were changes, uploading a new version of the archive" puts '=> There were changes, uploading a new version of the archive'
puts " => Old checksum: #{old_digest}" puts " => Old checksum: #{old_digest}"
puts " => New checksum: #{bundle_digest}" puts " => New checksum: #{bundle_digest}"
end end
puts "=> Preparing bundle archive" puts '=> Preparing bundle archive'
`cd ~ && tar -cjf #{file_name} .bundle && split -b 5m -a 3 #{file_name} #{file_name}.` `cd ~ && tar -cjf #{file_name} .bundle && split -b 5m -a 3 #{file_name} #{file_name}.`
parts_pattern = File.expand_path(File.join("~", "#{file_name}.*")) parts_pattern = File.expand_path(File.join('~', "#{file_name}.*"))
parts = Dir.glob(parts_pattern).sort parts = Dir.glob(parts_pattern).sort
storage = Fog::Storage.new({ storage = Fog::Storage.new(
:provider => "AWS", provider: 'AWS',
:aws_access_key_id => ENV["AWS_S3_KEY"], aws_access_key_id: ENV['AWS_S3_KEY'],
:aws_secret_access_key => ENV["AWS_S3_SECRET"], aws_secret_access_key: ENV['AWS_S3_SECRET'],
:region => ENV["AWS_S3_REGION"] || "us-east-1" region: ENV['AWS_S3_REGION'] || 'us-east-1'
}) )
puts "=> Uploading the bundle" puts '=> Uploading the bundle'
puts " => Beginning multipart upload" puts ' => Beginning multipart upload'
response = storage.initiate_multipart_upload bucket_name, file_name, { "x-amz-acl" => "public-read" } response = storage.initiate_multipart_upload bucket_name, file_name, 'x-amz-acl' => 'public-read'
upload_id = response.body['UploadId'] upload_id = response.body['UploadId']
puts " => Upload ID: #{upload_id}" puts " => Upload ID: #{upload_id}"
...@@ -53,22 +53,22 @@ else ...@@ -53,22 +53,22 @@ else
File.open part do |part_file| File.open part do |part_file|
response = storage.upload_part bucket_name, file_name, upload_id, part_number, part_file response = storage.upload_part bucket_name, file_name, upload_id, part_number, part_file
part_ids << response.headers['ETag'] part_ids << response.headers['ETag']
puts " => Uploaded" puts ' => Uploaded'
end end
end end
puts " => Completing multipart upload" puts ' => Completing multipart upload'
storage.complete_multipart_upload bucket_name, file_name, upload_id, part_ids storage.complete_multipart_upload bucket_name, file_name, upload_id, part_ids
puts "=> Uploading the digest file" puts '=> Uploading the digest file'
bucket = storage.directories.new(key: bucket_name) bucket = storage.directories.new(key: bucket_name)
bucket.files.create({ bucket.files.create(
:body => bundle_digest, body: bundle_digest,
:key => digest_filename, key: digest_filename,
:public => true, public: true,
:content_type => "text/plain" content_type: 'text/plain'
}) )
end end
puts "All done now." puts 'All done now.'
exit 0 exit 0
...@@ -3,14 +3,14 @@ require 'rails_helper' ...@@ -3,14 +3,14 @@ require 'rails_helper'
describe ApisController, type: :controller do describe ApisController, type: :controller do
describe "GET 'markdown_preview'" do describe "GET 'markdown_preview'" do
it "returns http redirect" do it 'returns http redirect' do
get 'markdown_preview' get 'markdown_preview'
expect(response).to redirect_to('/') expect(response).to redirect_to('/')
end end
end end
describe "GET 'markdown_preview'" do describe "GET 'markdown_preview'" do
it "returns http success" do it 'returns http success' do
sign_in FactoryGirl.create(:alice) sign_in FactoryGirl.create(:alice)
get 'markdown_preview' get 'markdown_preview'
......
...@@ -3,14 +3,14 @@ require 'rails_helper' ...@@ -3,14 +3,14 @@ require 'rails_helper'
describe FlowController, type: :controller do describe FlowController, type: :controller do
describe "GET 'show' without login" do describe "GET 'show' without login" do
it "returns http redirect" do it 'returns http redirect' do
get 'show' get 'show'
expect(response).to redirect_to('/') expect(response).to redirect_to('/')
end end
end end
describe "GET 'show' with login" do describe "GET 'show' with login" do
it "returns http success" do it 'returns http success' do
sign_in FactoryGirl.create(:alice) sign_in FactoryGirl.create(:alice)
get 'show' get 'show'
......
...@@ -5,7 +5,7 @@ describe PostsController, type: :controller do ...@@ -5,7 +5,7 @@ describe PostsController, type: :controller do
let(:post) { FactoryGirl.create(:post) } let(:post) { FactoryGirl.create(:post) }
describe "GET 'show' without login" do describe "GET 'show' without login" do
it "returns http redirect" do it 'returns http redirect' do
get 'show', id: post.id get 'show', id: post.id
expect(response).to redirect_to('/') expect(response).to redirect_to('/')
end end
...@@ -15,14 +15,14 @@ describe PostsController, type: :controller do ...@@ -15,14 +15,14 @@ describe PostsController, type: :controller do
let(:alice) { FactoryGirl.create(:alice) } let(:alice) { FactoryGirl.create(:alice) }
it "returns http success" do it 'returns http success' do
sign_in FactoryGirl.create(:alice) sign_in FactoryGirl.create(:alice)
get 'show', id: post.id get 'show', id: post.id
expect(response).to be_success expect(response).to be_success
end end
it "returns http success" do it 'returns http success' do
sign_in alice sign_in alice
get 'show', id: post.id get 'show', id: post.id
......
...@@ -3,14 +3,14 @@ require 'rails_helper' ...@@ -3,14 +3,14 @@ require 'rails_helper'
describe SearchController, type: :controller do describe SearchController, type: :controller do
describe "GET 'show' without login" do describe "GET 'show' without login" do
it "returns http redirect" do it 'returns http redirect' do
get 'show' get 'show'
expect(response).to redirect_to('/') expect(response).to redirect_to('/')
end end
end end
describe "GET 'show' with login" do describe "GET 'show' with login" do
it "returns http success" do it 'returns http success' do
sign_in FactoryGirl.create(:alice) sign_in FactoryGirl.create(:alice)
get 'show' get 'show'
......
...@@ -3,14 +3,14 @@ require 'rails_helper' ...@@ -3,14 +3,14 @@ require 'rails_helper'
describe StockController, type: :controller do describe StockController, type: :controller do
describe "GET 'show' without login" do describe "GET 'show' without login" do
it "returns http redirect" do it 'returns http redirect' do
get 'show' get 'show'
expect(response).to redirect_to('/') expect(response).to redirect_to('/')
end end
end end
describe "GET 'show' with login" do describe "GET 'show' with login" do
it "returns http success" do it 'returns http success' do
sign_in FactoryGirl.create(:alice) sign_in FactoryGirl.create(:alice)
get 'show' get 'show'
......
...@@ -5,14 +5,14 @@ describe TagsController, type: :controller do ...@@ -5,14 +5,14 @@ describe TagsController, type: :controller do
let(:tag) { FactoryGirl.create(:tag_ruby) } let(:tag) { FactoryGirl.create(:tag_ruby) }
describe "GET 'show' without login" do describe "GET 'show' without login" do
it "returns http redirect" do it 'returns http redirect' do
get 'show', name: tag.name get 'show', name: tag.name
expect(response).to redirect_to('/') expect(response).to redirect_to('/')
end end
end end
describe "GET 'show' with login" do describe "GET 'show' with login" do
it "returns http success" do it 'returns http success' do
sign_in FactoryGirl.create(:alice) sign_in FactoryGirl.create(:alice)
get 'show', name: tag.name get 'show', name: tag.name
......
require 'rails_helper' require 'rails_helper'
RSpec.describe TemplatesController, :type => :controller do RSpec.describe TemplatesController, type: :controller do
describe "GET 'show' without template" do describe "GET 'show' without template" do
it "returns http success" do it 'returns http success' do
sign_in FactoryGirl.create(:alice) sign_in FactoryGirl.create(:alice)
get 'show' get 'show'
...@@ -12,7 +12,7 @@ RSpec.describe TemplatesController, :type => :controller do ...@@ -12,7 +12,7 @@ RSpec.describe TemplatesController, :type => :controller do
end end
describe "GET 'show' with template" do describe "GET 'show' with template" do
it "returns http success" do it 'returns http success' do
sign_in FactoryGirl.create(:alice) sign_in FactoryGirl.create(:alice)
get 'show' get 'show'
......
...@@ -3,20 +3,20 @@ require 'rails_helper' ...@@ -3,20 +3,20 @@ require 'rails_helper'
describe UsersController, type: :controller do describe UsersController, type: :controller do
describe "GET 'edit'" do describe "GET 'edit'" do
it "returns http success" do it 'returns http success' do
sign_in FactoryGirl.create(:alice) sign_in FactoryGirl.create(:alice)
get :edit get :edit
response.should be_success expect(response).to be_success
end end
end end
describe "GET 'update'" do describe "GET 'update'" do
it "returns http success" do it 'returns http success' do
sign_in FactoryGirl.create(:alice) sign_in FactoryGirl.create(:alice)
patch :update, user: { nickname: 'bob' } patch :update, user: { nickname: 'bob' }
response.should redirect_to('/user/edit') expect(response).to redirect_to('/user/edit')
end end
end end
......
require 'rails_helper' require 'rails_helper'
RSpec.describe WatchingsController, :type => :controller do RSpec.describe WatchingsController, type: :controller do
describe "GET 'show' without login" do describe "GET 'show' without login" do
it "returns http redirect" do it 'returns http redirect' do
get 'show' get 'show'
expect(response).to redirect_to('/') expect(response).to redirect_to('/')
end end
end end
describe "GET 'show' with login" do describe "GET 'show' with login" do
it "returns http success" do it 'returns http success' do
sign_in FactoryGirl.create(:alice) sign_in FactoryGirl.create(:alice)
get 'show' get 'show'
......
...@@ -10,6 +10,6 @@ require 'rails_helper' ...@@ -10,6 +10,6 @@ require 'rails_helper'
# end # end
# end # end
# end # end
RSpec.describe TemplatesHelper, :type => :helper do RSpec.describe TemplatesHelper, type: :helper do
pending "add some examples to (or delete) #{__FILE__}" pending "add some examples to (or delete) #{__FILE__}"
end end
...@@ -10,6 +10,6 @@ require 'rails_helper' ...@@ -10,6 +10,6 @@ require 'rails_helper'
# end # end
# end # end
# end # end
RSpec.describe WatchingsHelper, :type => :helper do RSpec.describe WatchingsHelper, type: :helper do
pending "add some examples to (or delete) #{__FILE__}" pending "add some examples to (or delete) #{__FILE__}"
end end
...@@ -11,6 +11,6 @@ ...@@ -11,6 +11,6 @@
require 'rails_helper' require 'rails_helper'
RSpec.describe Footprint, :type => :model do RSpec.describe Footprint, type: :model do
pending "add some examples to (or delete) #{__FILE__}" pending "add some examples to (or delete) #{__FILE__}"
end end
require 'rails_helper' require 'rails_helper'
RSpec.describe MarkdownRenderer, :type => :model do RSpec.describe MarkdownRenderer, type: :model do
it "tests #render" do it 'tests #render' do
renderer = MarkdownRenderer.new(<<EOS) renderer = MarkdownRenderer.new(<<EOS)
# title # title
- body - body
- test - test
EOS EOS
expect(renderer.render.to_s.gsub(/^ +/, '')).to eq(<<EOS) expect(renderer.render.to_s.gsub(/^ +/, '')).to eq(<<EOS)
<h1>title</h1> <h1>title</h1>
...@@ -18,7 +19,7 @@ EOS ...@@ -18,7 +19,7 @@ EOS
EOS EOS
end end
it "tests #render with slides" do it 'tests #render with slides' do
renderer = MarkdownRenderer.new(<<EOS) renderer = MarkdownRenderer.new(<<EOS)
!slide!(http://test.com/slide-1.pdf) !slide!(http://test.com/slide-1.pdf)
!slide!(http://test.com/slide-2.pdf) !slide!(http://test.com/slide-2.pdf)
...@@ -26,12 +27,14 @@ EOS ...@@ -26,12 +27,14 @@ EOS
expect(renderer.render.to_s.gsub(/^ +/, '')).to eq(<<EOS) expect(renderer.render.to_s.gsub(/^ +/, '')).to eq(<<EOS)
<p> <p>
<div class="embed-responsive embed-responsive-4by3"> <div class="embed-responsive embed-responsive-4by3">
<iframe style="text-align:center;" src="/ViewerJS/#http://test.com/slide-1.pdf" width="400" height="300" allowfullscreen="true" webkitallowfullscreen="true"></iframe> <iframe style="text-align:center;" src="/ViewerJS/#http://test.com/slide-1.pdf"
width="400" height="300" allowfullscreen="true" webkitallowfullscreen="true"></iframe>
</div> </div>
<br> <br>
<div class="embed-responsive embed-responsive-4by3"> <div class="embed-responsive embed-responsive-4by3">
<iframe style="text-align:center;" src="/ViewerJS/#http://test.com/slide-2.pdf" width="400" height="300" allowfullscreen="true" webkitallowfullscreen="true"></iframe> <iframe style="text-align:center;" src="/ViewerJS/#http://test.com/slide-2.pdf"
width="400" height="300" allowfullscreen="true" webkitallowfullscreen="true"></iframe>
</div> </div>
</p> </p>
EOS EOS
......
...@@ -23,7 +23,7 @@ describe Notification do ...@@ -23,7 +23,7 @@ describe Notification do
@post = create(:post) @post = create(:post)
end end
it "notifies on post edited" do it 'notifies on post edited' do
@bob.watch!(post: @post) @bob.watch!(post: @post)
expect(@bob.watching?(post: @post)).to be_truthy expect(@bob.watching?(post: @post)).to be_truthy
@post.reload @post.reload
...@@ -32,7 +32,7 @@ describe Notification do ...@@ -32,7 +32,7 @@ describe Notification do
expect(@bob.notifications.size).to eq(1) expect(@bob.notifications.size).to eq(1)
end end
it "not duplicated notifies on post edited" do it 'not duplicated notifies on post edited' do
@bob.watch!(post: @post) @bob.watch!(post: @post)
expect(@bob.watching?(post: @post)).to be_truthy expect(@bob.watching?(post: @post)).to be_truthy
@post.reload @post.reload
...@@ -42,14 +42,14 @@ describe Notification do ...@@ -42,14 +42,14 @@ describe Notification do
expect(@bob.notifications.size).to eq(1) expect(@bob.notifications.size).to eq(1)
end end
it "not notifies on post edited by him" do it 'not notifies on post edited by him' do
@bob.watch!(post: @post) @bob.watch!(post: @post)
@post.reload @post.reload
@post.update!(title: @post.title + ' [New!]', author: @bob) @post.update!(title: @post.title + ' [New!]', author: @bob)
expect(@bob.notifications.size).to eq(0) expect(@bob.notifications.size).to eq(0)
end end
it "notifies on post commented" do it 'notifies on post commented' do
@bob.watch!(post: @post) @bob.watch!(post: @post)
expect(@bob.watching?(post: @post)).to be_truthy expect(@bob.watching?(post: @post)).to be_truthy
@post.reload @post.reload
...@@ -58,24 +58,24 @@ describe Notification do ...@@ -58,24 +58,24 @@ describe Notification do
expect(@bob.notifications.size).to eq(1) expect(@bob.notifications.size).to eq(1)
end end
it "not notifies on post commented by him" do it 'not notifies on post commented by him' do
@bob.watch!(post: @post) @bob.watch!(post: @post)
@post.reload @post.reload
@post.comments.create!(author: @bob, body: 'new comment') @post.comments.create!(author: @bob, body: 'new comment')
expect(@bob.notifications.size).to eq(0) expect(@bob.notifications.size).to eq(0)
end end
it "set watch on user create a new post" do it 'set watch on user create a new post' do
new_post = Post.create!(author: @bob, title: 'title', body: 'body') new_post = Post.create!(author: @bob, title: 'title', body: 'body')
expect(@bob.watching?(post: new_post)).to be_truthy expect(@bob.watching?(post: new_post)).to be_truthy
end end
it "set watch on user edit a post" do it 'set watch on user edit a post' do
@post.update!(author: @bob, title: 'new title') @post.update!(author: @bob, title: 'new title')
expect(@bob.watching?(post: @post)).to be_truthy expect(@bob.watching?(post: @post)).to be_truthy
end end
it "set watch on user comment a post" do it 'set watch on user comment a post' do
@post.comments.create!(author: @bob, body: 'new comment') @post.comments.create!(author: @bob, body: 'new comment')
expect(@bob.watching?(post: @post)).to be_truthy expect(@bob.watching?(post: @post)).to be_truthy
end end
......
...@@ -33,7 +33,7 @@ describe Tag do ...@@ -33,7 +33,7 @@ describe Tag do
end end
end end
describe '#set_parent!' do describe '#parent_tag=' do
before :each do before :each do
@tag_ruby = Tag.create(name: 'ruby') @tag_ruby = Tag.create(name: 'ruby')
@tag_lang = Tag.create(name: 'lang') @tag_lang = Tag.create(name: 'lang')
...@@ -42,7 +42,7 @@ describe Tag do ...@@ -42,7 +42,7 @@ describe Tag do
it 'successfully moved' do it 'successfully moved' do
expect(@tag_ruby.parent).not_to eq(@tag_lang) expect(@tag_ruby.parent).not_to eq(@tag_lang)
expect(@tag_lang.children).not_to include(@tag_ruby) expect(@tag_lang.children).not_to include(@tag_ruby)
@tag_ruby.set_parent!(@tag_lang) @tag_ruby.parent_tag = @tag_lang
expect(@tag_ruby.parent).to eq(@tag_lang) expect(@tag_ruby.parent).to eq(@tag_lang)
expect(@tag_lang.children).to include(@tag_ruby) expect(@tag_lang.children).to include(@tag_ruby)
end end
......
...@@ -84,36 +84,36 @@ describe User do ...@@ -84,36 +84,36 @@ describe User do
it 'should require an email address' do it 'should require an email address' do
no_email_user = User.new(@attr.merge(email: '')) no_email_user = User.new(@attr.merge(email: ''))
no_email_user.should_not be_valid expect(no_email_user).not_to be_valid
end end
it 'should accept valid email addresses' do it 'should accept valid email addresses' do
addresses = %w[user@foo.com THE_USER@foo.bar.org first.last@foo.jp] addresses = %w(user@foo.com THE_USER@foo.bar.org first.last@foo.jp)
addresses.each do |address| addresses.each do |address|
valid_email_user = User.new(@attr.merge(email: address)) valid_email_user = User.new(@attr.merge(email: address))
valid_email_user.should be_valid expect(valid_email_user).to be_valid
end end
end end
it 'should reject invalid email addresses' do it 'should reject invalid email addresses' do
addresses = %w[user@foo,com user_at_foo.org example.user@foo.] addresses = %w(user@foo,com user_at_foo.org example.user@foo.)
addresses.each do |address| addresses.each do |address|
invalid_email_user = User.new(@attr.merge(email: address)) invalid_email_user = User.new(@attr.merge(email: address))
invalid_email_user.should_not be_valid expect(invalid_email_user).not_to be_valid
end end
end end
it 'should reject duplicate email addresses' do it 'should reject duplicate email addresses' do
User.create!(@attr) User.create!(@attr)
user_with_duplicate_email = User.new(@attr) user_with_duplicate_email = User.new(@attr)
user_with_duplicate_email.should_not be_valid expect(user_with_duplicate_email).not_to be_valid
end end
it 'should reject email addresses identical up to case' do it 'should reject email addresses identical up to case' do
upcased_email = @attr[:email].upcase upcased_email = @attr[:email].upcase
User.create!(@attr.merge(email: upcased_email)) User.create!(@attr.merge(email: upcased_email))
user_with_duplicate_email = User.new(@attr) user_with_duplicate_email = User.new(@attr)
user_with_duplicate_email.should_not be_valid expect(user_with_duplicate_email).not_to be_valid
end end
describe 'passwords' do describe 'passwords' do
...@@ -123,28 +123,28 @@ describe User do ...@@ -123,28 +123,28 @@ describe User do
end end
it 'should have a password attribute' do it 'should have a password attribute' do
@user.should respond_to(:password) expect(@user).to respond_to(:password)
end end
it 'should have a password confirmation attribute' do it 'should have a password confirmation attribute' do
@user.should respond_to(:password_confirmation) expect(@user).to respond_to(:password_confirmation)
end end
end end
describe 'password validations' do describe 'password validations' do
it 'should require a password' do it 'should require a password' do
User.new(@attr.merge(password: '', password_confirmation: '')).should_not be_valid expect(User.new(@attr.merge(password: '', password_confirmation: ''))).not_to be_valid
end end
it 'should require a matching password confirmation' do it 'should require a matching password confirmation' do
User.new(@attr.merge(password_confirmation: 'invalid')).should_not be_valid expect(User.new(@attr.merge(password_confirmation: 'invalid'))).not_to be_valid
end end
it 'should reject short passwords' do it 'should reject short passwords' do
short = 'a' * 5 short = 'a' * 5
hash = @attr.merge(password: short, password_confirmation: short) hash = @attr.merge(password: short, password_confirmation: short)
User.new(hash).should_not be_valid expect(User.new(hash)).not_to be_valid
end end
end end
...@@ -156,11 +156,11 @@ describe User do ...@@ -156,11 +156,11 @@ describe User do
end end
it 'should have an encrypted password attribute' do it 'should have an encrypted password attribute' do
@user.should respond_to(:encrypted_password) expect(@user).to respond_to(:encrypted_password)
end end
it 'should set the encrypted password attribute' do it 'should set the encrypted password attribute' do
@user.encrypted_password.should_not be_blank expect(@user.encrypted_password).not_to be_blank
end end
end end
......
require 'rails_helper' require 'rails_helper'
RSpec.describe Watch, :type => :model do RSpec.describe Watch, type: :model do
# describe "validations" do # describe "validations" do
# let(:alice) { create(:alice) } # let(:alice) { create(:alice) }
# let(:post) { create(:post) } # let(:post) { create(:post) }
......
...@@ -6,21 +6,20 @@ Coveralls.wear! ...@@ -6,21 +6,20 @@ Coveralls.wear!
ENV['RAILS_ENV'] ||= 'test' ENV['RAILS_ENV'] ||= 'test'
require File.expand_path('../../config/environment', __FILE__) require File.expand_path('../../config/environment', __FILE__)
Dir["./spec/support/**/*.rb"].sort.each { |f| require f } Dir['./spec/support/**/*.rb'].sort.each { |f| require f }
require 'rspec/rails' require 'rspec/rails'
require 'rspec/autorun' # require 'rspec/autorun'
# require 'email_spec' # require 'email_spec'
require 'factory_girl' require 'factory_girl'
require 'capybara' require 'capybara'
require 'capybara/rspec' require 'capybara/rspec'
## Setting for polterguist. ## Setting for polterguist.
require 'capybara/poltergeist' require 'capybara/poltergeist'
def register_poltergeist(config) def register_poltergeist(_config)
Capybara.register_driver :poltergeist do |app| Capybara.register_driver :poltergeist do |app|
Capybara::Poltergeist::Driver.new(app, timeout: 60, js_errors: false) Capybara::Poltergeist::Driver.new(app, timeout: 60, js_errors: false)
end end
...@@ -38,9 +37,8 @@ Dir[Rails.root.join('spec/support/**/*.rb')].each { |f| require f } ...@@ -38,9 +37,8 @@ Dir[Rails.root.join('spec/support/**/*.rb')].each { |f| require f }
# If you are not using ActiveRecord, you can remove this line. # If you are not using ActiveRecord, you can remove this line.
ActiveRecord::Migration.check_pending! if defined?(ActiveRecord::Migration) ActiveRecord::Migration.check_pending! if defined?(ActiveRecord::Migration)
# Setting for turnip. # Setting for turnip.
Dir.glob("spec/steps/**/*steps.rb") { |f| load f, true } Dir.glob('spec/steps/**/*steps.rb') { |f| load f, true }
require 'turnip' require 'turnip'
require 'turnip/capybara' require 'turnip/capybara'
...@@ -94,18 +92,18 @@ RSpec.configure do |config| ...@@ -94,18 +92,18 @@ RSpec.configure do |config|
DatabaseRewinder.clean DatabaseRewinder.clean
end end
config.include Devise::TestHelpers, :type => :controller config.include Devise::TestHelpers, type: :controller
# config.extend ControllerMacros, :type => :controller # config.extend ControllerMacros, :type => :controller
# Capybara.app_host = "http://127.0.0.1/" # Capybara.app_host = "http://127.0.0.1/"
register_poltergeist(config) register_poltergeist(config)
OmniAuth.config.test_mode = true OmniAuth.config.test_mode = true
OmniAuth.config.add_mock(:google_oauth2, { OmniAuth.config.add_mock(:google_oauth2,
'uid' => '12345', 'uid' => '12345',
'provider' => 'google_oauth2', 'provider' => 'google_oauth2',
'info' => {'name' => 'Taro Yamada', 'email' => 'taro@zigexn.co.jp'}, 'info' => { 'name' => 'Taro Yamada', 'email' => 'taro@zigexn.co.jp' },
'credentials' => {'token' => 'aaaaa', 'refresh_token' => 'bbbbb', 'expires_at' => 9999999999} 'credentials' => { 'token' => 'aaaaa', 'refresh_token' => 'bbbbb', 'expires_at' => 9_999_999_999 }
}) )
end end
...@@ -37,8 +37,8 @@ step 'create post :title' do |title| ...@@ -37,8 +37,8 @@ step 'create post :title' do |title|
end end
step 'search by :query' do |query| step 'search by :query' do |query|
within("#app-search-form") do within('#app-search-form') do
fill_in 'q', :with => query fill_in 'q', with: query
end end
first(:css, "#app-search-form button[type='submit']").click first(:css, "#app-search-form button[type='submit']").click
end end
......
...@@ -2,7 +2,7 @@ module ControllerMacros ...@@ -2,7 +2,7 @@ module ControllerMacros
def login_user def login_user
before(:each) do before(:each) do
controller.stub(:authenticate_user!).and_return true controller.stub(:authenticate_user!).and_return true
@request.env["devise.mapping"] = Devise.mappings[:user] @request.env['devise.mapping'] = Devise.mappings[:user]
sign_in FactoryGirl.create(:alice) sign_in FactoryGirl.create(:alice)
end end
end end
......
# Set RAILS_ROOT and load the environment if it's not already loaded. # Set RAILS_ROOT and load the environment if it's not already loaded.
unless defined?(Rails) unless defined?(Rails)
ENV["RAILS_ROOT"] = File.expand_path("../../", __FILE__) ENV['RAILS_ROOT'] = File.expand_path('../../', __FILE__)
require File.expand_path("../../config/environment", __FILE__) require File.expand_path('../../config/environment', __FILE__)
end end
Teaspoon.configure do |config| Teaspoon.configure do |config|
# Determines where the Teaspoon routes will be mounted. Changing this to "/jasmine" would allow you to browse to # Determines where the Teaspoon routes will be mounted. Changing this to "/jasmine" would allow you to browse to
# `http://localhost:3000/jasmine` to run your tests. # `http://localhost:3000/jasmine` to run your tests.
#config.mount_at = "/teaspoon" # config.mount_at = "/teaspoon"
# Specifies the root where Teaspoon will look for files. If you're testing an engine using a dummy application it can # Specifies the root where Teaspoon will look for files. If you're testing an engine using a dummy application it can
# be useful to set this to your engines root (e.g. `Teaspoon::Engine.root`). # be useful to set this to your engines root (e.g. `Teaspoon::Engine.root`).
# Note: Defaults to `Rails.root` if nil. # Note: Defaults to `Rails.root` if nil.
#config.root = nil # config.root = nil
# Paths that will be appended to the Rails assets paths # Paths that will be appended to the Rails assets paths
# Note: Relative to `config.root`. # Note: Relative to `config.root`.
#config.asset_paths = ["spec/javascripts", "spec/javascripts/stylesheets"] # config.asset_paths = ["spec/javascripts", "spec/javascripts/stylesheets"]
# Fixtures are rendered through a controller, which allows using HAML, RABL/JBuilder, etc. Files in these paths will # Fixtures are rendered through a controller, which allows using HAML, RABL/JBuilder, etc. Files in these paths will
# be rendered as fixtures. # be rendered as fixtures.
#config.fixture_paths = ["spec/javascripts/fixtures"] # config.fixture_paths = ["spec/javascripts/fixtures"]
# SUITES # SUITES
# #
...@@ -46,47 +46,47 @@ Teaspoon.configure do |config| ...@@ -46,47 +46,47 @@ Teaspoon.configure do |config|
# Specify a file matcher as a regular expression and all matching files will be loaded when the suite is run. These # Specify a file matcher as a regular expression and all matching files will be loaded when the suite is run. These
# files need to be within an asset path. You can add asset paths using the `config.asset_paths`. # files need to be within an asset path. You can add asset paths using the `config.asset_paths`.
#suite.matcher = "{spec/javascripts,app/assets}/**/*_spec.{js,js.coffee,coffee}" # suite.matcher = "{spec/javascripts,app/assets}/**/*_spec.{js,js.coffee,coffee}"
# This suites spec helper, which can require additional support files. This file is loaded before any of your test # This suites spec helper, which can require additional support files. This file is loaded before any of your test
# files are loaded. # files are loaded.
#suite.helper = "spec_helper" # suite.helper = "spec_helper"
# The core Teaspoon javascripts. It's recommended to include only the base files here, as you can require support # The core Teaspoon javascripts. It's recommended to include only the base files here, as you can require support
# libraries from your spec helper. # libraries from your spec helper.
# Note: For CoffeeScript files use `"teaspoon/jasmine"` etc. # Note: For CoffeeScript files use `"teaspoon/jasmine"` etc.
# #
# Available: teaspoon-jasmine, teaspoon-mocha, teaspoon-qunit # Available: teaspoon-jasmine, teaspoon-mocha, teaspoon-qunit
#suite.javascripts = ["mocha/1.17.1", "teaspoon-mocha"] # suite.javascripts = ["mocha/1.17.1", "teaspoon-mocha"]
# You can include your own stylesheets if you want to change how Teaspoon looks. # You can include your own stylesheets if you want to change how Teaspoon looks.
# Note: Spec related CSS can and should be loaded using fixtures. # Note: Spec related CSS can and should be loaded using fixtures.
#suite.stylesheets = ["teaspoon"] # suite.stylesheets = ["teaspoon"]
# Partial to be rendered in the head tag of the runner. You can use the provided ones or define your own by creating # Partial to be rendered in the head tag of the runner. You can use the provided ones or define your own by creating
# a `_boot.html.erb` in your fixtures path, and adjust the config to `"/boot"` for instance. # a `_boot.html.erb` in your fixtures path, and adjust the config to `"/boot"` for instance.
# #
# Available: boot, boot_require_js # Available: boot, boot_require_js
#suite.boot_partial = "boot" # suite.boot_partial = "boot"
# Partial to be rendered in the body tag of the runner. You can define your own to create a custom body structure. # Partial to be rendered in the body tag of the runner. You can define your own to create a custom body structure.
#suite.body_partial = "body" # suite.body_partial = "body"
# Assets to be ignored when generating coverage reports. Accepts an array of filenames or regular expressions. The # Assets to be ignored when generating coverage reports. Accepts an array of filenames or regular expressions. The
# default excludes assets from vendor, gems and support libraries.<br/><br/> # default excludes assets from vendor, gems and support libraries.<br/><br/>
#suite.no_coverage = [%r{/lib/ruby/gems/}, %r{/vendor/assets/}, %r{/support/}, %r{/(.+)_helper.}] # suite.no_coverage = [%r{/lib/ruby/gems/}, %r{/vendor/assets/}, %r{/support/}, %r{/(.+)_helper.}]
# Hooks allow you to use `Teaspoon.hook("fixtures")` before, after, or during your spec run. This will make a # Hooks allow you to use `Teaspoon.hook("fixtures")` before, after, or during your spec run. This will make a
# synchronous Ajax request to the server that will call all of the blocks you've defined for that hook name. # synchronous Ajax request to the server that will call all of the blocks you've defined for that hook name.
#suite.hook :fixtures, proc{ } # suite.hook :fixtures, proc{ }
end end
# Example suite. Since we're just filtering to files already within the root test/javascripts, these files will also # Example suite. Since we're just filtering to files already within the root test/javascripts, these files will also
# be run in the default suite -- but can be focused into a more specific suite. # be run in the default suite -- but can be focused into a more specific suite.
#config.suite :targeted do |suite| # config.suite :targeted do |suite|
# suite.matcher = "test/javascripts/targeted/*_test.{js,js.coffee,coffee}" # suite.matcher = "test/javascripts/targeted/*_test.{js,js.coffee,coffee}"
#end # end
# CONSOLE RUNNER SPECIFIC # CONSOLE RUNNER SPECIFIC
# #
...@@ -105,44 +105,44 @@ Teaspoon.configure do |config| ...@@ -105,44 +105,44 @@ Teaspoon.configure do |config|
# Available: phantomjs, selenium # Available: phantomjs, selenium
# PhantomJS: https://github.com/modeset/teaspoon/wiki/Using-PhantomJS # PhantomJS: https://github.com/modeset/teaspoon/wiki/Using-PhantomJS
# Selenium Webdriver: https://github.com/modeset/teaspoon/wiki/Using-Selenium-WebDriver # Selenium Webdriver: https://github.com/modeset/teaspoon/wiki/Using-Selenium-WebDriver
#config.driver = "phantomjs" # config.driver = "phantomjs"
# Specify additional options for the driver. # Specify additional options for the driver.
# #
# PhantomJS: https://github.com/modeset/teaspoon/wiki/Using-PhantomJS # PhantomJS: https://github.com/modeset/teaspoon/wiki/Using-PhantomJS
# Selenium Webdriver: https://github.com/modeset/teaspoon/wiki/Using-Selenium-WebDriver # Selenium Webdriver: https://github.com/modeset/teaspoon/wiki/Using-Selenium-WebDriver
#config.driver_options = nil # config.driver_options = nil
# Specify the timeout for the driver. Specs are expected to complete within this time frame or the run will be # Specify the timeout for the driver. Specs are expected to complete within this time frame or the run will be
# considered a failure. This is to avoid issues that can arise where tests stall. # considered a failure. This is to avoid issues that can arise where tests stall.
#config.driver_timeout = 180 # config.driver_timeout = 180
# Specify a server to use with Rack (e.g. thin, mongrel). If nil is provided Rack::Server is used. # Specify a server to use with Rack (e.g. thin, mongrel). If nil is provided Rack::Server is used.
#config.server = nil # config.server = nil
# Specify a port to run on a specific port, otherwise Teaspoon will use a random available port. # Specify a port to run on a specific port, otherwise Teaspoon will use a random available port.
#config.server_port = nil # config.server_port = nil
# Timeout for starting the server in seconds. If your server is slow to start you may have to bump this, or you may # Timeout for starting the server in seconds. If your server is slow to start you may have to bump this, or you may
# want to lower this if you know it shouldn't take long to start. # want to lower this if you know it shouldn't take long to start.
#config.server_timeout = 20 # config.server_timeout = 20
# Force Teaspoon to fail immediately after a failing suite. Can be useful to make Teaspoon fail early if you have # Force Teaspoon to fail immediately after a failing suite. Can be useful to make Teaspoon fail early if you have
# several suites, but in environments like CI this may not be desirable. # several suites, but in environments like CI this may not be desirable.
#config.fail_fast = true # config.fail_fast = true
# Specify the formatters to use when outputting the results. # Specify the formatters to use when outputting the results.
# Note: Output files can be specified by using `"junit>/path/to/output.xml"`. # Note: Output files can be specified by using `"junit>/path/to/output.xml"`.
# #
# Available: dot, documentation, clean, json, junit, pride, snowday, swayze_or_oprah, tap, tap_y, teamcity # Available: dot, documentation, clean, json, junit, pride, snowday, swayze_or_oprah, tap, tap_y, teamcity
#config.formatters = ["dot"] # config.formatters = ["dot"]
# Specify if you want color output from the formatters. # Specify if you want color output from the formatters.
#config.color = true # config.color = true
# Teaspoon pipes all console[log/debug/error] to $stdout. This is useful to catch places where you've forgotten to # Teaspoon pipes all console[log/debug/error] to $stdout. This is useful to catch places where you've forgotten to
# remove them, but in verbose applications this may not be desirable. # remove them, but in verbose applications this may not be desirable.
#config.suppress_log = false # config.suppress_log = false
# COVERAGE REPORTS / THRESHOLD ASSERTIONS # COVERAGE REPORTS / THRESHOLD ASSERTIONS
# #
...@@ -157,25 +157,25 @@ Teaspoon.configure do |config| ...@@ -157,25 +157,25 @@ Teaspoon.configure do |config|
# - with the cli: teaspoon --coverage=[coverage_name] # - with the cli: teaspoon --coverage=[coverage_name]
# Specify that you always want a coverage configuration to be used. # Specify that you always want a coverage configuration to be used.
#config.use_coverage = nil # config.use_coverage = nil
config.coverage do |coverage| config.coverage do |_coverage|
# Which coverage reports Instanbul should generate. Correlates directly to what Istanbul supports. # Which coverage reports Instanbul should generate. Correlates directly to what Istanbul supports.
# #
# Available: text-summary, text, html, lcov, lcovonly, cobertura, teamcity # Available: text-summary, text, html, lcov, lcovonly, cobertura, teamcity
#coverage.reports = ["text-summary", "html"] # coverage.reports = ["text-summary", "html"]
# The path that the coverage should be written to - when there's an artifact to write to disk. # The path that the coverage should be written to - when there's an artifact to write to disk.
# Note: Relative to `config.root`. # Note: Relative to `config.root`.
#coverage.output_dir = "coverage" # coverage.output_dir = "coverage"
# Various thresholds requirements can be defined, and those thresholds will be checked at the end of a run. If any # Various thresholds requirements can be defined, and those thresholds will be checked at the end of a run. If any
# aren't met the run will fail with a message. Thresholds can be defined as a percentage (0-100), or nil. # aren't met the run will fail with a message. Thresholds can be defined as a percentage (0-100), or nil.
#coverage.statements = nil # coverage.statements = nil
#coverage.functions = nil # coverage.functions = nil
#coverage.branches = nil # coverage.branches = nil
#coverage.lines = nil # coverage.lines = nil
end end
......
require 'rails_helper' require 'rails_helper'
RSpec.describe "watchings/show.html.erb", :type => :view do RSpec.describe 'watchings/show.html.erb', type: :view do
pending "add some examples to (or delete) #{__FILE__}" pending "add some examples to (or delete) #{__FILE__}"
end end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment