Commit c339ce73 by tady

rspec修正:通過

parent ad76c651
......@@ -16,7 +16,7 @@ guard :rspec do
watch(%r{^spec/steps/(.+)_steps\.rb$}) { |m| Dir[File.join("**/#{m[1]}.feature")][0] || 'spec/acceptance' }
end
guard :teaspoon do
watch(%r{^app/assets/javascripts/(.+).js}) { |m| "spec/javascripts/#{m[1]}_spec.js.coffee" }
watch(%r{^spec/javascripts/(.*)})
end
# guard :teaspoon do
# watch(%r{^app/assets/javascripts/(.+).js}) { |m| "spec/javascripts/#{m[1]}_spec.js.coffee" }
# watch(%r{^spec/javascripts/(.*)})
# end
......@@ -5,7 +5,9 @@ class ApplicationController < ActionController::Base
add_breadcrumb("Rendezvous", '/')
def require_login
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
......
class FlowController < ApplicationController
before_action :require_login
def show
@posts = Post.includes(:tags, :author).where(is_draft: false).order(updated_at: :desc).limit(20).decorate
......
......@@ -2,7 +2,6 @@ require 'nkf'
class PostsController < ApplicationController
before_action :set_post, only: [:show, :edit, :update, :destroy, :slideshow]
before_action :require_login
include RV::Mailer
......@@ -23,12 +22,6 @@ class PostsController < ApplicationController
add_breadcrumb("##{_tag.name}", _tag.decorate.show_path)
end
add_breadcrumb(@post.title)
if params[:fragment].present?
render layout: false, partial: 'posts/show_fragment'
else
render
end
end
# GET /posts/new
......@@ -67,7 +60,7 @@ class PostsController < ApplicationController
respond_to do |format|
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 }
else
format.html { render action: 'new' }
......@@ -83,7 +76,7 @@ class PostsController < ApplicationController
respond_to do |format|
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 }
else
format.html { render action: 'edit' }
......
class SearchController < ApplicationController
before_action :require_login
def show
if params[:q].present?
......
class StockController < ApplicationController
before_action :require_login
def show
end
......
class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController
skip_before_action :redirect_unless_signed_in
def google_oauth2
email = request.env['omniauth.auth'].info['email']
......
class WelcomeController < ApplicationController
skip_before_action :require_login
skip_before_action :redirect_unless_signed_in
def top
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
.row
div
= render partial: 'posts/show_fragment'
/! /row
.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
/!
/! 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'
describe ApisController 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
get 'markdown_preview'
response.should be_success
expect(response).to be_success
end
end
......
......@@ -2,7 +2,7 @@ require 'spec_helper'
describe ApplicationController do
pending '#require_login'
pending '#redirect_unless_signed_in'
pending '#after_sign_in_path_for'
......
......@@ -2,11 +2,19 @@ require 'spec_helper'
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
it "returns http success" do
get 'show'
response.should be_success
expect(response).to be_success
end
end
......
......@@ -2,11 +2,19 @@ require 'spec_helper'
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
it "returns http success" do
get 'show'
response.should be_success
expect(response).to be_success
end
end
......
......@@ -2,11 +2,19 @@ require 'spec_helper'
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
it "returns http success" do
get 'show'
response.should be_success
expect(response).to be_success
end
end
......
......@@ -2,12 +2,22 @@ require 'spec_helper'
describe TagsController do
describe "GET 'show'" do
pending '...'
let(:tag) { FactoryGirl.create(:tag_ruby) }
describe "GET 'show' without login" do
it "returns http redirect" do
get 'show', name: tag.name
expect(response).to redirect_to('/')
end
end
describe "GET 'events'" do
pending '...'
describe "GET 'show' with login" do
login_user
it "returns http success" do
get 'show', name: tag.name
expect(response).to be_success
end
end
end
......@@ -22,7 +22,7 @@ require 'capybara/poltergeist'
def register_poltergeist(config)
Capybara.register_driver :poltergeist do |app|
Capybara::Poltergeist::Driver.new(app, timeout: 60)
Capybara::Poltergeist::Driver.new(app, timeout: 60, js_errors: false)
end
# Capybara.run_server = true
# 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