Write controller and feature specs for ActiveAdmin using RSpec?

送分小仙女□ 提交于 2019-12-02 21:16:09

I figured out how to construct a controller spec.

# spec/controllers/admin/organizations_controller_spec.rb
require 'spec_helper'
include Devise::TestHelpers

describe Admin::OrganizationsController do
  render_views

  before(:each) do
    @user = FactoryGirl.create(:admin_user)
   sign_in @user
  end

  it 'approve organization' do
    @organization = FactoryGirl.create(:organization, state: 'pending')
    post :batch_action, batch_action: 'approve', collection_selection_toggle_all: 'on', collection_selection: [@organization.id]
    @organization.reload
    @organization.pending?.should be_false
  end
end

If anyone knows how to write the feature spec, please share that info.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!