Commit c339ce73 by tady

rspec修正:通過

parent ad76c651
...@@ -16,7 +16,7 @@ guard :rspec do ...@@ -16,7 +16,7 @@ guard :rspec do
watch(%r{^spec/steps/(.+)_steps\.rb$}) { |m| Dir[File.join("**/#{m[1]}.feature")][0] || 'spec/acceptance' } watch(%r{^spec/steps/(.+)_steps\.rb$}) { |m| Dir[File.join("**/#{m[1]}.feature")][0] || 'spec/acceptance' }
end end
guard :teaspoon do # guard :teaspoon do
watch(%r{^app/assets/javascripts/(.+).js}) { |m| "spec/javascripts/#{m[1]}_spec.js.coffee" } # watch(%r{^app/assets/javascripts/(.+).js}) { |m| "spec/javascripts/#{m[1]}_spec.js.coffee" }
watch(%r{^spec/javascripts/(.*)}) # watch(%r{^spec/javascripts/(.*)})
end # end
...@@ -5,7 +5,9 @@ class ApplicationController < ActionController::Base ...@@ -5,7 +5,9 @@ class ApplicationController < ActionController::Base
add_breadcrumb("Rendezvous", '/') add_breadcrumb("Rendezvous", '/')
def require_login before_action :redirect_unless_signed_in
def redirect_unless_signed_in
unless user_signed_in? unless user_signed_in?
flash[:alert] = 'You need Login!' flash[:alert] = 'You need Login!'
session[:login_redirect_to] = request.url session[:login_redirect_to] = request.url
......
class FlowController < ApplicationController class FlowController < ApplicationController
before_action :require_login
def show def show
@posts = Post.includes(:tags, :author).where(is_draft: false).order(updated_at: :desc).limit(20).decorate @posts = Post.includes(:tags, :author).where(is_draft: false).order(updated_at: :desc).limit(20).decorate
......
...@@ -2,7 +2,6 @@ require 'nkf' ...@@ -2,7 +2,6 @@ require 'nkf'
class PostsController < ApplicationController class PostsController < ApplicationController
before_action :set_post, only: [:show, :edit, :update, :destroy, :slideshow] before_action :set_post, only: [:show, :edit, :update, :destroy, :slideshow]
before_action :require_login
include RV::Mailer include RV::Mailer
...@@ -23,12 +22,6 @@ class PostsController < ApplicationController ...@@ -23,12 +22,6 @@ class PostsController < ApplicationController
add_breadcrumb("##{_tag.name}", _tag.decorate.show_path) add_breadcrumb("##{_tag.name}", _tag.decorate.show_path)
end end
add_breadcrumb(@post.title) add_breadcrumb(@post.title)
if params[:fragment].present?
render layout: false, partial: 'posts/show_fragment'
else
render
end
end end
# GET /posts/new # GET /posts/new
...@@ -67,7 +60,7 @@ class PostsController < ApplicationController ...@@ -67,7 +60,7 @@ class PostsController < ApplicationController
respond_to do |format| respond_to do |format|
if @post.save if @post.save
format.html { redirect_to root_path(id: @post.id), flash: { notice: 'Post was successfully created.' } } format.html { redirect_to post_path(id: @post.id), flash: { notice: 'Post was successfully created.' } }
format.json { render action: 'show', status: :created, location: @post } format.json { render action: 'show', status: :created, location: @post }
else else
format.html { render action: 'new' } format.html { render action: 'new' }
...@@ -83,7 +76,7 @@ class PostsController < ApplicationController ...@@ -83,7 +76,7 @@ class PostsController < ApplicationController
respond_to do |format| respond_to do |format|
if @post.update(post_params) if @post.update(post_params)
format.html { redirect_to root_path(id: @post.id), flash: { notice: 'Post was successfully updated.' } } format.html { redirect_to post_path(id: @post.id), flash: { notice: 'Post was successfully updated.' } }
format.json { head :no_content } format.json { head :no_content }
else else
format.html { render action: 'edit' } format.html { render action: 'edit' }
......
class SearchController < ApplicationController class SearchController < ApplicationController
before_action :require_login
def show def show
if params[:q].present? if params[:q].present?
......
class StockController < ApplicationController class StockController < ApplicationController
before_action :require_login
def show def show
end end
......
class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController
skip_before_action :redirect_unless_signed_in
def google_oauth2 def google_oauth2
email = request.env['omniauth.auth'].info['email'] email = request.env['omniauth.auth'].info['email']
......
class WelcomeController < ApplicationController class WelcomeController < ApplicationController
skip_before_action :require_login
skip_before_action :redirect_unless_signed_in
def top def top
if user_signed_in? if user_signed_in?
......
.panel.panel-default
.panel-heading
h3.panel-title
a href=post_path(@post) = @post.title
ul.list-group
li.list-group-item
- @post.tags.each do |tag|
span.label.label-success
a href=tag.decorate.show_path
| ##{tag.name}
| &nbsp;
span.label.label-info
a href=(search_path(q: "@#{@post.author.name}"))
| @#{@post.author.name}
| &nbsp;
span.label.label-danger
a href=(search_path(q: "date:#{@post.display_date}")) = @post.display_date
.btn-group.pull-right style=("margin: -7px -12px 0 0;")
a.btn.btn-primary href=edit_post_path(@post)
span.glyphicon.glyphicon-pencil
button.btn.btn-default.dropdown-toggle data-toggle="dropdown" type="button"
span.caret
span.sr-only Toggle Dropdown
ul.dropdown-menu role="menu"
li
a href=slideshow_post_path(@post) target="_blank" Slideshow
li
a.small href="https://github.com/gnab/remark" target="_blank" What is Slideshow?
li.divider
li
a href=fork_post_path(@post) Fork
li
a data-target="#myModal" data-toggle="modal" href="#" Mail to...
li.divider
li= link_to 'Delete', post_path(@post), method: :delete, data: { confirm: 'Are you sure?' }
.panel-body.viewer.github
= h_application_format_markdown(@post.body)
.panel.panel-success
.panel-heading
h3.panel-title Comments
.panel-body
ul.media-list
- @post.comments.each do |comment|
li.media
a.pull-left href="#"
img.media-object src=comment.author.image_url /
.media-body
h4.media-heading= comment.author.name
= comment.body
= form_tag(comment_post_path, method: :post, data: { 'form-id' => "comment_#{@post.id}" }) do
li.media
a.pull-left href="#"
img.media-object src=current_user.image_url /
.media-body
h4.media-heading= current_user.name
= text_area :comment, :body, class: 'form-control', placeholder: 'コメントする...'
= submit_tag 'Comment', class: 'btn btn-primary', data: { 'disable-with' => '...' }
javascript:
$("form[data-form-id='comment_#{@post.id}']").on('ajax:success', function(event, data, xhr) {
});
/! Button trigger modal
/!
| <button class="btn btn-primary btn-lg" data-toggle="modal" data-target="#myModal"
| Launch demo modal
| </button
/! Modal
#myModal.modal.fade aria-hidden="true" aria-labelledby="myModalLabel" role="dialog" tabindex="-1"
.modal-dialog
.modal-content
= form_tag mail_post_path(@post), method: :post, class: 'form-horizontal', role: 'form' do
.modal-header
button.close aria-hidden="true" data-dismiss="modal" type="button" &times;
h4#myModalLabel.modal-title Mail this post to...
.modal-body
.form-group
label.col-sm-2.control-label Title
.col-sm-10
input.form-control readonly="" type="text" value=@post.title /
.form-group
label.col-sm-2.control-label for="inputEmail3" To
.col-sm-10
input#inputEmail3.form-control name="mail[to]" placeholder="Email" type="email" /
.form-group
label.col-sm-2.control-label From
.col-sm-10
input.form-control readonly="" type="text" value=current_user.email /
.modal-footer
button.btn.btn-default data-dismiss="modal" type="button" Close
button.btn.btn-primary data-disable-with="Sending..." type="submit" Send
/! /.modal-content
/! /.modal-dialog
/! /.modal
= render_breadcrumbs = render_breadcrumbs
.row .row
div .panel.panel-default
= render partial: 'posts/show_fragment' .panel-heading
/! /row h3.panel-title
a href=post_path(@post) = @post.title
ul.list-group
li.list-group-item
- @post.tags.each do |tag|
span.label.label-success
a href=tag.decorate.show_path
| ##{tag.name}
| &nbsp;
span.label.label-info
a href=(search_path(q: "@#{@post.author.name}"))
| @#{@post.author.name}
| &nbsp;
span.label.label-danger
a href=(search_path(q: "date:#{@post.display_date}")) = @post.display_date
.btn-group.pull-right style=("margin: -7px -12px 0 0;")
a.btn.btn-primary href=edit_post_path(@post)
span.glyphicon.glyphicon-pencil
button.btn.btn-default.dropdown-toggle data-toggle="dropdown" type="button"
span.caret
span.sr-only Toggle Dropdown
ul.dropdown-menu role="menu"
li
a href=slideshow_post_path(@post) target="_blank" Slideshow
li
a.small href="https://github.com/gnab/remark" target="_blank" What is Slideshow?
li.divider
li
a href=fork_post_path(@post) Fork
li
a data-target="#myModal" data-toggle="modal" href="#" Mail to...
li.divider
li= link_to 'Delete', post_path(@post), method: :delete, data: { confirm: 'Are you sure?' }
.panel-body.viewer.github
= h_application_format_markdown(@post.body)
.panel.panel-success
.panel-heading
h3.panel-title Comments
.panel-body
ul.media-list
- @post.comments.each do |comment|
li.media
a.pull-left href="#"
img.media-object src=comment.author.image_url /
.media-body
h4.media-heading= comment.author.name
= comment.body
= form_tag(comment_post_path, method: :post, data: { 'form-id' => "comment_#{@post.id}" }) do
li.media
a.pull-left href="#"
img.media-object src=current_user.image_url /
.media-body
h4.media-heading= current_user.name
= text_area :comment, :body, class: 'form-control', placeholder: 'コメントする...'
= submit_tag 'Comment', class: 'btn btn-primary', data: { 'disable-with' => '...' }
javascript:
$("form[data-form-id='comment_#{@post.id}']").on('ajax:success', function(event, data, xhr) {
});
/! Button trigger modal
/!
/! Modal
#myModal.modal.fade aria-hidden="true" aria-labelledby="myModalLabel" role="dialog" tabindex="-1"
.modal-dialog
.modal-content
= form_tag mail_post_path(@post), method: :post, class: 'form-horizontal', role: 'form' do
.modal-header
button.close aria-hidden="true" data-dismiss="modal" type="button" &times;
h4#myModalLabel.modal-title Mail this post to...
.modal-body
.form-group
label.col-sm-2.control-label Title
.col-sm-10
input.form-control readonly="" type="text" value=@post.title /
.form-group
label.col-sm-2.control-label for="inputEmail3" To
.col-sm-10
input#inputEmail3.form-control name="mail[to]" placeholder="Email" type="email" /
.form-group
label.col-sm-2.control-label From
.col-sm-10
input.form-control readonly="" type="text" value=current_user.email /
.modal-footer
button.btn.btn-default data-dismiss="modal" type="button" Close
button.btn.btn-primary data-disable-with="Sending..." type="submit" Send
/! /.modal-content
/! /.modal-dialog
/! /.modal
...@@ -3,9 +3,18 @@ require 'spec_helper' ...@@ -3,9 +3,18 @@ require 'spec_helper'
describe ApisController do describe ApisController do
describe "GET 'markdown_preview'" do describe "GET 'markdown_preview'" do
it "returns http redirect" do
get 'markdown_preview'
expect(response).to redirect_to('/')
end
end
describe "GET 'markdown_preview'" do
login_user
it "returns http success" do it "returns http success" do
get 'markdown_preview' get 'markdown_preview'
response.should be_success expect(response).to be_success
end end
end end
......
...@@ -2,7 +2,7 @@ require 'spec_helper' ...@@ -2,7 +2,7 @@ require 'spec_helper'
describe ApplicationController do describe ApplicationController do
pending '#require_login' pending '#redirect_unless_signed_in'
pending '#after_sign_in_path_for' pending '#after_sign_in_path_for'
......
...@@ -2,11 +2,19 @@ require 'spec_helper' ...@@ -2,11 +2,19 @@ require 'spec_helper'
describe FlowController do describe FlowController do
describe "GET 'show'" do describe "GET 'show' without login" do
it "returns http redirect" do
get 'show'
expect(response).to redirect_to('/')
end
end
describe "GET 'show' with login" do
login_user login_user
it "returns http success" do it "returns http success" do
get 'show' get 'show'
response.should be_success expect(response).to be_success
end end
end end
......
...@@ -2,11 +2,19 @@ require 'spec_helper' ...@@ -2,11 +2,19 @@ require 'spec_helper'
describe SearchController do describe SearchController do
describe "GET 'show'" do describe "GET 'show' without login" do
it "returns http redirect" do
get 'show'
expect(response).to redirect_to('/')
end
end
describe "GET 'show' with login" do
login_user login_user
it "returns http success" do it "returns http success" do
get 'show' get 'show'
response.should be_success expect(response).to be_success
end end
end end
......
...@@ -2,11 +2,19 @@ require 'spec_helper' ...@@ -2,11 +2,19 @@ require 'spec_helper'
describe StockController do describe StockController do
describe "GET 'show'" do describe "GET 'show' without login" do
it "returns http redirect" do
get 'show'
expect(response).to redirect_to('/')
end
end
describe "GET 'show' with login" do
login_user login_user
it "returns http success" do it "returns http success" do
get 'show' get 'show'
response.should be_success expect(response).to be_success
end end
end end
......
...@@ -2,12 +2,22 @@ require 'spec_helper' ...@@ -2,12 +2,22 @@ require 'spec_helper'
describe TagsController do describe TagsController do
describe "GET 'show'" do let(:tag) { FactoryGirl.create(:tag_ruby) }
pending '...'
describe "GET 'show' without login" do
it "returns http redirect" do
get 'show', name: tag.name
expect(response).to redirect_to('/')
end
end end
describe "GET 'events'" do describe "GET 'show' with login" do
pending '...' login_user
it "returns http success" do
get 'show', name: tag.name
expect(response).to be_success
end
end end
end end
...@@ -22,7 +22,7 @@ require 'capybara/poltergeist' ...@@ -22,7 +22,7 @@ require 'capybara/poltergeist'
def register_poltergeist(config) def register_poltergeist(config)
Capybara.register_driver :poltergeist do |app| Capybara.register_driver :poltergeist do |app|
Capybara::Poltergeist::Driver.new(app, timeout: 60) Capybara::Poltergeist::Driver.new(app, timeout: 60, js_errors: false)
end end
# Capybara.run_server = true # Capybara.run_server = true
# Capybara.default_driver = :poltergeist # Capybara.default_driver = :poltergeist
......
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