繁体   English   中英

Hartl Rails教程第8章

[英]Hartl Rails Tutorial Chapter 8

由于某种原因,在运行规格测试时,Bootstrap上更新的导航下拉菜单布局在登录后无法呈现(即,它不显示“ Account”)。这是我的authentication_pages_spec:预先感谢您的帮助。

require 'spec_helper'

describe "Authentication" do

subject { page }

describe "signin page" do
    before { visit signin_path }

    it { should have_selector('h1',    text: 'Sign in') }
    it { should have_selector('title', text: 'Sign in') }
end

describe "signin" do
    before { visit signin_path }

    describe "with invalid information" do
        before { click_button "Sign in" }

        it { should have_selector('title', text: 'Sign in') }
        it { should have_selector('div.alert.alert-error', text: 'Invalid') }

        describe "after visiting another page" do
            before { click_link "Home" }
            it { should_not have_selector('div.alert.alert-error') }
        end
    end

    describe "with valid information" do
        let(:user){ FactoryGirl.create(:user) }
        before do
            fill_in "Email",    with: user.email.upcase
            fill_in "Password", with: user.password
            click_button "Sign in"
        end

        it { should have_selector('title',text: user.name) }

        it { should have_link('Users',    href: users_path) }
        it { should have_link('Profile',  href: users_path(path)) }
        it { should have_link('Settings', href: edit_user_path(user)) }
        it { should have_link('Sign out', href: signout_path) }
        it { should_not have_link('Sign in', href: signin_path) }

        describe "followed by signout" do
            before { click_link "Sign out" }
            it { should have_link('Sign in') }
        end
    end
  end
end

标题布局

<header class="navbar navbar-fixed-top navbar-inverse">
   <div class="navbar-inner">
<div class="container">
  <%= link_to "sample app", root_path, id: "logo" %>
  <nav>
    <ul class="nav pull-right">
      <li><%= link_to "Home", root_path %></li>
      <li><%= link_to "Help", help_path %></li>
      <% if signed_in? %>
        <li><%= link_to "Users", '#' %></li>
        <li id="fat-menu" class="dropdown">
          <a href="#" class="dropdown-toggle" data-toggle="dropdown">
            Account <b class="caret"></b>
          </a>
          <ul class="dropdown-menu">
            <li><%= link_to "Profile", current_user %></li>
            <li><%= link_to "Settings", '#' %></li>
            <li class="divider"></li>
            <li>
              <%= link_to "Sign out", signout_path, method: "delete" %>
            </li>
          </ul>
        </li>
      <% else %>
        <li><%= link_to "Sign in", signin_path %></li>
      <% end %>
    </ul>
  </nav>
</div>

问题出在您的app / assets / application.js文件中。

引导程序需要直接列在jquery的下面。

//= require jquery
//= require bootstrap
//= require jquery_ujs
//= require turbo links
//= require_tree .

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM