I'm trying to test a custom member action in ActiveAdmin using rspec.
app/admin/inactive_user.rb
ActiveAdmin.register InactiveUser do
member_action :activate, method: :put do
user = User.new(email: resource.email, password: generate_activation_code)
resource.destroy if user.save
send_activation_email user
redirect_to admin_inactive_users_path, notice: "#{user.email} was activated"
end
end
app/spec/admin/inactive_user_controller_spec.rb
require 'spec_helper'
describe Admin::InactiveUserController do
render_views
before do
@admin = FactoryGirl.create(:admin, confirmed_at: Date.yesterday)
authenticate_user @admin
end
describe "PUT #activate" do
before(:each) do
@inactive_user = FactoryGirl.create(:inactive_user)
put :activate, id: @inactive_user.id
end
it "should redirect to inactive users index" do
expect(response).to redirect_to(admin_inactive_users_path)
end
end
end
I'm getting this error:
NameError:
uninitialized constant Admin
# ./spec/admin/inactive_user_controller_spec.rb:3:in `<top (required)>'
I have tried this without any luck.
Plus, if you know of any project that uses rspec to do tests on this kind of things it would be great, the doc doesn't say much.
Update:
Right now it's running the active_admin
initializer after the test:
An error occurred while loading
NameError:
uninitialized constant Admin
# ./spec/admin/inactive_user_controller_spec.rb:3:in `<top (required)>'
[3, 12] in /Users/lucia/Documents/frogs-api-remote/config/initializers/active_admin.rb
3: # == Site Title
4: #
5: # Set the title that is displayed on the main layout
6: # for each of the active admin pages.
7: #
=> 8: config.site_title = "Frogs App"
9:
10: # Set the link url for the title. For example, to take
11: # users to your main site. Defaults to no link.
12: #