Commit cc5dc7dc by tady

config rubocop

parent 51feadb2
AllCops:
# Rails特有のチェックを実行
RunRailsCops: true
# チェック対象外ディレクトリ
Exclude:
- 'db/**/*'
- 'config/**/*'
- 'script/**/*'
- 'bin/**/*'
- 'vendor/**/*'
- 'Guardfile'
# Ascii文字以外のコメントを許容
Style/AsciiComments:
Enabled: false
LineLength:
Max: 159
# 1行の最大文字列長を緩和
Metrics/LineLength:
Max: 160
NumericLiterals:
Enabled: false
# メソッド定義の行数を緩和
Metrics/MethodLength:
Max: 50
Documentation:
Enabled: false
# Classの最大長制限
Metrics/ClassLength:
Max: 300
WordArray:
# top-classでのコメントを任意に
Style/Documentation:
Enabled: false
MethodLength:
Max: 30
# 1行if文を使用可に
Style/IfUnlessModifier:
Enabled: false
IfUnlessModifier:
# nestしたclass/moduleを許容
Style/ClassAndModuleChildren:
Enabled: false
CyclomaticComplexity:
Max: 10
# 後置rescueを許容
Style/RescueModifier:
Enabled: false
RaiseArgs:
# and/orを許容
Style/AndOr:
Enabled: false
......@@ -82,6 +82,8 @@ group :development do
gem 'capistrano-rails', '~> 1.1'
gem 'capistrano-rbenv', '~> 2.0'
gem 'capistrano3-unicorn'
gem 'travis'
end
group :development, :test do
......@@ -139,21 +141,19 @@ 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
......
......@@ -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,111 +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)
......@@ -338,6 +246,7 @@ GEM
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 +295,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 +413,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 +446,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)
......@@ -587,6 +513,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]) }
......
require 'digest/md5'
class ApisController < ApplicationController
# TODO: not to use
include ApplicationHelper
......@@ -26,7 +25,7 @@ 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
......@@ -34,7 +33,7 @@ class ApisController < ApplicationController
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"
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,7 +3,7 @@ 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
......
......@@ -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
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,7 +64,7 @@ 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)
......@@ -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
......@@ -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)
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
......@@ -30,11 +30,11 @@ class TagDecorator < Draper::Decorator
def tree_view_node
_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|
......@@ -46,5 +46,4 @@ class TagDecorator < Draper::Decorator
_html.html_safe
end
end
class TagsDecorator < Draper::CollectionDecorator
# tagをtree viewで表示する
def tree_view
_html = ''
_html += %Q{
_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}
</li>
}
)
end
_html += "</ul>"
_html += '</ul>'
_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"
fail '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!
......
......@@ -4,14 +4,14 @@ module HipchatIntegration
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)
client[Settings.hipchat.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,14 @@ 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 +21,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
......
......@@ -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
......@@ -88,9 +88,8 @@ 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)
......@@ -98,7 +97,7 @@ class Post < ActiveRecord::Base
_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.tag_ids = tag_ids
_forked_post.author = user
_forked_post.specified_date = Date.today
......@@ -107,7 +106,7 @@ class Post < ActiveRecord::Base
# slideshow用のbody
def body_for_slideshow
self.body.gsub(/^#/, "---\n\n#")
body.gsub(/^#/, "---\n\n#")
end
def visited_user_count
......
......@@ -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,33 +21,29 @@ 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|
posts.each do |_post|
_post.tags.delete(self)
_post.tags << other_tag unless _post.tags.include?(other_tag)
end
......
......@@ -41,7 +41,7 @@ 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
......@@ -54,7 +54,6 @@ class User < ActiveRecord::Base
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|
def self.find_for_google_oauth2(access_token, _signed_in_resource = nil)
user = 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
_user.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,
......@@ -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
......@@ -35,8 +35,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
......
Rendezvous::Application.routes.draw do
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".
......
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
......@@ -6,7 +6,7 @@ namespace :migrations do
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
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
......
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,7 +3,7 @@ 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
......@@ -12,7 +12,7 @@ describe UsersController, type: :controller do
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' }
......
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
......@@ -18,7 +18,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)
......
......@@ -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
......
......@@ -88,7 +88,7 @@ describe User do
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
......@@ -96,7 +96,7 @@ describe User do
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
......
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,7 +6,7 @@ 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'
......@@ -16,11 +16,10 @@ 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