Commit 6180b5dc by tady

Merge branch 'wip/feat/0107_comments'

parents 9a63a132 3d579144
# Load DSL and Setup Up Stages
require 'capistrano/setup'
# Includes default deployment tasks
require 'capistrano/deploy'
# Includes tasks from other gems included in your Gemfile
#
# For documentation on these, see for example:
#
# https://github.com/capistrano/rvm
# https://github.com/capistrano/rbenv
# https://github.com/capistrano/chruby
# https://github.com/capistrano/bundler
# https://github.com/capistrano/rails
#
# require 'capistrano/rvm'
require 'capistrano/rbenv'
# require 'capistrano/chruby'
require 'capistrano/bundler'
require 'capistrano/rails/assets'
require 'capistrano/rails/migrations'
# Loads custom tasks from `lib/capistrano/tasks' if you have any defined.
Dir.glob('lib/capistrano/tasks/*.cap').each { |r| import r }
......@@ -41,16 +41,12 @@ end
# Use unicorn as the app server
# gem 'unicorn'
# Use Capistrano for deployment
# gem 'capistrano', group: :development
# Use debugger
# gem 'debugger', group: [:development, :test]
# gem 'bootstrap-sass-rails'
gem 'mysql2'
gem 'sqlite3'
gem 'devise'
gem 'omniauth-google-oauth2'
......@@ -69,8 +65,6 @@ group :development do
gem 'thin'
# gem 'capistrano', '~> 3.0.1'
gem 'pry-rails'
# profiler
......@@ -81,6 +75,12 @@ group :development do
gem 'guard-rubocop'
gem 'guard-spring'
gem 'spring'
# Use Capistrano for deployment
gem 'capistrano', '~> 3.1'
gem 'capistrano-bundler', '~> 1.1.2'
gem 'capistrano-rails', '~> 1.1'
gem 'capistrano-rbenv', '~> 2.0'
end
group :development, :test do
......
......@@ -54,6 +54,19 @@ GEM
binding_of_caller (0.7.2)
debug_inspector (>= 0.0.1)
builder (3.1.4)
capistrano (3.1.0)
i18n
rake (>= 10.0.0)
sshkit (~> 1.3)
capistrano-bundler (1.1.2)
capistrano (~> 3.0)
sshkit (~> 1.2)
capistrano-rails (1.1.1)
capistrano (~> 3.1)
capistrano-bundler (~> 1.1)
capistrano-rbenv (2.0.2)
capistrano (~> 3.1)
sshkit (~> 1.3)
capybara (2.2.1)
mime-types (>= 1.16)
nokogiri (>= 1.3.3)
......@@ -165,6 +178,9 @@ GEM
mysql2 (0.3.14)
net-http-digest_auth (1.4)
net-http-persistent (2.9)
net-scp (1.1.2)
net-ssh (>= 2.6.5)
net-ssh (2.8.0)
nokogiri (1.6.1)
mini_portile (~> 0.5.0)
ntlm-http (0.1.1)
......@@ -272,6 +288,10 @@ GEM
activesupport (>= 3.0)
sprockets (~> 2.8)
sqlite3 (1.3.8)
sshkit (1.3.0)
net-scp (>= 1.1.2)
net-ssh
term-ansicolor
term-ansicolor (1.2.2)
tins (~> 0.8)
thin (1.6.1)
......@@ -310,6 +330,10 @@ DEPENDENCIES
ancestry
better_errors
binding_of_caller
capistrano (~> 3.1)
capistrano-bundler (~> 1.1.2)
capistrano-rails (~> 1.1)
capistrano-rbenv (~> 2.0)
capybara
coderay
coffee-rails
......
......@@ -36,9 +36,11 @@ class Post < ActiveRecord::Base
# generate forked post (not saved)
def generate_fork(user)
forked_post = clone
forked_post = Post.new(self.attributes.except(:id))
forked_post.title = forked_post.title.gsub(/%Name/, user.name)
forked_post.title = Time.now.strftime(forked_post.title) # TODO
forked_post.tag_ids = self.tag_ids
forked_post.author = user
forked_post
......
......@@ -22,9 +22,9 @@
<!-- Split button -->
<div class="btn-group pull-right" style="margin: -7px -12px 0 0;">
<button type="button" class="btn btn-primary">
<a class="btn btn-primary" href="<%= edit_post_path(@post) %>">
<span class="glyphicon glyphicon-pencil"></span>
</button>
</a>
<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
<span class="caret"></span>
<span class="sr-only">Toggle Dropdown</span>
......
......@@ -32,7 +32,11 @@ test:
host: <%= ENV['DB_TEST_HOST'] %>
production:
adapter: sqlite3
database: db/production.sqlite3
adapter: mysql2
encoding: utf8
reconnect: false
database: <%= ENV['DB_PRODUCTION_DATABASE'] %>
pool: 5
timeout: 5000
username: <%= ENV['DB_PRODUCTION_USER'] %>
password: <%= ENV['DB_PRODUCTION_PASS'] %>
host: <%= ENV['DB_PRODUCTION_HOST'] %>
# config valid only for Capistrano 3.1
lock '3.1.0'
set :application, 'rendezvous'
set :repo_url, 'git@github.com:tadyjp/rendezvous.git'
# Default branch is :master
# ask :branch, proc { `git rev-parse --abbrev-ref HEAD`.chomp }
# Default deploy_to directory is /var/www/my_app
set :deploy_to, '/var/rails/rendezvous'
# Default value for :scm is :git
# set :scm, :git
# Default value for :format is :pretty
# set :format, :pretty
# Default value for :log_level is :debug
# set :log_level, :debug
# Default value for :pty is false
# set :pty, true
# Default value for :linked_files is []
# set :linked_files, %w{config/database.yml}
# Default value for linked_dirs is []
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" }
# Default value for keep_releases is 5
set :keep_releases, 5
set :rbenv_type, :system
set :rbenv_ruby, '2.0.0-p353'
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_roles, :all # default value
after 'deploy:publishing', 'deploy:restart'
namespace :deploy do
desc 'Restart application'
task :restart do
on roles(:app), in: :sequence, wait: 5 do
# Your restart mechanism here, for example:
execute :touch, release_path.join('tmp/restart.txt')
end
end
after :publishing, :restart
after :restart, :clear_cache do
on roles(:web), in: :groups, limit: 3, wait: 10 do
# Here we can do anything such as:
# within release_path do
# execute :rake, 'cache:clear'
# end
end
end
end
# Simple Role Syntax
# ==================
# Supports bulk-adding hosts to roles, the primary
# 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}
# Extended Server Syntax
# ======================
# This can be used to drop a more detailed server
# 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
# 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
# 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(/Users/tady/.ssh/id_rsa_07PC12),
forward_agent: true,
auth_methods: %w(publickey)
}
# and/or per server
# server 'example.com',
# user: 'user_name',
# roles: %w{web app},
# ssh_options: {
# user: 'user_name', # overrides user setting above
# keys: %w(/home/user_name/.ssh/id_rsa),
# forward_agent: false,
# auth_methods: %w(publickey password)
# # password: 'please use keys'
# }
# setting per server overrides global ssh_options
# Simple Role Syntax
# ==================
# Supports bulk-adding hosts to roles, the primary
# 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}
# Extended Server Syntax
# ======================
# This can be used to drop a more detailed server
# 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
# 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
# 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(/home/rlisowski/.ssh/id_rsa),
# forward_agent: false,
# auth_methods: %w(password)
# }
# and/or per server
# server 'example.com',
# user: 'user_name',
# roles: %w{web app},
# ssh_options: {
# user: 'user_name', # overrides user setting above
# keys: %w(/home/user_name/.ssh/id_rsa),
# forward_agent: false,
# auth_methods: %w(publickey password)
# # password: 'please use keys'
# }
# setting per server overrides global ssh_options
......@@ -13,65 +13,65 @@
ActiveRecord::Schema.define(version: 20140106160129) 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 '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
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'
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"
end
create_table 'tags', force: true do |t|
t.string 'name'
t.datetime 'created_at'
t.datetime 'updated_at'
t.string 'ancestry'
create_table "tags", force: true do |t|
t.string "name"
t.datetime "created_at"
t.datetime "updated_at"
t.string "ancestry"
end
add_index 'tags', ['ancestry'], name: 'index_tags_on_ancestry', using: :btree
add_index "tags", ["ancestry"], name: "index_tags_on_ancestry", using: :btree
create_table 'users', force: true do |t|
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'
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"
end
add_index 'users', ['email'], name: 'index_users_on_email', unique: true, using: :btree
add_index 'users', ['reset_password_token'], name: 'index_users_on_reset_password_token', unique: true, using: :btree
add_index "users", ["email"], name: "index_users_on_email", unique: true, using: :btree
add_index "users", ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true, using: :btree
end
......@@ -6,26 +6,33 @@ describe Post do
before :each do
@post = create(:post)
@alice = create(:alice)
@new_post = @post.generate_fork(@alice).save
end
describe 'Fork' do
subject { @post.generate_fork(@alice) }
# subject {
# @post.generate_fork(@alice).save
# }
it 'duplicated' do
expect(@new_post.id).not_to eq(@post.id)
end
it 'valid title' do
expect(subject.title).to eq('sample title')
expect(@new_post.title).to eq('sample title')
end
it 'valid body' do
expect(subject.body).to eq('sample body')
expect(@new_post.body).to eq('sample body')
end
it 'valid user' do
expect(subject.author).to eq(@alice)
expect(@new_post.author).to eq(@alice)
end
it 'valid user' do
expect(subject.tags).to include(@post.tags.first)
expect(@new_post.tags).to include(@post.tags.first)
end
end
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment