activeadmin 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of activeadmin might be problematic. Click here for more details.
- data/.document +5 -0
- data/.gitignore +25 -0
- data/Gemfile +16 -0
- data/LICENSE +20 -0
- data/README.rdoc +201 -0
- data/Rakefile +71 -0
- data/active_admin.gemspec +22 -0
- data/lib/active_admin.rb +229 -0
- data/lib/active_admin/action_builder.rb +60 -0
- data/lib/active_admin/action_items.rb +48 -0
- data/lib/active_admin/asset_registration.rb +34 -0
- data/lib/active_admin/breadcrumbs.rb +26 -0
- data/lib/active_admin/dashboards.rb +50 -0
- data/lib/active_admin/dashboards/dashboard_controller.rb +40 -0
- data/lib/active_admin/dashboards/renderer.rb +45 -0
- data/lib/active_admin/dashboards/section.rb +43 -0
- data/lib/active_admin/dashboards/section_renderer.rb +28 -0
- data/lib/active_admin/filters.rb +189 -0
- data/lib/active_admin/form_builder.rb +91 -0
- data/lib/active_admin/helpers/optional_display.rb +34 -0
- data/lib/active_admin/menu.rb +42 -0
- data/lib/active_admin/menu_item.rb +67 -0
- data/lib/active_admin/namespace.rb +111 -0
- data/lib/active_admin/page_config.rb +15 -0
- data/lib/active_admin/pages.rb +11 -0
- data/lib/active_admin/pages/base.rb +92 -0
- data/lib/active_admin/pages/edit.rb +21 -0
- data/lib/active_admin/pages/index.rb +58 -0
- data/lib/active_admin/pages/index/blog.rb +65 -0
- data/lib/active_admin/pages/index/table.rb +48 -0
- data/lib/active_admin/pages/index/thumbnails.rb +40 -0
- data/lib/active_admin/pages/new.rb +21 -0
- data/lib/active_admin/pages/show.rb +54 -0
- data/lib/active_admin/renderer.rb +72 -0
- data/lib/active_admin/resource.rb +96 -0
- data/lib/active_admin/resource_controller.rb +325 -0
- data/lib/active_admin/sidebar.rb +78 -0
- data/lib/active_admin/table_builder.rb +162 -0
- data/lib/active_admin/tabs_renderer.rb +39 -0
- data/lib/active_admin/version.rb +3 -0
- data/lib/active_admin/view_helpers.rb +106 -0
- data/lib/active_admin/views/active_admin_dashboard/index.html.erb +1 -0
- data/lib/active_admin/views/active_admin_default/edit.html.erb +1 -0
- data/lib/active_admin/views/active_admin_default/index.csv.erb +2 -0
- data/lib/active_admin/views/active_admin_default/index.html.erb +1 -0
- data/lib/active_admin/views/active_admin_default/new.html.erb +1 -0
- data/lib/active_admin/views/active_admin_default/show.html.erb +1 -0
- data/lib/active_admin/views/layouts/active_admin.html.erb +40 -0
- data/lib/activeadmin.rb +1 -0
- data/lib/generators/active_admin/install/install_generator.rb +31 -0
- data/lib/generators/active_admin/install/templates/active_admin.css +325 -0
- data/lib/generators/active_admin/install/templates/active_admin.js +10 -0
- data/lib/generators/active_admin/install/templates/active_admin.rb +47 -0
- data/lib/generators/active_admin/install/templates/active_admin_vendor.js +382 -0
- data/lib/generators/active_admin/install/templates/dashboards.rb +36 -0
- data/lib/generators/active_admin/install/templates/images/orderable.gif +0 -0
- data/lib/generators/active_admin/resource/resource_generator.rb +16 -0
- data/lib/generators/active_admin/resource/templates/admin.rb +3 -0
- data/spec/integration/dashboard_spec.rb +44 -0
- data/spec/integration/index_as_blog_spec.rb +65 -0
- data/spec/integration/index_as_csv_spec.rb +40 -0
- data/spec/integration/index_as_table_spec.rb +160 -0
- data/spec/integration/index_as_thumbnails_spec.rb +43 -0
- data/spec/integration/layout_spec.rb +82 -0
- data/spec/integration/new_view_spec.rb +52 -0
- data/spec/integration/show_view_spec.rb +91 -0
- data/spec/spec_helper.rb +104 -0
- data/spec/support/rails_template.rb +19 -0
- data/spec/unit/action_builder_spec.rb +76 -0
- data/spec/unit/action_items_spec.rb +41 -0
- data/spec/unit/active_admin_spec.rb +52 -0
- data/spec/unit/asset_registration_spec.rb +37 -0
- data/spec/unit/controller_filters_spec.rb +26 -0
- data/spec/unit/dashboard_section_spec.rb +63 -0
- data/spec/unit/dashboards_spec.rb +59 -0
- data/spec/unit/filter_form_builder_spec.rb +157 -0
- data/spec/unit/form_builder_spec.rb +238 -0
- data/spec/unit/menu_item_spec.rb +137 -0
- data/spec/unit/menu_spec.rb +53 -0
- data/spec/unit/namespace_spec.rb +107 -0
- data/spec/unit/registration_spec.rb +46 -0
- data/spec/unit/renderer_spec.rb +100 -0
- data/spec/unit/resource_controller_spec.rb +48 -0
- data/spec/unit/resource_spec.rb +197 -0
- data/spec/unit/routing_spec.rb +12 -0
- data/spec/unit/sidebar_spec.rb +96 -0
- data/spec/unit/table_builder_spec.rb +162 -0
- data/spec/unit/tabs_renderer_spec.rb +34 -0
- metadata +247 -0
@@ -0,0 +1,52 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
2
|
+
|
3
|
+
describe_with_render "New View" do
|
4
|
+
|
5
|
+
before :all do
|
6
|
+
load_defaults!
|
7
|
+
reload_routes!
|
8
|
+
end
|
9
|
+
|
10
|
+
before(:each) do
|
11
|
+
Admin::PostsController.reset_form_config!
|
12
|
+
end
|
13
|
+
|
14
|
+
describe "GET #new" do
|
15
|
+
|
16
|
+
it "should generate a default form with no config" do
|
17
|
+
get :new
|
18
|
+
response.should have_tag("input", :attributes => {
|
19
|
+
:type => "text",
|
20
|
+
:name => "post[title]"
|
21
|
+
})
|
22
|
+
response.should have_tag("textarea", :attributes => {
|
23
|
+
:name => "post[body]"
|
24
|
+
})
|
25
|
+
end
|
26
|
+
|
27
|
+
it "should generate a form with simple symbol configuration"
|
28
|
+
|
29
|
+
describe "when generating a complex form" do
|
30
|
+
before(:each) do
|
31
|
+
Admin::PostsController.form do |f|
|
32
|
+
f.inputs "Your Post" do
|
33
|
+
f.input :title
|
34
|
+
f.input :body
|
35
|
+
end
|
36
|
+
f.inputs "Publishing" do
|
37
|
+
f.input :published_at
|
38
|
+
end
|
39
|
+
f.buttons
|
40
|
+
end
|
41
|
+
get :new
|
42
|
+
end
|
43
|
+
it "should create a field set" do
|
44
|
+
response.should have_tag("legend", "Your Post")
|
45
|
+
end
|
46
|
+
it "should create a title field inside the fieldset" do
|
47
|
+
response.should have_tag("input", :attributes => { :type => "text", :name => 'post[title]' },
|
48
|
+
:ancestor => { :tag => "fieldset" })
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,91 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
2
|
+
|
3
|
+
describe_with_render "Show View" do
|
4
|
+
|
5
|
+
before :all do
|
6
|
+
load_defaults!
|
7
|
+
reload_routes!
|
8
|
+
end
|
9
|
+
|
10
|
+
describe "GET #show" do
|
11
|
+
before(:each) do
|
12
|
+
Admin::PostsController.reset_show_config!
|
13
|
+
end
|
14
|
+
|
15
|
+
describe "the page title" do
|
16
|
+
before do
|
17
|
+
@post = Post.create :title => "Hello World"
|
18
|
+
Admin::PostsController.show(:title => title)
|
19
|
+
get :show, :id => @post.id
|
20
|
+
end
|
21
|
+
|
22
|
+
context "with default" do
|
23
|
+
let(:title){ nil }
|
24
|
+
it "should render the type and id" do
|
25
|
+
response.should have_tag("h2", "Post ##{@post.id}")
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
context "with a symbol set" do
|
30
|
+
let(:title) { :title }
|
31
|
+
it "should call the method on the object and render the response" do
|
32
|
+
response.should have_tag("h2", @post.title)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
context "with a string set" do
|
37
|
+
let(:title) { "Hey Hey" }
|
38
|
+
it "should render the string" do
|
39
|
+
response.should have_tag("h2", "Hey Hey")
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
context "with a block set" do
|
44
|
+
let(:title) { proc{|r| r.title } }
|
45
|
+
it "should render the proc with the object as a param" do
|
46
|
+
response.should have_tag("h2", @post.title)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
51
|
+
|
52
|
+
describe "action items" do
|
53
|
+
before do
|
54
|
+
@post = Post.create(:title => "Hello World", :body => "Woot Woot")
|
55
|
+
get :show, :id => @post.id
|
56
|
+
end
|
57
|
+
it "should have a delete button" do
|
58
|
+
response.should have_tag("a", "Delete Post", :attributes => { 'data-method' => 'delete' })
|
59
|
+
end
|
60
|
+
it "should have an edit button" do
|
61
|
+
response.should have_tag("a", "Edit Post")
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
context "with default output" do
|
66
|
+
before do
|
67
|
+
@post = Post.create(:title => "Hello World", :body => "Woot Woot")
|
68
|
+
get :show, :id => @post.id
|
69
|
+
end
|
70
|
+
|
71
|
+
it "should render default view" do
|
72
|
+
response.should have_tag("th", "Title")
|
73
|
+
response.should have_tag('td', 'Hello World')
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
context "with custom output" do
|
78
|
+
before(:each) do
|
79
|
+
Admin::PostsController.show do
|
80
|
+
"Woot Bang"
|
81
|
+
end
|
82
|
+
@post = Post.create(:title => "Hello World", :body => "Woot Woot")
|
83
|
+
get :show, :id => @post.id
|
84
|
+
end
|
85
|
+
|
86
|
+
it "should render contents" do
|
87
|
+
response.body.should include("Woot Bang")
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,104 @@
|
|
1
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
2
|
+
ENV['BUNDLE_GEMFILE'] = File.expand_path('../../Gemfile', __FILE__)
|
3
|
+
|
4
|
+
require 'rubygems'
|
5
|
+
require "bundler"
|
6
|
+
Bundler.setup
|
7
|
+
|
8
|
+
# Setup autoloading of ActiveAdmin and the load path
|
9
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
10
|
+
autoload :ActiveAdmin, 'active_admin'
|
11
|
+
|
12
|
+
module ActiveAdminIntegrationSpecHelper
|
13
|
+
|
14
|
+
extend self
|
15
|
+
|
16
|
+
def load_defaults!
|
17
|
+
ActiveAdmin.register Post
|
18
|
+
ActiveAdmin.register Category
|
19
|
+
end
|
20
|
+
|
21
|
+
# Sometimes we need to reload the routes within
|
22
|
+
# the application to test them out
|
23
|
+
def reload_routes!
|
24
|
+
Rails.application.reload_routes!
|
25
|
+
end
|
26
|
+
|
27
|
+
# Sets up a describe block where you can render controller
|
28
|
+
# actions. Uses the Admin::PostsController as the subject
|
29
|
+
# for the describe block
|
30
|
+
def describe_with_render(*args, &block)
|
31
|
+
describe *args do
|
32
|
+
include RSpec::Rails::ControllerExampleGroup
|
33
|
+
render_views
|
34
|
+
metadata[:behaviour][:describes] = Admin::PostsController
|
35
|
+
module_eval &block
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
# Returns a fake action view instance to use with our renderers
|
40
|
+
def mock_action_view(assigns = {})
|
41
|
+
controller = ActionView::TestCase::TestController.new
|
42
|
+
ActionView::Base.send :include, ActionView::Helpers
|
43
|
+
ActionView::Base.send :include, ActiveAdmin::ViewHelpers
|
44
|
+
ActionView::Base.new(ActionController::Base.view_paths, assigns, controller)
|
45
|
+
end
|
46
|
+
alias_method :action_view, :mock_action_view
|
47
|
+
|
48
|
+
end
|
49
|
+
|
50
|
+
ENV['RAILS'] ||= '3.0.0'
|
51
|
+
ENV['RAILS_ENV'] = 'test'
|
52
|
+
|
53
|
+
if ENV['RAILS'] == '3.0.0'
|
54
|
+
ENV['RAILS_ROOT'] = File.expand_path('../rails/rails-3.0.0', __FILE__)
|
55
|
+
|
56
|
+
# Create the test app if it doesn't exists
|
57
|
+
unless File.exists?(ENV['RAILS_ROOT'])
|
58
|
+
system 'rake setup'
|
59
|
+
end
|
60
|
+
|
61
|
+
require ENV['RAILS_ROOT'] + '/config/environment'
|
62
|
+
require 'rspec/rails'
|
63
|
+
|
64
|
+
# Setup Some Admin stuff for us to play with
|
65
|
+
include ActiveAdminIntegrationSpecHelper
|
66
|
+
load_defaults!
|
67
|
+
reload_routes!
|
68
|
+
|
69
|
+
# Don't add asset cache timestamps. Makes it easy to integration
|
70
|
+
# test for the presence of an asset file
|
71
|
+
ENV["RAILS_ASSET_ID"] = ''
|
72
|
+
|
73
|
+
Rspec.configure do |config|
|
74
|
+
config.use_transactional_fixtures = true
|
75
|
+
config.use_instantiated_fixtures = false
|
76
|
+
end
|
77
|
+
|
78
|
+
|
79
|
+
Rspec::Matchers.define :have_tag do |*args|
|
80
|
+
|
81
|
+
match_unless_raises Test::Unit::AssertionFailedError do |response|
|
82
|
+
tag = args.shift
|
83
|
+
content = args.first.is_a?(Hash) ? nil : args.shift
|
84
|
+
|
85
|
+
options = {
|
86
|
+
:tag => tag
|
87
|
+
}.merge(args[0] || {})
|
88
|
+
|
89
|
+
options[:content] = content if content
|
90
|
+
|
91
|
+
begin
|
92
|
+
assert_tag(options)
|
93
|
+
rescue NoMethodError
|
94
|
+
# We are not in a controller, so let's do the checking ourselves
|
95
|
+
doc = HTML::Document.new(response, false, false)
|
96
|
+
tag = doc.find(options)
|
97
|
+
assert tag, "expected tag, but no tag found matching #{options.inspect} in:\n#{response.inspect}"
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
end
|
103
|
+
|
104
|
+
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# Rails template to build the sample app for specs
|
2
|
+
generate :model, "post title:string body:text published_at:datetime author_id:integer"
|
3
|
+
inject_into_file 'app/models/post.rb', " belongs_to :author, :class_name => 'User'\n accepts_nested_attributes_for :author\n", :after => "class Post < ActiveRecord::Base\n"
|
4
|
+
generate :model, "user first_name:string last_name:string username:string"
|
5
|
+
inject_into_file 'app/models/user.rb', " has_many :posts, :foreign_key => 'author_id'\n", :after => "class User < ActiveRecord::Base\n"
|
6
|
+
generate :model, 'category name:string'
|
7
|
+
|
8
|
+
run "rm Gemfile"
|
9
|
+
run "rm -r test"
|
10
|
+
run "rm -r spec"
|
11
|
+
|
12
|
+
rake "db:migrate"
|
13
|
+
rake "db:test:prepare"
|
14
|
+
|
15
|
+
# Install ActiveAdmin
|
16
|
+
# This should happen last so that we don't have to worry about the
|
17
|
+
# rake's blowing up due to not having active admin in their load paths
|
18
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
19
|
+
generate :'active_admin:install'
|
@@ -0,0 +1,76 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
2
|
+
|
3
|
+
describe ActiveAdmin::ActionBuilder do
|
4
|
+
|
5
|
+
let(:controller){ Admin::PostsController }
|
6
|
+
|
7
|
+
describe "generating a new member action" do
|
8
|
+
before do
|
9
|
+
action!
|
10
|
+
reload_routes!
|
11
|
+
end
|
12
|
+
|
13
|
+
after(:each) do
|
14
|
+
controller.clear_member_actions!
|
15
|
+
end
|
16
|
+
|
17
|
+
context "with a block" do
|
18
|
+
let(:action!) do
|
19
|
+
controller.member_action :comment do
|
20
|
+
# Do nothing
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
it "should create a new public instance method" do
|
25
|
+
controller.public_instance_methods.should include("comment")
|
26
|
+
end
|
27
|
+
it "should add itself to the member actions config" do
|
28
|
+
controller.active_admin_config.member_actions.size.should == 1
|
29
|
+
end
|
30
|
+
it "should create a new named route" do
|
31
|
+
Rails.application.routes.url_helpers.methods.should include("comment_admin_post_path")
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
context "without a block" do
|
36
|
+
let(:action!){ controller.member_action :comment }
|
37
|
+
it "should still generate a new empty action" do
|
38
|
+
controller.public_instance_methods.should include("comment")
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
describe "generate a new collection action" do
|
44
|
+
before do
|
45
|
+
action!
|
46
|
+
reload_routes!
|
47
|
+
end
|
48
|
+
after(:each) do
|
49
|
+
controller.clear_collection_actions!
|
50
|
+
end
|
51
|
+
|
52
|
+
context "with a block" do
|
53
|
+
let(:action!) do
|
54
|
+
controller.collection_action :comments do
|
55
|
+
# Do nothing
|
56
|
+
end
|
57
|
+
end
|
58
|
+
it "should create a new public instance method" do
|
59
|
+
controller.public_instance_methods.should include("comments")
|
60
|
+
end
|
61
|
+
it "should add itself to the member actions config" do
|
62
|
+
controller.active_admin_config.collection_actions.size.should == 1
|
63
|
+
end
|
64
|
+
it "should create a new named route" do
|
65
|
+
Rails.application.routes.url_helpers.methods.should include("comments_admin_posts_path")
|
66
|
+
end
|
67
|
+
end
|
68
|
+
context "without a block" do
|
69
|
+
let(:action!){ controller.collection_action :comments }
|
70
|
+
it "should still generate a new empty action" do
|
71
|
+
controller.public_instance_methods.should include("comments")
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
2
|
+
|
3
|
+
describe_with_render ActiveAdmin::ActionItems do
|
4
|
+
|
5
|
+
# Store the config and set it back after each spec so that we
|
6
|
+
# dont mess with other specs
|
7
|
+
before do
|
8
|
+
@config_before = Admin::PostsController.action_items
|
9
|
+
Admin::PostsController.clear_action_items!
|
10
|
+
end
|
11
|
+
|
12
|
+
after(:each) do
|
13
|
+
Admin::PostsController.action_items = @config_before
|
14
|
+
end
|
15
|
+
|
16
|
+
# Helpers method to define an action item
|
17
|
+
def action_item(*args, &block)
|
18
|
+
Admin::PostsController.class_eval do
|
19
|
+
action_item *args, &block
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
context "when setting with a block" do
|
24
|
+
before do
|
25
|
+
action_item do
|
26
|
+
link_to "All Posts", collection_path
|
27
|
+
end
|
28
|
+
get :index
|
29
|
+
end
|
30
|
+
it "should add a new action item" do
|
31
|
+
Admin::PostsController.action_items.size.should == 1
|
32
|
+
end
|
33
|
+
it "should render the content in the context of the view" do
|
34
|
+
response.should have_tag('a', 'All Posts')
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
# action_item 'New', new_post_path
|
39
|
+
context "when setting with as a link with text and a path"
|
40
|
+
|
41
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
2
|
+
|
3
|
+
describe ActiveAdmin do
|
4
|
+
|
5
|
+
it "should have a default load path of ['app/admin']" do
|
6
|
+
ActiveAdmin.load_paths.should == [File.expand_path('app/admin', Rails.root)]
|
7
|
+
end
|
8
|
+
|
9
|
+
it "should remove app/admin from the autoload path to remove the possibility of conflicts" do
|
10
|
+
ActiveSupport::Dependencies.autoload_paths.should_not include(File.join(Rails.root, "app/admin"))
|
11
|
+
end
|
12
|
+
|
13
|
+
it "should remove app/admin from the eager load paths (Active Admin deals with loading)" do
|
14
|
+
Rails.application.config.eager_load_paths.should_not include(File.join(Rails.root, "app/admin"))
|
15
|
+
end
|
16
|
+
|
17
|
+
# TODO: Find a good way to test loading and unloading constants
|
18
|
+
# without blowing up all the other specs
|
19
|
+
#
|
20
|
+
#describe "loading" do
|
21
|
+
# it "should unload all registered controllers" do
|
22
|
+
# TestClass = Class.new(ActiveRecord::Base)
|
23
|
+
# ActiveAdmin.register(TestClass)
|
24
|
+
# Admin::TestClassesController
|
25
|
+
# ActiveAdmin.unload!
|
26
|
+
# lambda {
|
27
|
+
# Admin::TestClassesController
|
28
|
+
# }.should raise_error
|
29
|
+
# ActiveAdminIntegrationSpecHelper.load!
|
30
|
+
# end
|
31
|
+
#end
|
32
|
+
|
33
|
+
it "should default the application name" do
|
34
|
+
ActiveAdmin.site_title.should == "Rails300"
|
35
|
+
end
|
36
|
+
|
37
|
+
it "should set the site title" do
|
38
|
+
old_title = ActiveAdmin.site_title.dup
|
39
|
+
ActiveAdmin.site_title = "New Title"
|
40
|
+
ActiveAdmin.site_title.should == "New Title"
|
41
|
+
ActiveAdmin.site_title = old_title
|
42
|
+
end
|
43
|
+
|
44
|
+
it "should have a set of menus" do
|
45
|
+
ActiveAdmin.menus.should be_an_instance_of(Hash)
|
46
|
+
end
|
47
|
+
|
48
|
+
it "should have a default tab renderer" do
|
49
|
+
ActiveAdmin.tabs_renderer.should == ActiveAdmin::TabsRenderer
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
2
|
+
|
3
|
+
module MockRegistration
|
4
|
+
extend ActiveAdmin::AssetRegistration
|
5
|
+
end
|
6
|
+
|
7
|
+
describe ActiveAdmin::AssetRegistration do
|
8
|
+
|
9
|
+
before do
|
10
|
+
MockRegistration.clear_stylesheets!
|
11
|
+
MockRegistration.clear_javascripts!
|
12
|
+
end
|
13
|
+
|
14
|
+
it "should register a stylesheet file" do
|
15
|
+
MockRegistration.register_stylesheet "active_admin.css"
|
16
|
+
MockRegistration.stylesheets.should == ["active_admin.css"]
|
17
|
+
end
|
18
|
+
|
19
|
+
it "should clear all existing stylesheets" do
|
20
|
+
MockRegistration.register_stylesheet "active_admin.css"
|
21
|
+
MockRegistration.stylesheets.should == ["active_admin.css"]
|
22
|
+
MockRegistration.clear_stylesheets!
|
23
|
+
MockRegistration.stylesheets.should == []
|
24
|
+
end
|
25
|
+
|
26
|
+
it "should register a javascript file" do
|
27
|
+
MockRegistration.register_javascript "active_admin.js"
|
28
|
+
MockRegistration.javascripts.should == ["active_admin.js"]
|
29
|
+
end
|
30
|
+
|
31
|
+
it "should clear all existing javascripts" do
|
32
|
+
MockRegistration.register_javascript "active_admin.js"
|
33
|
+
MockRegistration.javascripts.should == ["active_admin.js"]
|
34
|
+
MockRegistration.clear_javascripts!
|
35
|
+
MockRegistration.javascripts.should == []
|
36
|
+
end
|
37
|
+
end
|