7
Come si fa a scrivere la spec controller e funzionalità per il seguente codice ActiveAdmin:Controller di scrittura e specifiche delle funzionalità per ActiveAdmin usando RSpec?
# app/admin/organization.rb
ActiveAdmin.register Organization do
batch_action :approve do |selection|
Organization.find(selection).each {|organization| organization.approve }
redirect_to collection_path, notice: 'Organizations approved.'
end
end
Qui è la mia caratteristica spec. Non riesce a trovare "Azioni batch" che ActiveAdmin carica nel menu a comparsa.
# spec/features/admin/organization_feature_spec.rb
require 'spec_helper'
include Devise::TestHelpers
describe 'Admin Organization' do
before(:each) do
@user = FactoryGirl.create(:admin_user)
login('[email protected]', 'password1')
end
it 'approves in batch' do
organization = FactoryGirl.create(:organization)
visit admin_organizations_path
check 'collection_selection_toggle_all'
click_link 'Batch Actions'
click_link 'Approve Selected'
organization.reload
organization.state.should eq 'approved'
end
end
Versioni
- Rails 3.2.14
- ActiveAdmin 0.6.0