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
RV_PDF_UPLOADING=1
DATABASE_URL=mysql2://user:passwd@localhost/rendezvous_development
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:
Max: 159
# Classの最大長制限
Metrics/ClassLength:
Max: 300
NumericLiterals:
# top-classでのコメントを任意に
Style/Documentation:
Enabled: false
Documentation:
# 1行if文を使用可に
Style/IfUnlessModifier:
Enabled: false
WordArray:
# nestしたclass/moduleを許容
Style/ClassAndModuleChildren:
Enabled: false
MethodLength:
Max: 30
# 後置rescueを許容
Style/RescueModifier:
Enabled: false
IfUnlessModifier:
# and/orを許容
Style/AndOr:
Enabled: false
CyclomaticComplexity:
Max: 10
# ABCチェックを無効
Metrics/AbcSize:
Enabled: false
RaiseArgs:
# ???
Style/RaiseArgs:
Enabled: false
......@@ -11,6 +11,8 @@ env:
- AWS_S3_REGION="us-east-1"
- AWS_S3_BUCKET="rendezvous-travis-bundler"
- 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=
services:
- mysql
......@@ -22,4 +24,6 @@ before_script:
- mysql -e 'CREATE DATABASE rendezvous_test;'
after_script:
- 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
# gem 'turbolinks'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder'
# gem 'jbuilder'
gem 'i18n_generators'
......@@ -69,8 +69,6 @@ group :development do
# profiler
gem 'rack-mini-profiler'
# rubocop
gem 'rubocop'
gem 'guard-rspec', require: false
gem 'guard-rubocop'
# gem 'guard-spring'
......@@ -82,6 +80,8 @@ group :development do
gem 'capistrano-rails', '~> 1.1'
gem 'capistrano-rbenv', '~> 2.0'
gem 'capistrano3-unicorn'
gem 'travis'
end
group :development, :test do
......@@ -95,6 +95,8 @@ group :development, :test do
gem 'byebug'
gem 'dotenv-rails'
gem 'rubocop'
end
group :test do
......@@ -139,25 +141,23 @@ gem 'breadcrumble'
gem 'slim'
gem 'annotate', ">=2.6.0"
gem 'annotate', '>=2.6.0'
gem 'kaminari', github: 'amatsuda/kaminari'
gem 'jwt', '0.1.11'
# Optional
# For notifing to HipChat
gem 'hipchat'
# For PDF upload
gem 'rmagick', :require => 'RMagick'
gem 'rmagick', require: 'RMagick'
# for heroku
gem 'rails_12factor', group: :production
gem 'mysql'
# gem 'mysql'
# for IP restriction
gem 'rack-contrib', require: 'rack/contrib'
......@@ -67,6 +67,7 @@ GEM
aws-sdk (1.39.0)
json (~> 1.4)
nokogiri (>= 1.4.4)
backports (3.6.3)
bcrypt (3.1.9)
better_errors (2.0.0)
coderay (>= 1.0.0)
......@@ -147,6 +148,8 @@ GEM
activesupport (>= 3.0)
request_store (~> 1.0)
erubis (2.7.0)
ethon (0.7.1)
ffi (>= 1.3.0)
eventmachine (1.0.3)
execjs (2.2.2)
factory_girl (4.5.0)
......@@ -156,8 +159,17 @@ GEM
railties (>= 3.0.0)
faraday (0.9.0)
multipart-post (>= 1.2, < 3)
faraday_middleware (0.9.1)
faraday (>= 0.7.4, < 0.10)
ffi (1.9.6)
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)
multi_json (~> 1.3)
github-markdown (0.6.7)
......@@ -179,6 +191,7 @@ GEM
guard (~> 2.2)
teaspoon (>= 0.8.0)
hashie (3.3.1)
highline (1.6.21)
hike (1.2.3)
hipchat (1.4.0)
httparty
......@@ -193,114 +206,6 @@ GEM
i18n_generators (1.2.1)
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)
jbuilder (2.2.4)
activesupport (>= 3.0.0, < 5)
multi_json (~> 1.2)
jquery-rails (3.1.2)
railties (>= 3.0, < 5.0)
thor (>= 0.14, < 2.0)
......@@ -334,10 +239,10 @@ GEM
multi_json (1.10.1)
multi_xml (0.5.5)
multipart-post (2.0.0)
mysql (2.9.1)
mysql2 (0.3.16)
net-http-digest_auth (1.4)
net-http-persistent (2.9.4)
net-http-pipeline (1.0.1)
net-scp (1.2.1)
net-ssh (>= 2.6.5)
net-ssh (2.9.1)
......@@ -386,6 +291,9 @@ GEM
slop (~> 3.4)
pry-rails (0.3.2)
pry (>= 0.9.10)
pusher-client (0.6.0)
json
websocket (~> 1.0)
rack (1.5.2)
rack-contrib (1.2.0)
rack (>= 0.9.1)
......@@ -501,9 +409,22 @@ GEM
timers (4.0.1)
hitimes
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)
gherkin (>= 2.5)
rspec (>= 2.14.0, < 4.0)
typhoeus (0.6.9)
ethon (>= 0.7.1)
tzinfo (1.2.2)
thread_safe (~> 0.1)
uglifier (2.5.3)
......@@ -521,6 +442,7 @@ GEM
warden (1.2.3)
rack (>= 1.0)
webrobots (0.1.1)
websocket (1.2.1)
websocket-driver (0.3.5)
xpath (2.0.0)
nokogiri (~> 1.3)
......@@ -558,13 +480,11 @@ DEPENDENCIES
guard-teaspoon
hipchat
i18n_generators
jbuilder
jquery-rails
jwt (= 0.1.11)
kaminari!
launchy
mail
mysql
mysql2
newrelic_rpm
nokogiri
......@@ -587,6 +507,7 @@ DEPENDENCIES
teaspoon
therubyracer
thin
travis
turnip
uglifier
unicorn
......
......@@ -9,16 +9,16 @@
guard :rspec, cmd: 'bundle exec rspec' do
watch(%r{^spec/.+_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
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/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('config/routes.rb') { "spec/routing" }
watch('app/controllers/application_controller.rb') { "spec/controllers" }
watch('spec/rails_helper.rb') { "spec" }
watch(%r{^spec/support/(.+)\.rb$}) { 'spec' }
watch('config/routes.rb') { 'spec/routing' }
watch('app/controllers/application_controller.rb') { 'spec/controllers' }
watch('spec/rails_helper.rb') { 'spec' }
# Capybara features specs
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
watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) { |m| Dir[File.join("**/#{m[1]}.feature")][0] || 'spec/acceptance' }
end
# guard :rubocop do
# watch(%r{.+\.rb$})
# 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(http://fonts.googleapis.com/css?family=Quicksand:300,400,700);
@import url(https://fonts.googleapis.com/css?family=Flamenco:300,400);
@import url(https://fonts.googleapis.com/css?family=Quicksand:300,400,700);
$set_prefix: -webkit-, -moz-, -ms-, -o-, '';
$main-color: #75b3c8;
......
@import 'values';
@import url(http://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=Flamenco:300,400);
@import url(https://fonts.googleapis.com/css?family=Quicksand:300,400,700);
p, h1, h2, h3, h4, h5, h6, span {
// font-family: 'メイリオ', 'meiryo', hiragino kaku go;
// letter-spacing: 2pt;
......
......@@ -17,8 +17,8 @@ $main-color: #75b3c8;
#{$prefix}transition: all $transition_value $move_type
}
}
@import url(http://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=Flamenco:300,400);
@import url(https://fonts.googleapis.com/css?family=Quicksand:300,400,700);
.btn-original {
background: transparent!important;
border: 1px solid #fff;
......
......@@ -6,8 +6,8 @@
* app_header
*************************************************************************/
@import 'values';
@import url(http://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=Flamenco:300,400);
@import url(https://fonts.googleapis.com/css?family=Quicksand:300,400,700);
$main-color: #75b3c8;
.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;
.background-image {
width: 100%;
......
require 'digest/md5'
class ApisController < ApplicationController
# TODO: not to use
include ApplicationHelper
......@@ -26,15 +25,15 @@ class ApisController < ApplicationController
# Skip uploading if file ext is not listed.
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)
case file.original_filename
when /\.(jpe?g|png|gif)\Z/
s3_files << { type: 'image', name: file.original_filename, image: res.public_url.to_s }
when /\.pdf\Z/
if Settings.respond_to?(:pdf_uploading) && Settings.pdf_uploading
cover_image_name = "#{Digest::MD5.file(file.path).to_s}-cover.png"
if Settings.enable_pdf_uploading
cover_image_name = "#{Digest::MD5.file(file.path)}-cover.png"
pdf = Magick::ImageList.new(file.path + '[0]')
cover_tmp = Rails.root.join('tmp', cover_image_name)
pdf[0].write(cover_tmp)
......@@ -49,7 +48,7 @@ class ApisController < ApplicationController
end
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
end
......
......@@ -3,16 +3,16 @@ class ApplicationController < ActionController::Base
# For APIs, you may want to use :null_session instead.
protect_from_forgery with: :exception
add_breadcrumb("Rendezvous", '/')
add_breadcrumb('Rendezvous', '/')
before_action :redirect_unless_signed_in
def redirect_unless_signed_in
unless user_signed_in?
flash[:alert] = 'You need Login!'
session[:login_redirect_to] = request.url
redirect_to root_path
end
return if user_signed_in?
flash[:alert] = 'You need Login!'
session[:login_redirect_to] = request.url
redirect_to root_path
end
def after_sign_in_path_for(resource)
......
......@@ -14,10 +14,10 @@ module RV::Mailer
html_body = generate_html_mail(post)
mail = Mail.new do
from opts[:user].email
to opts[:to]
subject post.title
body post.body
from opts[:user].email
to opts[:to]
subject post.title
body post.body
html_part do
content_type 'text/html; charset=UTF-8'
......@@ -40,10 +40,10 @@ module RV::Mailer
template = File.open(path).read
html_body = template
.sub('__POST_URL__', Settings.rendezvous.app_host + post.decorate.show_path)
.sub('__HTML_TITLE__', MarkdownRenderer.new(post.title).render)
.sub('__HTML_BODY__', MarkdownRenderer.new(post.body).render)
.sub('__RV_URL__', Settings.rendezvous.app_host + '/')
.sub('__POST_URL__', Settings.rendezvous.app_host + post.decorate.show_path)
.sub('__HTML_TITLE__', MarkdownRenderer.new(post.title).render)
.sub('__HTML_BODY__', MarkdownRenderer.new(post.body).render)
.sub('__RV_URL__', Settings.rendezvous.app_host + '/')
premailer = Premailer.new(html_body, with_html_string: true, adapter: :nokogiri)
premailer.to_inline_css
......
class FlowController < ApplicationController
def show
@posts = Post.includes(:tags, :author).where(is_draft: false).order(updated_at: :desc).page(params[:page]).decorate
end
......
......@@ -11,5 +11,4 @@ class NotificationsController < ApplicationController
def set_notification
@notification = Notification.find(params[:id])
end
end
......@@ -10,8 +10,8 @@ class PostsController < ApplicationController
def show
current_user.visit_post!(@post)
@post.tags.each do |_tag|
add_breadcrumb("##{_tag.name}", _tag.decorate.show_path)
@post.tags.each do |tag|
add_breadcrumb("##{tag.name}", tag.decorate.show_path)
end
add_breadcrumb(@post.title)
end
......@@ -131,17 +131,17 @@ class PostsController < ApplicationController
# Never trust parameters from the scary internet, only allow the white list through.
def post_params
@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 = _param_hash.delete('tags')
tags_text = param_hash.delete('tags')
tags = tags_text.split(',').map do |_tag_name|
Tag.find_or_create_by(name: _tag_name)
tags = tags_text.split(',').map do |tag_name|
Tag.find_or_create_by(name: tag_name)
end
_param_hash['tag_ids'] = tags.map(&:id)
param_hash['tag_ids'] = tags.map(&:id)
_param_hash
param_hash
end
end
......
class SearchController < ApplicationController
def show
if params[:q].present?
scope = Post.search(params[:q])
......
......@@ -52,7 +52,7 @@ class TagsController < ApplicationController
# すべてのPostを移動先のタグに移動し
# このタグを削除する
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.delete
......@@ -64,9 +64,9 @@ class TagsController < ApplicationController
# このタグを他のタグの下に移動
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}」の下に移動しました"
......@@ -76,12 +76,11 @@ class TagsController < ApplicationController
private
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
end
def tag_params
params.require(:tag).permit(:name, :body).to_hash
end
end
class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController
skip_before_action :redirect_unless_signed_in
def google_oauth2
email = request.env['omniauth.auth'].info['email']
# reject if email is not zigexn nor ventura.
......
class UsersController < ApplicationController
before_action :set_user, only: [:edit, :update]
def edit
......
class WelcomeController < ApplicationController
skip_before_action :redirect_unless_signed_in
def top
......
......@@ -9,5 +9,4 @@ class ApisDecorator < Draper::Decorator
# object.created_at.strftime("%a %m/%d/%y")
# end
# end
end
......@@ -9,5 +9,4 @@ class FlowDecorator < Draper::Decorator
# object.created_at.strftime("%a %m/%d/%y")
# end
# end
end
......@@ -12,12 +12,12 @@ class PostDecorator < Draper::Decorator
# 読了時間
# 500文字/1分換算
def read_time
_time_min = model.body.length / 500
case _time_min
time_min = model.body.length / 500
case time_min
when 0
'< 1 min.'
when 1..10
"#{_time_min} min."
"#{time_min} min."
else
'> 10 min.'
end
......@@ -46,5 +46,4 @@ class PostDecorator < Draper::Decorator
''
end
end
end
class PostsDecorator < Draper::CollectionDecorator
def related_tags
_tags = self.map do |_post|
_post.tags
end.flatten.uniq
tags = map(&:tags).flatten.uniq
TagDecorator.decorate_collection(_tags)
TagDecorator.decorate_collection(tags)
end
def related_authors
self.map do |_post|
_post.author
end.flatten.uniq.map do |_author|
_author.decorate
end
map(&:author).flatten.uniq.map(&:decorate)
end
end
......@@ -9,5 +9,4 @@ class SearchDecorator < Draper::Decorator
# object.created_at.strftime("%a %m/%d/%y")
# end
# end
end
......@@ -9,5 +9,4 @@ class StockDecorator < Draper::Decorator
# object.created_at.strftime("%a %m/%d/%y")
# end
# end
end
......@@ -28,23 +28,22 @@ class TagDecorator < Draper::Decorator
# tagをtree viewで表示する
def tree_view_node
_html = ''
html = ''
_html += %Q{
<a href="#{ self.show_path }" data-name="#{model.name}">
html += %(
<a href="#{ show_path }" data-name="#{model.name}">
#{model.name} <span class="badge">#{model.posts.size}</span>
</a>
}
)
_html += '<ul>'
model.children.each do |_child|
_html += '<li>'
_html << _child.decorate.tree_view_node
_html += '</li>'
html += '<ul>'
model.children.each do |child|
html += '<li>'
html << child.decorate.tree_view_node
html += '</li>'
end
_html += '</ul>'
html += '</ul>'
_html.html_safe
html.html_safe
end
end
class TagsDecorator < Draper::CollectionDecorator
# tagをtree viewで表示する
def tree_view
_html = ''
_html += %Q{
html = ''
html += %(
<ul class="mod-tag-tree">
<input type="search" class="mod-tag-tree-filter form-control" placeholder="filter...">
}
self.each do |_node|
_html += %Q{
)
each do |node|
html += %(
<li>
#{_node.decorate.tree_view_node}
#{node.decorate.tree_view_node}
</li>
}
)
end
_html += "</ul>"
html += '</ul>'
_html.html_safe
html.html_safe
end
end
......@@ -9,5 +9,4 @@ class TemplateDecorator < Draper::Decorator
# object.created_at.strftime("%a %m/%d/%y")
# end
# end
end
......@@ -9,5 +9,4 @@ class UsersDecorator < Draper::Decorator
# object.created_at.strftime("%a %m/%d/%y")
# end
# end
end
......@@ -9,5 +9,4 @@ class WatchingDecorator < Draper::Decorator
# object.created_at.strftime("%a %m/%d/%y")
# end
# end
end
module ApplicationHelper
def h_application_format_markdown(text)
raise "deplicated error"
text = GitHub::Markdown.render_gfm(text)
text.html_safe
end
end
......@@ -33,6 +33,7 @@ class Comment < ActiveRecord::Base
######################################################################
# Instance method
######################################################################
private
def notify_watchers!
......
module HipchatIntegration
# Call Hipchat API
def notify_hipchat!
require 'uri'
return if is_draft
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
# @return [String] notification body
def notify_hipchat_body
<<EOF
#{author.name}が「#{title}」を投稿しました。
#{self.decorate.show_url}
#{decorate.show_url}
--
#{body}
EOF
......
......@@ -6,15 +6,15 @@ class MarkdownRenderer
# pdf viewerの変換
# !slide!(file-url) -> %%slide:0%% -> <iframe>...</iframe>
def render
# slideのurlを一時保管
slide_urls = []
text = @text.gsub(/!slide!\(([^\)]+)\)/) do |_|
slide_urls << %Q{
slide_urls << %(
<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>
}
)
"%%slide:#{slide_urls.size - 1}%%"
end
......@@ -22,7 +22,7 @@ class MarkdownRenderer
# 保管したslide urlを取り出す
text = text.gsub(/%%slide:(\d+)%%/) do |_|
slide_urls[$1.to_i]
slide_urls[Regexp.last_match[1].to_i]
end
text.html_safe
......
......@@ -19,13 +19,13 @@ class Notification < ActiveRecord::Base
# Named scope
######################################################################
scope :unread, -> {
scope :unread, (lambda do
where(is_read: false)
}
end)
scope :recent, -> {
scope :recent, (lambda do
where(arel_table[:created_at].gt 7.day.ago)
}
end)
######################################################################
# Instance method
......
......@@ -27,8 +27,8 @@ class Post < ActiveRecord::Base
has_many :comments
has_many :footprints
has_many :watches, :as => :watchable, :dependent => :destroy
has_many :watchers, :through => :watches
has_many :watches, as: :watchable, dependent: :destroy
has_many :watchers, through: :watches
######################################################################
# Validations
......@@ -41,46 +41,46 @@ class Post < ActiveRecord::Base
######################################################################
after_save :set_watcher!
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
######################################################################
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.
query_list = query.split(/[\s ]+/)
query_list.each do |_query|
case _query
query_list.each do |where_query|
case where_query
when /\Aid:(.+)/
_where_list = _where_list.where(id: Regexp.last_match[1])
where_list = where_list.where(id: Regexp.last_match[1])
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:(.+)/
_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@(.+)/
_where_list = _where_list.where(users: { nickname: Regexp.last_match[1] })
where_list = where_list.where(users: { nickname: Regexp.last_match[1] })
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+)/
_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)
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)
when /\Adraft:1/
_where_list = _where_list.where(is_draft: true)
where_list = where_list.where(is_draft: true)
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
_where_list
where_list
end)
# 最新のPostを取得
scope :recent, -> (limit = 10) {
scope :recent, (lambda do |limit = 10|
order(updated_at: :desc).limit(limit)
}
end)
######################################################################
# Instance method
......@@ -88,35 +88,34 @@ class Post < ActiveRecord::Base
# generate forked post (not saved)
def generate_fork(user)
# `id`以外をコピーする
_forked_post = Post.new(self.attributes.except('id'))
forked_post = Post.new(attributes.except('id'))
# `%name`をユーザー名に置換
_forked_post.title = _forked_post.title.gsub(/%name/, user.name)
forked_post.title = forked_post.title.gsub(/%name/, user.name)
# `%Y`などを日付に変換
_forked_post.title = Time.now.strftime(_forked_post.title) # TODO
_forked_post.title = _forked_post.title
forked_post.title = Time.now.strftime(forked_post.title) # TODO
forked_post.title = forked_post.title
_forked_post.tag_ids = self.tag_ids
_forked_post.author = user
_forked_post.specified_date = Date.today
forked_post.tag_ids = tag_ids
forked_post.author = user
forked_post.specified_date = Date.today
_forked_post
forked_post
end
# slideshow用のbody
def body_for_slideshow
self.body.gsub(/^#/, "---\n\n#")
body.gsub(/^#/, "---\n\n#")
end
def visited_user_count
footprints.select(:user_id).uniq.count
end
# FIXME:
# FIXME: 正常に動作しないため動作しないため一時的にメソッドを作成
# has_many :watchers, :through => :watches
# 正常に動作しないため動作しないため一時的にメソッドを作成
#
# def watchers
# watches.map { |watch| watch.watcher }
# end
......
......@@ -6,7 +6,7 @@ class S3Uploader
# @param [String] bucket: uploading backet name.
def initialize(access_key_id: Settings.s3.access_key_id,
secret_access_key: Settings.s3.secret_access_key,
region: "ap-northeast-1",
region: 'ap-northeast-1',
bucket:)
@s3 = AWS::S3.new(access_key_id: access_key_id,
secret_access_key: secret_access_key,
......
......@@ -21,40 +21,36 @@ class Tag < ActiveRecord::Base
# for versioning
has_paper_trail
default_scope { order(:updated_at => :desc) }
default_scope { order(updated_at: :desc) }
scope :posts_exist, lambda {
select('tags.*, count(posts.id) as posts_count').
joins(:posts).
group('tags.id').
having('posts_count > 0')
select('tags.*, count(posts.id) as posts_count')
.joins(:posts)
.group('tags.id')
.having('posts_count > 0')
}
class << self
# 最近投稿されたTagを取得
def recent(limit=10)
Post.recent(20).map do |post|
post.tags
end.flatten.compact.uniq.take(limit)
def recent(limit = 10)
Post.recent(20).map(&:tags).flatten.compact.uniq.take(limit)
end
end
def recent_posts(limit = 30)
self.posts.recent(limit)
posts.recent(limit)
end
# 自分のタグに紐づくPostをすべて`other_tag`へ移動する
def move_all_posts_to!(other_tag)
self.posts.each do |_post|
_post.tags.delete(self)
_post.tags << other_tag unless _post.tags.include?(other_tag)
posts.each do |moving_post|
moving_post.tags.delete(self)
moving_post.tags << other_tag unless moving_post.tags.include?(other_tag)
end
end
# 親タグを設定する
def set_parent!(other_tag)
def parent_tag=(other_tag)
self.parent = other_tag
self.save!
end
......
......@@ -41,19 +41,18 @@ class User < ActiveRecord::Base
has_many :footprints
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 :post_recently, -> {
scope :post_recently, (lambda do
User.joins(:posts).group('id').order('posts.updated_at desc')
}
scope :search, (lambda do |_query|
where('name LIKE ? OR nickname LIKE ?', "%#{_query}%", "%#{_query}%")
end)
scope :search, (lambda do |query|
where('name LIKE ? OR nickname LIKE ?', "%#{query}%", "%#{query}%")
end)
######################################################################
# Validations
......@@ -66,13 +65,12 @@ class User < ActiveRecord::Base
validates :nickname, uniqueness: true
# Device
def self.find_for_google_oauth2(access_token, signed_in_resource = nil)
user = self.where(email: access_token.info['email']).first_or_create do |_user|
_user.name = access_token.info['name']
_user.image_url = access_token.info['image']
_user.password = Devise.friendly_token[0, 20]
_user.nickname = (("a".."z").to_a + ("A".."Z").to_a + (0..9).to_a).shuffle[0..4].join
def self.find_for_google_oauth2(access_token, _signed_in_resource = nil)
user = where(email: access_token.info['email']).first_or_create do |u|
u.name = access_token.info['name']
u.image_url = access_token.info['image']
u.password = Devise.friendly_token[0, 20]
u.nickname = (('a'..'z').to_a + ('A'..'Z').to_a + (0..9).to_a).shuffle[0..4].join
end
user.update(
......@@ -96,8 +94,8 @@ class User < ActiveRecord::Base
# refresh google oauth token
def google_oauth_token_refresh!
conn = Faraday.new(url: 'https://accounts.google.com') do |builder|
builder.request :url_encoded
builder.adapter :net_http
builder.request :url_encoded
builder.adapter :net_http
end
response = conn.post '/o/oauth2/token',
client_id: Settings.google_api.client_id,
......@@ -115,9 +113,9 @@ class User < ActiveRecord::Base
# push通知を追加
def push_notification(detail_path, body)
unless notifications.where(detail_path: detail_path).unread.exists?
notifications.create(detail_path: detail_path, body: body, is_read: false)
end
return if notifications.where(detail_path: detail_path).unread.exists?
notifications.create(detail_path: detail_path, body: body, is_read: false)
end
# record footprint
......@@ -129,11 +127,11 @@ class User < ActiveRecord::Base
if hash[:post]
watching_posts << hash[:post] unless watching_posts.include?(hash[:post])
elsif hash[:tag]
raise 'Not Implemented.'
fail 'Not Implemented.'
elsif hash[:user]
raise 'Not Implemented.'
fail 'Not Implemented.'
else
raise 'No hash argument set.'
fail 'No hash argument set.'
end
end
......@@ -141,11 +139,11 @@ class User < ActiveRecord::Base
if hash[:post]
hash[:post].watches.where(watcher: self).destroy_all
elsif hash[:tag]
raise 'Not Implemented.'
fail 'Not Implemented.'
elsif hash[:user]
raise 'Not Implemented.'
fail 'Not Implemented.'
else
raise 'No hash argument set.'
fail 'No hash argument set.'
end
end
......@@ -155,11 +153,11 @@ class User < ActiveRecord::Base
if hash[:post]
hash[:post].watches.where(watcher: self).exists?
elsif hash[:tag]
raise 'Not Implemented.'
fail 'Not Implemented.'
elsif hash[:user]
raise 'Not Implemented.'
fail 'Not Implemented.'
else
raise 'No hash argument set.'
fail 'No hash argument set.'
end
end
......
class Watch < ActiveRecord::Base
######################################################################
# Associations
######################################################################
......@@ -10,5 +9,4 @@ class Watch < ActiveRecord::Base
# Validations
######################################################################
validates :watcher_id, uniqueness: { scope: [:watchable_type, :watchable_id] }
end
......@@ -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.print.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"
= render partial: 'partials/google_analytics'
= stylesheet_link_tag "application", media: "all"
......
- if Settings.respond_to?(:google_analytics) && Settings.google_analytics.present?
- if Settings.google_analytics.present?
javascript:
(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),
......
File mode changed from 100644 to 100755
......@@ -4,7 +4,7 @@ require 'rails/all'
# Require the gems listed in Gemfile, including any gems
# you've limited to :test, :development, or :production.
Bundler.require(:default, Rails.env)
Bundler.require(*Rails.groups)
module Rendezvous
class Application < Rails::Application
......@@ -14,14 +14,11 @@ module Rendezvous
# 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.
config.time_zone = 'Tokyo'
config.active_record.default_timezone = :local
# config.time_zone = 'Central Time (US & Canada)'
# 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]
I18n.enforce_available_locales = true
config.i18n.default_locale = 'ja'
# config.i18n.default_locale = :de
# config.action_mailer.delivery_method = :action_gmailer
config.action_mailer.smtp_settings = {
......@@ -35,8 +32,7 @@ module Rendezvous
# IP restriction.
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
# Set up gems listed in the Gemfile.
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'
# set :pty, true
# 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 []
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 {}
# set :default_env, { path: "/opt/ruby/bin:$PATH" }
......@@ -38,7 +38,7 @@ set :keep_releases, 5
set :rbenv_type, :system
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_map_bins, %w{rake gem bundle ruby rails}
set :rbenv_map_bins, %w(rake gem bundle ruby rails)
set :rbenv_roles, :all # default value
# namespace :deploy do
......
......@@ -4,9 +4,9 @@
# server in each group is considered to be the first
# unless any hosts have the primary property set.
# Don't declare `role :all`, it's a meta role
role :app, %w{rendezvous}
role :web, %w{rendezvous}
role :db, %w{rendezvous}
role :app, %w(rendezvous)
role :web, %w(rendezvous)
role :db, %w(rendezvous)
# Extended Server Syntax
# ======================
......@@ -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
# 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 :ssh_options, {
keys: %w(~/.ssh/id_rsa),
forward_agent: true,
auth_methods: %w(publickey)
}
set :ssh_options,
keys: %w(~/.ssh/id_rsa),
forward_agent: true,
auth_methods: %w(publickey)
# and/or per server
# server 'example.com',
# user: 'user_name',
......
......@@ -4,9 +4,9 @@
# server in each group is considered to be the first
# unless any hosts have the primary property set.
# Don't declare `role :all`, it's a meta role
role :app, %w{rendezvous}
role :web, %w{rendezvous}
role :db, %w{rendezvous}
role :app, %w(rendezvous)
role :web, %w(rendezvous)
role :db, %w(rendezvous)
# Extended Server Syntax
# ======================
......@@ -14,7 +14,7 @@ role :db, %w{rendezvous}
# definition into the server list. The second argument
# something that quacks like a hash can be used to set
# 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
# 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 @@
require File.expand_path('../application', __FILE__)
# 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.
# In the development environment your application's code is reloaded on
......@@ -19,7 +19,7 @@ Rendezvous::Application.configure do
# Print deprecation notices to the Rails logger.
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
# Debug mode disables concatenation and preprocessing of assets.
......@@ -27,6 +27,14 @@ Rendezvous::Application.configure do
# number of complex assets.
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
config.action_mailer.default_url_options = { host: 'localhost:3000' }
end
Rendezvous::Application.configure do
Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.
# Code is not reloaded between requests.
config.cache_classes = true
# 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.
# Rake tasks automatically ignore this option for performance.
config.eager_load = true
......@@ -20,27 +20,26 @@ Rendezvous::Application.configure do
# config.action_dispatch.rack_cache = true
# 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.
config.assets.js_compressor = :uglifier
# config.assets.css_compressor = :sass
# 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.
config.assets.digest = true
# Version of your assets, change this if you want to expire all your assets.
config.assets.version = '1.0'
# `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb
# 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-Accel-Redirect' # for nginx
# 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.
config.log_level = :info
......@@ -57,16 +56,12 @@ Rendezvous::Application.configure do
# Enable serving of images, stylesheets, and JavaScripts from an asset server.
# 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.
# Set this to true and configure the email server for immediate delivery to raise delivery errors.
# config.action_mailer.raise_delivery_errors = false
# 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
# Send deprecation notices to registered listeners.
......@@ -77,4 +72,7 @@ Rendezvous::Application.configure do
# Use default logging formatter so that PID and timestamp are not suppressed.
config.log_formatter = ::Logger::Formatter.new
# Do not dump schema after migrations.
config.active_record.dump_schema_after_migration = false
end
Rendezvous::Application.configure do
Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.
# The test environment is used exclusively to run your application's
......@@ -33,4 +33,7 @@ Rendezvous::Application.configure do
# Print deprecation notices to the stderr.
config.active_support.deprecation = :stderr
# Raises error for missing translations
# config.action_view.raise_on_missing_translations = true
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 @@
# Add new mime types for use in respond_to blocks:
# Mime::Type.register "text/richtext", :rtf
# Mime::Type.register_alias "text/html", :iphone
# Be sure to restart your server when you modify this file.
Rendezvous::Application.config.session_store :cookie_store,
key: '__rv__'
Rails.application.config.session_store :cookie_store, key: '__rv'
......@@ -15,7 +15,7 @@ common: &default_settings
# You must specify the license key associated with your New Relic
# account. This key binds your Agent's data to your account in the
# New Relic service.
license_key: '7bd008493661cbb36f85d52068addbe8ffecaf04'
license_key: <%= ENV['RV_NEWRELIC_LICENSE_KEY'] %>
# Agent Enabled (Ruby/Rails Only)
# 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/file_receiver'
get 'apis/user_mention'
post 'apis/markdown_preview'
post 'apis/file_receiver'
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 'flow' => 'flow#show', as: 'flow'
get 'search' => 'search#show', as: 'search'
get 'templates' => 'templates#show', as: 'templates'
get 'watchings' => 'watchings#show', as: 'watching'
get 'stock' => 'stock#show', as: 'stock'
get 'flow' => 'flow#show', as: 'flow'
get 'search' => 'search#show', as: 'search'
get 'templates' => 'templates#show', as: 'templates'
get 'watchings' => 'watchings#show', as: 'watching'
get 'posts/:id/fork' => 'posts#fork', as: 'fork_post'
post 'posts/:id/mail' => 'posts#mail', as: 'mail_post'
post 'posts/:id/comment' => 'posts#comment', as: 'comment_post'
get 'posts/:id/slideshow' => 'posts#slideshow', as: 'slideshow_post'
get 'posts/:id/watch' => 'posts#watch', as: 'watch_post'
get 'posts/:id/fork' => 'posts#fork', as: 'fork_post'
post 'posts/:id/mail' => 'posts#mail', as: 'mail_post'
post 'posts/:id/comment' => 'posts#comment', as: 'comment_post'
get 'posts/:id/slideshow' => 'posts#slideshow', as: 'slideshow_post'
get 'posts/:id/watch' => 'posts#watch', as: 'watch_post'
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/move_to/:move_to_name' => 'tags#move_to', as: 'move_to_tag'
resources :tags, :param => :name, except: [:index]
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'
resources :tags, param: :name, except: [:index]
devise_for :users,
controllers: {
omniauth_callbacks: 'users/omniauth_callbacks',
registrations: 'users/registrations'
},
skip: [
:passwords,
:registrations,
]
controllers: {
omniauth_callbacks: 'users/omniauth_callbacks',
registrations: 'users/registrations'
},
skip: [
:passwords,
:registrations
]
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
# 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
bucket_name: <%= ENV['RV_S3_BACKET_NAME'] %>
# optional
# hipchat:
# token: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
# room: 'xxxxxxxxxxx'
hipchat:
token: <%= ENV['RV_HIPCHAT_TOKEN'] %>
room: <%= ENV['RV_HIPCHAT_ROOM'] %>
# optional
# google_analytics:
google_analytics: <%= ENV['RV_GOOGLE_ANALYTICS_ID'] %>
# optional
pdf_uploading: <%= ENV['RV_PDF_UPLOADING'].present? %>
enable_pdf_uploading: <%= ENV['RV_PDF_UPLOADING'].present? %>
development:
<<: *defaults
......
worker_processes Integer(ENV["WEB_CONCURRENCY"] || 3)
worker_processes Integer(ENV['WEB_CONCURRENCY'] || 3)
timeout 15
preload_app true
before_fork do |server, worker|
before_fork do |_server, _worker|
Signal.trap 'TERM' do
puts 'Unicorn master intercepting TERM and sending myself QUIT instead'
Process.kill 'QUIT', Process.pid
end
defined?(ActiveRecord::Base) and
defined?(ActiveRecord::Base) &&
ActiveRecord::Base.connection.disconnect!
end
after_fork do |server, worker|
after_fork do |_server, _worker|
Signal.trap 'TERM' do
puts 'Unicorn worker intercepting TERM and doing nothing. Wait for master to send QUIT'
end
defined?(ActiveRecord::Base) and
defined?(ActiveRecord::Base) &&
ActiveRecord::Base.establish_connection
end
# paths
app_path = "/var/www/rendezvous"
app_path = '/var/www/rendezvous'
working_directory "#{app_path}/current"
pid "#{app_path}/current/tmp/pids/unicorn.pid"
pid "#{app_path}/current/tmp/pids/unicorn.pid"
# listen
listen "/tmp/unicorn-rendezvous.socket", :backlog => 64
listen '/tmp/unicorn-rendezvous.socket', backlog: 64
# logging
stderr_path "log/unicorn.stderr.log"
stdout_path "log/unicorn.stdout.log"
stderr_path 'log/unicorn.stderr.log'
stdout_path 'log/unicorn.stdout.log'
# workers
worker_processes 3
# use correct Gemfile on restarts
before_exec do |server|
before_exec do |_server|
ENV['BUNDLE_GEMFILE'] = "#{app_path}/current/Gemfile"
end
# preload
preload_app true
before_fork do |server, worker|
before_fork do |server, _worker|
# the following is highly recomended for Rails + "preload_app true"
# as there's no need for the master process to hold a connection
if defined?(ActiveRecord::Base)
......@@ -31,16 +31,16 @@ before_fork do |server, worker|
# Before forking, kill the master process that belongs to the .oldbin PID.
# This enables 0 downtime deploys.
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
Process.kill("QUIT", File.read(old_pid).to_i)
Process.kill('QUIT', File.read(old_pid).to_i)
rescue Errno::ENOENT, Errno::ESRCH
# someone else did our job for us
end
end
end
after_fork do |server, worker|
after_fork do |_server, _worker|
if defined?(ActiveRecord::Base)
ActiveRecord::Base.establish_connection
end
......
......@@ -6,18 +6,18 @@ class AddDeviseToUsers < ActiveRecord::Migration
t.string :encrypted_password, null: false, default: ''
## Recoverable
t.string :reset_password_token
t.string :reset_password_token
t.datetime :reset_password_sent_at
## Rememberable
t.datetime :remember_created_at
## 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 :last_sign_in_at
t.string :current_sign_in_ip
t.string :last_sign_in_ip
t.string :current_sign_in_ip
t.string :last_sign_in_ip
## Confirmable
# t.string :confirmation_token
......
class CreateVersions < ActiveRecord::Migration
def self.up
create_table :versions do |t|
t.string :item_type, :null => false
t.integer :item_id, :null => false
t.string :event, :null => false
t.string :whodunnit
t.text :object
t.string :item_type, null: false
t.integer :item_id, null: false
t.string :event, null: false
t.string :whodunnit
t.text :object
t.datetime :created_at
end
add_index :versions, [:item_type, :item_id]
......
......@@ -2,6 +2,6 @@ class AddNicknameToUsers < ActiveRecord::Migration
def change
add_column :users, :nickname, :string, default: '', null: false
add_index "users", ["nickname"]
add_index 'users', ['nickname']
end
end
......@@ -2,7 +2,7 @@ class CreateWatches < ActiveRecord::Migration
def change
create_table :watches do |t|
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.timestamps
......
......@@ -13,117 +13,117 @@
ActiveRecord::Schema.define(version: 20140719145016) do
create_table "comments", force: true do |t|
t.integer "author_id"
t.integer "post_id"
t.text "body"
t.datetime "created_at"
t.datetime "updated_at"
create_table 'comments', force: true do |t|
t.integer 'author_id'
t.integer 'post_id'
t.text 'body'
t.datetime 'created_at'
t.datetime 'updated_at'
end
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', ['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
create_table "footprints", force: true do |t|
t.integer "user_id", null: false
t.integer "post_id", null: false
t.datetime "created_at"
t.datetime "updated_at"
create_table 'footprints', force: true do |t|
t.integer 'user_id', null: false
t.integer 'post_id', null: false
t.datetime 'created_at'
t.datetime 'updated_at'
end
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
create_table "notifications", force: true do |t|
t.integer "user_id"
t.datetime "read_at"
t.boolean "is_read", default: false, null: false
t.string "detail_path"
t.text "body"
t.datetime "created_at"
t.datetime "updated_at"
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
create_table 'notifications', force: true do |t|
t.integer 'user_id'
t.datetime 'read_at'
t.boolean 'is_read', default: false, null: false
t.string 'detail_path'
t.text 'body'
t.datetime 'created_at'
t.datetime 'updated_at'
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|
t.integer "post_id", null: false
t.integer "tag_id", null: false
t.datetime "created_at"
t.datetime "updated_at"
create_table 'post_tags', force: true do |t|
t.integer 'post_id', null: false
t.integer 'tag_id', null: false
t.datetime 'created_at'
t.datetime 'updated_at'
end
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
create_table "posts", force: true do |t|
t.string "title"
t.text "body"
t.integer "author_id"
t.datetime "created_at"
t.datetime "updated_at"
t.boolean "is_draft", default: false
t.date "specified_date"
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
create_table 'posts', force: true do |t|
t.string 'title'
t.text 'body'
t.integer 'author_id'
t.datetime 'created_at'
t.datetime 'updated_at'
t.boolean 'is_draft', default: false
t.date 'specified_date'
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|
t.string "name"
t.datetime "created_at"
t.datetime "updated_at"
t.string "ancestry"
t.text "body"
t.integer "posts_count", default: 0, null: false
create_table 'tags', force: true do |t|
t.string 'name'
t.datetime 'created_at'
t.datetime 'updated_at'
t.string 'ancestry'
t.text 'body'
t.integer 'posts_count', default: 0, null: false
end
add_index "tags", ["ancestry"], name: "index_tags_on_ancestry", using: :btree
create_table "users", force: true do |t|
t.string "name"
t.string "image_url"
t.datetime "created_at"
t.datetime "updated_at"
t.string "email", default: "", null: false
t.string "encrypted_password", default: "", null: false
t.string "reset_password_token"
t.datetime "reset_password_sent_at"
t.datetime "remember_created_at"
t.integer "sign_in_count", default: 0, null: false
t.datetime "current_sign_in_at"
t.datetime "last_sign_in_at"
t.string "current_sign_in_ip"
t.string "last_sign_in_ip"
t.string "google_auth_token"
t.string "google_refresh_token"
t.datetime "google_token_expires_at"
t.string "nickname", default: "", null: false
add_index 'tags', ['ancestry'], name: 'index_tags_on_ancestry', using: :btree
create_table 'users', force: true do |t|
t.string 'name'
t.string 'image_url'
t.datetime 'created_at'
t.datetime 'updated_at'
t.string 'email', default: '', null: false
t.string 'encrypted_password', default: '', null: false
t.string 'reset_password_token'
t.datetime 'reset_password_sent_at'
t.datetime 'remember_created_at'
t.integer 'sign_in_count', default: 0, null: false
t.datetime 'current_sign_in_at'
t.datetime 'last_sign_in_at'
t.string 'current_sign_in_ip'
t.string 'last_sign_in_ip'
t.string 'google_auth_token'
t.string 'google_refresh_token'
t.datetime 'google_token_expires_at'
t.string 'nickname', default: '', null: false
end
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", ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true, using: :btree
create_table "versions", force: true do |t|
t.string "item_type", null: false
t.integer "item_id", null: false
t.string "event", null: false
t.string "whodunnit"
t.text "object"
t.datetime "created_at"
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', ['reset_password_token'], name: 'index_users_on_reset_password_token', unique: true, using: :btree
create_table 'versions', force: true do |t|
t.string 'item_type', null: false
t.integer 'item_id', null: false
t.string 'event', null: false
t.string 'whodunnit'
t.text 'object'
t.datetime 'created_at'
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|
t.integer "watcher_id", null: false
t.string "watchable_type", null: false
t.integer "watchable_id", null: false
t.datetime "created_at"
t.datetime "updated_at"
create_table 'watches', force: true do |t|
t.integer 'watcher_id', null: false
t.string 'watchable_type', null: false
t.integer 'watchable_id', null: false
t.datetime 'created_at'
t.datetime 'updated_at'
end
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', ['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
end
......@@ -24,7 +24,7 @@ _tag_tree = [
['OS', 'CentOS'],
['OS', 'Ubuntu'],
['OS', 'MacOS'],
['OS', 'Windows'],
['OS', 'Windows']
]
tags = []
......
......@@ -4,10 +4,8 @@ namespace :batch do
desc 'Tagに関連するPostのcounter_cacheの再生成'
task reset_counters: :environment do
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"
end
end
......@@ -3,11 +3,11 @@ namespace :migrations do
desc '001 nicknameを自動付与'
task task_001_user_nickname: :environment do
User.all.each do |_user|
next if _user.nickname.present?
User.all.each do |user|
next if user.nickname.present?
new_nickname = (("a".."z").to_a + ("A".."Z").to_a + (0..9).to_a).shuffle[0..4].join
_user.update_attributes!(nickname: new_nickname)
new_nickname = (('a'..'z').to_a + ('A'..'Z').to_a + (0..9).to_a).shuffle[0..4].join
user.update_attributes!(nickname: new_nickname)
end
end
......
# 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:
# User-agent: *
# Disallow: /
User-agent: *
Disallow: /
require "digest"
require "fog"
require 'digest'
require 'fog'
bucket_name = ENV["AWS_S3_BUCKET"]
bucket_name = ENV['AWS_S3_BUCKET']
architecture = `uname -m`.strip
file_name = "#{ENV['BUNDLE_ARCHIVE']}-#{architecture}.tgz"
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"
old_digest = File.expand_path("~/remote_#{digest_filename}")
puts "Checking for changes"
puts 'Checking for changes'
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
puts "=> There were no changes, doing nothing"
puts '=> There were no changes, doing nothing'
else
if old_digest == ""
puts "=> There was no existing digest, uploading a new version of the archive"
if old_digest == ''
puts '=> There was no existing digest, uploading a new version of the archive'
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 " => New checksum: #{bundle_digest}"
end
puts "=> Preparing bundle archive"
puts '=> Preparing bundle archive'
`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
storage = Fog::Storage.new({
:provider => "AWS",
:aws_access_key_id => ENV["AWS_S3_KEY"],
:aws_secret_access_key => ENV["AWS_S3_SECRET"],
:region => ENV["AWS_S3_REGION"] || "us-east-1"
})
storage = Fog::Storage.new(
provider: 'AWS',
aws_access_key_id: ENV['AWS_S3_KEY'],
aws_secret_access_key: ENV['AWS_S3_SECRET'],
region: ENV['AWS_S3_REGION'] || 'us-east-1'
)
puts "=> Uploading the bundle"
puts " => Beginning multipart upload"
response = storage.initiate_multipart_upload bucket_name, file_name, { "x-amz-acl" => "public-read" }
puts '=> Uploading the bundle'
puts ' => Beginning multipart upload'
response = storage.initiate_multipart_upload bucket_name, file_name, 'x-amz-acl' => 'public-read'
upload_id = response.body['UploadId']
puts " => Upload ID: #{upload_id}"
......@@ -53,22 +53,22 @@ else
File.open part do |part_file|
response = storage.upload_part bucket_name, file_name, upload_id, part_number, part_file
part_ids << response.headers['ETag']
puts " => Uploaded"
puts ' => Uploaded'
end
end
puts " => Completing multipart upload"
puts ' => Completing multipart upload'
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.files.create({
:body => bundle_digest,
:key => digest_filename,
:public => true,
:content_type => "text/plain"
})
bucket.files.create(
body: bundle_digest,
key: digest_filename,
public: true,
content_type: 'text/plain'
)
end
puts "All done now."
puts 'All done now.'
exit 0
......@@ -3,14 +3,14 @@ require 'rails_helper'
describe ApisController, type: :controller do
describe "GET 'markdown_preview'" do
it "returns http redirect" do
it 'returns http redirect' do
get 'markdown_preview'
expect(response).to redirect_to('/')
end
end
describe "GET 'markdown_preview'" do
it "returns http success" do
it 'returns http success' do
sign_in FactoryGirl.create(:alice)
get 'markdown_preview'
......
......@@ -3,14 +3,14 @@ require 'rails_helper'
describe FlowController, type: :controller do
describe "GET 'show' without login" do
it "returns http redirect" do
it 'returns http redirect' do
get 'show'
expect(response).to redirect_to('/')
end
end
describe "GET 'show' with login" do
it "returns http success" do
it 'returns http success' do
sign_in FactoryGirl.create(:alice)
get 'show'
......
......@@ -5,7 +5,7 @@ describe PostsController, type: :controller do
let(:post) { FactoryGirl.create(:post) }
describe "GET 'show' without login" do
it "returns http redirect" do
it 'returns http redirect' do
get 'show', id: post.id
expect(response).to redirect_to('/')
end
......@@ -15,14 +15,14 @@ describe PostsController, type: :controller do
let(:alice) { FactoryGirl.create(:alice) }
it "returns http success" do
it 'returns http success' do
sign_in FactoryGirl.create(:alice)
get 'show', id: post.id
expect(response).to be_success
end
it "returns http success" do
it 'returns http success' do
sign_in alice
get 'show', id: post.id
......
......@@ -3,14 +3,14 @@ require 'rails_helper'
describe SearchController, type: :controller do
describe "GET 'show' without login" do
it "returns http redirect" do
it 'returns http redirect' do
get 'show'
expect(response).to redirect_to('/')
end
end
describe "GET 'show' with login" do
it "returns http success" do
it 'returns http success' do
sign_in FactoryGirl.create(:alice)
get 'show'
......
......@@ -3,14 +3,14 @@ require 'rails_helper'
describe StockController, type: :controller do
describe "GET 'show' without login" do
it "returns http redirect" do
it 'returns http redirect' do
get 'show'
expect(response).to redirect_to('/')
end
end
describe "GET 'show' with login" do
it "returns http success" do
it 'returns http success' do
sign_in FactoryGirl.create(:alice)
get 'show'
......
......@@ -5,14 +5,14 @@ describe TagsController, type: :controller do
let(:tag) { FactoryGirl.create(:tag_ruby) }
describe "GET 'show' without login" do
it "returns http redirect" do
it 'returns http redirect' do
get 'show', name: tag.name
expect(response).to redirect_to('/')
end
end
describe "GET 'show' with login" do
it "returns http success" do
it 'returns http success' do
sign_in FactoryGirl.create(:alice)
get 'show', name: tag.name
......
require 'rails_helper'
RSpec.describe TemplatesController, :type => :controller do
RSpec.describe TemplatesController, type: :controller do
describe "GET 'show' without template" do
it "returns http success" do
it 'returns http success' do
sign_in FactoryGirl.create(:alice)
get 'show'
......@@ -12,7 +12,7 @@ RSpec.describe TemplatesController, :type => :controller do
end
describe "GET 'show' with template" do
it "returns http success" do
it 'returns http success' do
sign_in FactoryGirl.create(:alice)
get 'show'
......
......@@ -3,20 +3,20 @@ require 'rails_helper'
describe UsersController, type: :controller do
describe "GET 'edit'" do
it "returns http success" do
it 'returns http success' do
sign_in FactoryGirl.create(:alice)
get :edit
response.should be_success
expect(response).to be_success
end
end
describe "GET 'update'" do
it "returns http success" do
it 'returns http success' do
sign_in FactoryGirl.create(:alice)
patch :update, user: { nickname: 'bob' }
response.should redirect_to('/user/edit')
expect(response).to redirect_to('/user/edit')
end
end
......
require 'rails_helper'
RSpec.describe WatchingsController, :type => :controller do
RSpec.describe WatchingsController, type: :controller do
describe "GET 'show' without login" do
it "returns http redirect" do
it 'returns http redirect' do
get 'show'
expect(response).to redirect_to('/')
end
end
describe "GET 'show' with login" do
it "returns http success" do
it 'returns http success' do
sign_in FactoryGirl.create(:alice)
get 'show'
......
......@@ -10,6 +10,6 @@ require 'rails_helper'
# end
# end
# end
RSpec.describe TemplatesHelper, :type => :helper do
RSpec.describe TemplatesHelper, type: :helper do
pending "add some examples to (or delete) #{__FILE__}"
end
......@@ -10,6 +10,6 @@ require 'rails_helper'
# end
# end
# end
RSpec.describe WatchingsHelper, :type => :helper do
RSpec.describe WatchingsHelper, type: :helper do
pending "add some examples to (or delete) #{__FILE__}"
end
......@@ -11,6 +11,6 @@
require 'rails_helper'
RSpec.describe Footprint, :type => :model do
RSpec.describe Footprint, type: :model do
pending "add some examples to (or delete) #{__FILE__}"
end
require 'rails_helper'
RSpec.describe MarkdownRenderer, :type => :model do
it "tests #render" do
RSpec.describe MarkdownRenderer, type: :model do
it 'tests #render' do
renderer = MarkdownRenderer.new(<<EOS)
# title
- body
- test
EOS
expect(renderer.render.to_s.gsub(/^ +/, '')).to eq(<<EOS)
<h1>title</h1>
......@@ -18,7 +19,7 @@ EOS
EOS
end
it "tests #render with slides" do
it 'tests #render with slides' do
renderer = MarkdownRenderer.new(<<EOS)
!slide!(http://test.com/slide-1.pdf)
!slide!(http://test.com/slide-2.pdf)
......@@ -26,12 +27,14 @@ EOS
expect(renderer.render.to_s.gsub(/^ +/, '')).to eq(<<EOS)
<p>
<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>
<br>
<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>
</p>
EOS
......
......@@ -23,7 +23,7 @@ describe Notification do
@post = create(:post)
end
it "notifies on post edited" do
it 'notifies on post edited' do
@bob.watch!(post: @post)
expect(@bob.watching?(post: @post)).to be_truthy
@post.reload
......@@ -32,7 +32,7 @@ describe Notification do
expect(@bob.notifications.size).to eq(1)
end
it "not duplicated notifies on post edited" do
it 'not duplicated notifies on post edited' do
@bob.watch!(post: @post)
expect(@bob.watching?(post: @post)).to be_truthy
@post.reload
......@@ -42,14 +42,14 @@ describe Notification do
expect(@bob.notifications.size).to eq(1)
end
it "not notifies on post edited by him" do
it 'not notifies on post edited by him' do
@bob.watch!(post: @post)
@post.reload
@post.update!(title: @post.title + ' [New!]', author: @bob)
expect(@bob.notifications.size).to eq(0)
end
it "notifies on post commented" do
it 'notifies on post commented' do
@bob.watch!(post: @post)
expect(@bob.watching?(post: @post)).to be_truthy
@post.reload
......@@ -58,24 +58,24 @@ describe Notification do
expect(@bob.notifications.size).to eq(1)
end
it "not notifies on post commented by him" do
it 'not notifies on post commented by him' do
@bob.watch!(post: @post)
@post.reload
@post.comments.create!(author: @bob, body: 'new comment')
expect(@bob.notifications.size).to eq(0)
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')
expect(@bob.watching?(post: new_post)).to be_truthy
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')
expect(@bob.watching?(post: @post)).to be_truthy
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')
expect(@bob.watching?(post: @post)).to be_truthy
end
......
......@@ -33,7 +33,7 @@ describe Tag do
end
end
describe '#set_parent!' do
describe '#parent_tag=' do
before :each do
@tag_ruby = Tag.create(name: 'ruby')
@tag_lang = Tag.create(name: 'lang')
......@@ -42,7 +42,7 @@ describe Tag do
it 'successfully moved' do
expect(@tag_ruby.parent).not_to eq(@tag_lang)
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_lang.children).to include(@tag_ruby)
end
......
......@@ -84,36 +84,36 @@ describe User do
it 'should require an email address' do
no_email_user = User.new(@attr.merge(email: ''))
no_email_user.should_not be_valid
expect(no_email_user).not_to be_valid
end
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|
valid_email_user = User.new(@attr.merge(email: address))
valid_email_user.should be_valid
expect(valid_email_user).to be_valid
end
end
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|
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
it 'should reject duplicate email addresses' do
User.create!(@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
it 'should reject email addresses identical up to case' do
upcased_email = @attr[:email].upcase
User.create!(@attr.merge(email: upcased_email))
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
describe 'passwords' do
......@@ -123,28 +123,28 @@ describe User do
end
it 'should have a password attribute' do
@user.should respond_to(:password)
expect(@user).to respond_to(:password)
end
it 'should have a password confirmation attribute' do
@user.should respond_to(:password_confirmation)
expect(@user).to respond_to(:password_confirmation)
end
end
describe 'password validations' 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
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
it 'should reject short passwords' do
short = 'a' * 5
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
......@@ -156,11 +156,11 @@ describe User do
end
it 'should have an encrypted password attribute' do
@user.should respond_to(:encrypted_password)
expect(@user).to respond_to(:encrypted_password)
end
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
......
require 'rails_helper'
RSpec.describe Watch, :type => :model do
RSpec.describe Watch, type: :model do
# describe "validations" do
# let(:alice) { create(:alice) }
# let(:post) { create(:post) }
......
......@@ -6,21 +6,20 @@ Coveralls.wear!
ENV['RAILS_ENV'] ||= 'test'
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/autorun'
# require 'rspec/autorun'
# require 'email_spec'
require 'factory_girl'
require 'capybara'
require 'capybara/rspec'
## Setting for polterguist.
require 'capybara/poltergeist'
def register_poltergeist(config)
def register_poltergeist(_config)
Capybara.register_driver :poltergeist do |app|
Capybara::Poltergeist::Driver.new(app, timeout: 60, js_errors: false)
end
......@@ -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.
ActiveRecord::Migration.check_pending! if defined?(ActiveRecord::Migration)
# 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/capybara'
......@@ -94,18 +92,18 @@ RSpec.configure do |config|
DatabaseRewinder.clean
end
config.include Devise::TestHelpers, :type => :controller
config.include Devise::TestHelpers, type: :controller
# config.extend ControllerMacros, :type => :controller
# Capybara.app_host = "http://127.0.0.1/"
register_poltergeist(config)
OmniAuth.config.test_mode = true
OmniAuth.config.add_mock(:google_oauth2, {
'uid' => '12345',
'provider' => 'google_oauth2',
'info' => {'name' => 'Taro Yamada', 'email' => 'taro@zigexn.co.jp'},
'credentials' => {'token' => 'aaaaa', 'refresh_token' => 'bbbbb', 'expires_at' => 9999999999}
})
OmniAuth.config.add_mock(:google_oauth2,
'uid' => '12345',
'provider' => 'google_oauth2',
'info' => { 'name' => 'Taro Yamada', 'email' => 'taro@zigexn.co.jp' },
'credentials' => { 'token' => 'aaaaa', 'refresh_token' => 'bbbbb', 'expires_at' => 9_999_999_999 }
)
end
......@@ -37,8 +37,8 @@ step 'create post :title' do |title|
end
step 'search by :query' do |query|
within("#app-search-form") do
fill_in 'q', :with => query
within('#app-search-form') do
fill_in 'q', with: query
end
first(:css, "#app-search-form button[type='submit']").click
end
......
......@@ -2,7 +2,7 @@ module ControllerMacros
def login_user
before(:each) do
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)
end
end
......
# Set RAILS_ROOT and load the environment if it's not already loaded.
unless defined?(Rails)
ENV["RAILS_ROOT"] = File.expand_path("../../", __FILE__)
require File.expand_path("../../config/environment", __FILE__)
ENV['RAILS_ROOT'] = File.expand_path('../../', __FILE__)
require File.expand_path('../../config/environment', __FILE__)
end
Teaspoon.configure do |config|
# 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.
#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
# be useful to set this to your engines root (e.g. `Teaspoon::Engine.root`).
# Note: Defaults to `Rails.root` if nil.
#config.root = nil
# config.root = nil
# Paths that will be appended to the Rails assets paths
# 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
# be rendered as fixtures.
#config.fixture_paths = ["spec/javascripts/fixtures"]
# config.fixture_paths = ["spec/javascripts/fixtures"]
# SUITES
#
......@@ -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
# 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
# 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
# libraries from your spec helper.
# Note: For CoffeeScript files use `"teaspoon/jasmine"` etc.
#
# 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.
# 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
# a `_boot.html.erb` in your fixtures path, and adjust the config to `"/boot"` for instance.
#
# 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.
#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
# 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
# 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
# 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.
#config.suite :targeted do |suite|
# config.suite :targeted do |suite|
# suite.matcher = "test/javascripts/targeted/*_test.{js,js.coffee,coffee}"
#end
# end
# CONSOLE RUNNER SPECIFIC
#
......@@ -105,44 +105,44 @@ Teaspoon.configure do |config|
# Available: phantomjs, selenium
# PhantomJS: https://github.com/modeset/teaspoon/wiki/Using-PhantomJS
# Selenium Webdriver: https://github.com/modeset/teaspoon/wiki/Using-Selenium-WebDriver
#config.driver = "phantomjs"
# config.driver = "phantomjs"
# Specify additional options for the driver.
#
# PhantomJS: https://github.com/modeset/teaspoon/wiki/Using-PhantomJS
# 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
# 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.
#config.server = nil
# config.server = nil
# 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
# 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
# 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.
# 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
#config.formatters = ["dot"]
# config.formatters = ["dot"]
# 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
# remove them, but in verbose applications this may not be desirable.
#config.suppress_log = false
# config.suppress_log = false
# COVERAGE REPORTS / THRESHOLD ASSERTIONS
#
......@@ -157,25 +157,25 @@ Teaspoon.configure do |config|
# - with the cli: teaspoon --coverage=[coverage_name]
# 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.
#
# 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.
# 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
# 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.functions = nil
#coverage.branches = nil
#coverage.lines = nil
# coverage.statements = nil
# coverage.functions = nil
# coverage.branches = nil
# coverage.lines = nil
end
......
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__}"
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