I am developing a Rails 4.1 application that sits alongside Alchemy CMS. I do not want the admin portion to use Alchemy's admin interface. (I am building my own with ZURB Foundation.)
Trouble starts brewing when I want to run my own specs in RSpec. While the application runs fine in development mode, I get this error in my tests:
Failure/Error: visit new_staff_program_path
Alchemy::DefaultLanguageNotFoundError:
No default language found. Have you run the rake alchemy:db:seed task?
It appears that the controller is running some filters that expect data to be in place. Is there a way that I can "opt out" of this for certain parts of my application?
For now, this is my solution...
I have a base controller that the separate admin is extending. Within that, I instruct it to skip before_action
calls that the Alchemy engine adds to the controller layer:
class Staff::Base < ApplicationController
# Filters
skip_before_action :set_current_alchemy_site, :set_alchemy_language
# Layout
layout 'admin'
end
If anyone has any better solutions, let me know.
Yes, it is indeed very simple ;)
In your spec_helper
you can add a Rspec.config
block that will seed the base data of Alchemy everytime you run your test suite:
# spec/spec_helper.rb
require 'alchemy/seeder'
RSpec.configure do |config|
config.before type: :feature do
Alchemy::Seeder.seed!
end
end