ruby approval_workflow_spec.rb

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了ruby approval_workflow_spec.rb相关的知识,希望对你有一定的参考价值。

<!-- Trying to get the approval_workflow_spec to select from the options starting on line 92, but can never get this dropdown sleected in my test -->

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8" />
  <meta name="ROBOTS" content="NOODP" />
  <meta name="viewport" content="initial-scale=1" />
  <title>Edit Post #6 | Overtime</title>
  
  <link rel="stylesheet" media="screen" href="/assets/administrate/application.self-8dc609a13c6de3a4e2f330a5de0b2bfea1d7e16ffff8c0d5a4319ebb851b6476.css?body=1" />



  <meta name="csrf-param" content="authenticity_token" />
<meta name="csrf-token" content="tbIihlUGFtmI2zj9sCbADbUMxlob/BuNGa3sSTi8MoAl4QOQ7uuFvvS1VhGEt4yTCxGubD2CZiRoUwQckH3osg==" />
</head>

<body>

  <div class="app-container">

    <div class="sidebar">
      
<ul class="sidebar__list">
    <li>
      <a class="sidebar__link sidebar__link--inactive" href="/admin/users">Users</a>
    </li>
    <li>
      <a class="sidebar__link sidebar__link--active" href="/admin/posts">Posts</a>
    </li>
    <li>
      <a class="sidebar__link sidebar__link--inactive" href="/admin/admin_users">Admin Users</a>
    </li>
</ul>
    </div>

    <main class="main-content" role="main">
      
      
      

<header class="header">
  <h1 class="header__heading">Edit Post #6</h1>
  <div class="header__actions">
    <a class="button" href="/admin/posts/6">Show Post #6</a>
  </div>
</header>


<form class="form" id="edit_post_6" action="/admin/posts/6" accept-charset="UTF-8" method="post"><input name="utf8" type="hidden" value="&#x2713;" /><input type="hidden" name="_method" value="patch" /><input type="hidden" name="authenticity_token" value="YetiWMtK2VmudIc7GCEYXuLbn0vUY7FLGgVtNj2joTjxuENOcKdKPtIa6dcssFTAXMb3ffIdzOJr+4VjlWJ7Cg==" />

    <div class="field-unit field-unit--belongs-to">
      
<div class="field-unit__label">
  <label for="post_user_id">User</label>
</div>
<div class="field-unit__field">
  <select name="post[user_id]" id="post_user_id">
    <option value=""></option>
<option selected="selected" value="1">User #1</option>
<option value="2">AdminUser #2</option>
</select></div>

    </div>
    <div class="field-unit field-unit--date-time">
      
<div class="field-unit__label">
  <label for="post_date">Date</label>
</div>
<div class="field-unit__field">
  <input class="datetimepicker" type="text" value="2017-01-26" name="post[date]" id="post_date" />
</div>

    </div>
    <div class="field-unit field-unit--text">
      
<div class="field-unit__label">
  <label for="post_rationale">Rationale</label>
</div>
<div class="field-unit__field">
  <textarea name="post[rationale]" id="post_rationale">
5 rationale content</textarea>
</div>

    </div>
    <div class="field-unit field-unit--select">
      
<div class="field-unit__label">
  <label for="post_status">Status</label>
</div>
<div class="field-unit__field">
  <select name="post[status]" id="post_status"><option value="submitted">submitted</option>
<option value="approved">approved</option>
<option selected="selected" value="rejected">rejected</option></select>
</div>

    </div>

  <div class="form-actions">
    <input type="submit" name="commit" value="Update Post" />
  </div>
</form>

    </main>

  </div>

  
  <script src="/assets/jquery.self-bd7ddd393353a8d2480a622e80342adf488fb6006d667e8b42e4c0073393abee.js?body=1"></script>
<script src="/assets/jquery_ujs.self-784a997f6726036b1993eb2217c9cb558e1cbb801c6da88105588c56f13b466a.js?body=1"></script>
<script src="/assets/selectize.self-7e677d328c56b076ab303c3a5685e4f11fab78c896c7c6be7c7159180f774040.js?body=1"></script>
<script src="/assets/moment.self-34da66f0997d145341cfb3fc71c794ea32b4c6affa3ff5d9e7e5107170125d1c.js?body=1"></script>
<script src="/assets/datetime_picker.self-953135ed994cc31cc9cfec48a266ddfc2017dce124e3a2d0503f69d3c31ed8be.js?body=1"></script>
<script src="/assets/administrate/components/_search.self-7adb2f7a055eb9954a9015ca41f1028b1ffa44d0a8f5ddb9b7e193c599810f42.js?body=1"></script>
<script src="/assets/administrate/components/date_time_picker.self-f0348b2d219140450e53b856e6ddedf2b5869e71bad36b9a3c7f9ec77a4380aa.js?body=1"></script>
<script src="/assets/administrate/components/has_many_form.self-1f25789b95907cf69cffca6b436b523b4df0d94bdf8903ededdeced0ac7147d7.js?body=1"></script>
<script src="/assets/administrate/components/table.self-be567616202e2a6901a0fdcd096e5a26bee6f88b83444215df31486d22d7bd71.js?body=1"></script>
<script src="/assets/administrate/application.self-d088784b7ecb87f1ea17e6f982fa968ffefcc07b79de6ecc548fc00242868da6.js?body=1"></script>




</body>
</html>
# spec/features/approval_workflow_spec.rb

require 'rails_helper'

describe 'Navigate' do
  before do
    @admin_user = FactoryGirl.create(:admin_user)
    login_as(@admin_user, :scope => :user)
  end

  describe 'edit' do
    before do
      @post = FactoryGirl.create(:post)
    end

    it 'has a status that can be edited on the form' do
      visit edit_post_path(@post)

      select 'approved', from: '#post_status'
      # select 'approved', from: 'post_status'
      # select 'approved', from: 'post[status]'
      # select 'approved', from: 'select'
      # select 'approved', from: 'div.field-unit__select'
      # select 'approved', from: '.field-unit__select'
      # select 'approved', from: 'field-unit__select'
      # select 'approved', from: '.field-unit__field select'
      # select 'approved', from: 'field-unit__field select'
      # etc, etc
      
      click('Update Post')

      expect(@post.reload.status).to eq('approved')
    end
  end
end

以上是关于ruby approval_workflow_spec.rb的主要内容,如果未能解决你的问题,请参考以下文章

Ruby 25 岁了!Ruby 之父说 Ruby 3 有望 3 倍提速

如何学习ruby?Ruby学习技巧分享

ruby Ruby脚本,看看是否用openssl编译了ruby

什么是ruby?

ruby和ruby ee

ruby入门知识:了解ruby历史及特性