activeadmin 0.2.1 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of activeadmin might be problematic. Click here for more details.
- data/CHANGELOG.rdoc +60 -11
- data/Gemfile +7 -3
- data/README.rdoc +118 -8
- data/Rakefile +5 -1
- data/activeadmin.gemspec +20 -13
- data/cucumber.yml +1 -0
- data/features/comments/commenting.feature +5 -1
- data/features/dashboard.feature +26 -0
- data/features/menu.feature +26 -0
- data/features/step_definitions/dashboard_steps.rb +11 -0
- data/features/step_definitions/menu_steps.rb +7 -0
- data/features/sti_resource.feature +49 -0
- data/lib/active_admin.rb +20 -13
- data/lib/active_admin/arbre/tag.rb +10 -2
- data/lib/active_admin/comments.rb +15 -0
- data/lib/active_admin/form_builder.rb +1 -1
- data/lib/active_admin/resource.rb +9 -4
- data/lib/active_admin/resource_controller.rb +4 -4
- data/lib/active_admin/resource_controller/collection.rb +3 -2
- data/lib/active_admin/stylesheets/active_admin.scss +9 -2
- data/lib/active_admin/stylesheets/active_admin/_forms.scss +2 -2
- data/lib/active_admin/version.rb +1 -1
- data/lib/active_admin/view_helpers/filter_form_helper.rb +1 -1
- data/lib/active_admin/views/components/table_for.rb +1 -1
- data/lib/active_admin/views/index_as_table.rb +3 -3
- data/lib/active_admin/views/pages/base.rb +8 -1
- data/lib/active_admin/views/pages/dashboard.rb +0 -2
- data/lib/active_admin/views/pages/index.rb +3 -1
- data/lib/active_admin/views/templates/active_admin/devise/sessions/new.html.erb +1 -1
- data/lib/active_admin/views/templates/layouts/active_admin_logged_out.html.erb +1 -1
- data/lib/generators/active_admin/devise/devise_generator.rb +7 -3
- data/lib/generators/active_admin/install/templates/active_admin.rb.erb +7 -6
- data/lib/generators/active_admin/install/templates/dashboards.rb +4 -3
- data/spec/{integration → controllers}/index_as_csv_spec.rb +8 -13
- data/spec/integration/belongs_to_spec.rb +1 -1
- data/spec/spec_helper.rb +10 -4
- data/spec/support/integration_example_group.rb +0 -4
- data/spec/support/rails_template.rb +2 -1
- data/spec/unit/action_builder_spec.rb +1 -1
- data/spec/unit/action_items_spec.rb +1 -1
- data/spec/unit/active_admin_spec.rb +19 -6
- data/spec/unit/arbre/html_spec.rb +26 -1
- data/spec/unit/asset_registration_spec.rb +1 -1
- data/spec/unit/belongs_to_spec.rb +1 -1
- data/spec/unit/breadcrumbs_spec.rb +1 -1
- data/spec/unit/comments_spec.rb +1 -1
- data/spec/unit/controller_filters_spec.rb +1 -1
- data/spec/unit/dashboard_controller_spec.rb +1 -1
- data/spec/unit/dashboard_section_spec.rb +1 -1
- data/spec/unit/dashboards_spec.rb +1 -1
- data/spec/unit/filter_form_builder_spec.rb +1 -1
- data/spec/unit/form_builder_spec.rb +1 -1
- data/spec/unit/menu_item_spec.rb +1 -1
- data/spec/unit/menu_spec.rb +1 -1
- data/spec/unit/namespace_spec.rb +1 -1
- data/spec/unit/registration_spec.rb +1 -1
- data/spec/unit/renderer_spec.rb +1 -1
- data/spec/unit/resource_controller/collection_spec.rb +34 -0
- data/spec/unit/resource_controller_spec.rb +1 -1
- data/spec/unit/resource_spec.rb +23 -2
- data/spec/unit/routing_spec.rb +1 -1
- data/spec/unit/tabs_renderer_spec.rb +1 -1
- metadata +36 -13
- data/spec/integration/dashboard_spec.rb +0 -44
- data/spec/integration/index_as_table_spec.rb +0 -41
- data/spec/integration/layout_spec.rb +0 -48
@@ -20,7 +20,9 @@ module ActiveAdmin
|
|
20
20
|
renderer_class = find_index_renderer_class(config[:as])
|
21
21
|
|
22
22
|
paginated_collection(collection, :entry_name => active_admin_config.resource_name) do
|
23
|
-
|
23
|
+
div :class => 'index_content' do
|
24
|
+
insert_tag(renderer_class, config, collection)
|
25
|
+
end
|
24
26
|
end
|
25
27
|
end
|
26
28
|
|
@@ -4,7 +4,7 @@
|
|
4
4
|
<% scope = Devise::Mapping.find_scope!(resource_name) %>
|
5
5
|
<%= active_admin_form_for(resource, :as => resource_name, :url => send(:"#{scope}_session_path"), :html => { :id => "session_new" }) do |f|
|
6
6
|
f.inputs do
|
7
|
-
f.input
|
7
|
+
Devise.authentication_keys.each { |key| f.input key }
|
8
8
|
f.input :password
|
9
9
|
f.input :remember_me, :as => :boolean, :if => false #devise_mapping.rememberable? }
|
10
10
|
end
|
@@ -35,9 +35,13 @@ module ActiveAdmin
|
|
35
35
|
end
|
36
36
|
|
37
37
|
def add_default_user_to_migration
|
38
|
-
|
39
|
-
|
40
|
-
|
38
|
+
# Don't assume that we have a migration!
|
39
|
+
devise_migrations = Dir["db/migrate/*_devise_create_#{table_name}.rb"]
|
40
|
+
if devise_migrations.size > 0
|
41
|
+
inject_into_file Dir["db/migrate/*_devise_create_#{table_name}.rb"].first,
|
42
|
+
"# Create a default user\n #{class_name}.create!(:email => 'admin@example.com', :password => 'password', :password_confirmation => 'password')\n\n ",
|
43
|
+
:before => "add_index :#{table_name}, :email"
|
44
|
+
end
|
41
45
|
end
|
42
46
|
|
43
47
|
end
|
@@ -43,16 +43,17 @@ ActiveAdmin.setup do |config|
|
|
43
43
|
# This setting changes the method which Active Admin calls
|
44
44
|
# to return the currently logged in user.
|
45
45
|
config.current_user_method = :current_admin_user
|
46
|
-
|
47
46
|
|
48
|
-
|
49
|
-
#
|
47
|
+
|
48
|
+
# == Admin Comments
|
49
|
+
#
|
50
50
|
# Admin notes allow you to add notes to any model
|
51
51
|
#
|
52
|
-
# Admin notes are enabled by default
|
53
|
-
#
|
52
|
+
# Admin notes are enabled by default in the default
|
53
|
+
# namespace only. You can turn them on in a namesapce
|
54
|
+
# by adding them to the comments array.
|
54
55
|
#
|
55
|
-
config.
|
56
|
+
# config.allow_comments_in = [:admin]
|
56
57
|
|
57
58
|
|
58
59
|
# == Controller Filters
|
@@ -8,9 +8,10 @@ ActiveAdmin::Dashboards.build do
|
|
8
8
|
# Here is an example of a simple dashboard section
|
9
9
|
#
|
10
10
|
# section "Recent Posts" do
|
11
|
-
#
|
12
|
-
#
|
13
|
-
#
|
11
|
+
# ul do
|
12
|
+
# Post.recent(5).collect do |post|
|
13
|
+
# li link_to(post.title, admin_post_path(post))
|
14
|
+
# end
|
14
15
|
# end
|
15
16
|
# end
|
16
17
|
|
@@ -1,40 +1,35 @@
|
|
1
|
-
require
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
|
-
describe_with_render
|
4
|
-
|
5
|
-
before :all do
|
6
|
-
load_defaults!
|
7
|
-
reload_routes!
|
8
|
-
end
|
9
|
-
|
10
|
-
before(:each) do
|
11
|
-
Admin::PostsController.reset_index_config!
|
12
|
-
end
|
13
|
-
|
3
|
+
describe_with_render Admin::PostsController do
|
14
4
|
describe "get index with format csv" do
|
5
|
+
|
15
6
|
before do
|
16
7
|
Post.create :title => "Hello World"
|
17
8
|
Post.create :title => "Goodbye World"
|
18
9
|
end
|
10
|
+
|
19
11
|
it "should return csv" do
|
20
12
|
get :index, 'format' => 'csv'
|
21
13
|
response.content_type.should == 'text/csv'
|
22
14
|
end
|
15
|
+
|
23
16
|
it "should return a header and a line for each item" do
|
24
17
|
get :index, 'format' => 'csv'
|
25
18
|
response.body.split("\n").size.should == 3
|
26
19
|
end
|
20
|
+
|
27
21
|
Post.columns.each do |column|
|
28
22
|
it "should include a header for #{column.name}" do
|
29
23
|
get :index, 'format' => 'csv'
|
30
24
|
response.body.split("\n").first.should include(column.name.titleize)
|
31
25
|
end
|
32
26
|
end
|
27
|
+
|
33
28
|
it "should set a much higher per page pagination" do
|
34
29
|
100.times{ Post.create :title => "woot" }
|
35
30
|
get :index, 'format' => 'csv'
|
36
31
|
response.body.split("\n").size.should == 103
|
37
32
|
end
|
38
|
-
end
|
39
33
|
|
34
|
+
end
|
40
35
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -59,7 +59,7 @@ module ActiveAdminIntegrationSpecHelper
|
|
59
59
|
describe *args do
|
60
60
|
include RSpec::Rails::ControllerExampleGroup
|
61
61
|
render_views
|
62
|
-
metadata[:behaviour][:describes] = ActiveAdmin.namespaces[:admin].resources['Post'].controller
|
62
|
+
# metadata[:behaviour][:describes] = ActiveAdmin.namespaces[:admin].resources['Post'].controller
|
63
63
|
module_eval &block
|
64
64
|
end
|
65
65
|
end
|
@@ -67,7 +67,6 @@ module ActiveAdminIntegrationSpecHelper
|
|
67
67
|
# Setup a describe block which uses capybara and rails integration
|
68
68
|
# test methods.
|
69
69
|
def describe_with_capybara(*args, &block)
|
70
|
-
require 'integration_example_group'
|
71
70
|
describe *args do
|
72
71
|
include RSpec::Rails::IntegrationExampleGroup
|
73
72
|
module_eval &block
|
@@ -113,15 +112,22 @@ ActiveAdmin.current_user_method = false
|
|
113
112
|
# test for the presence of an asset file
|
114
113
|
ENV["RAILS_ASSET_ID"] = ''
|
115
114
|
|
116
|
-
|
115
|
+
RSpec.configure do |config|
|
117
116
|
config.use_transactional_fixtures = true
|
118
117
|
config.use_instantiated_fixtures = false
|
119
118
|
end
|
120
119
|
|
120
|
+
# All RSpec configuration needs to happen before any examples
|
121
|
+
# or else it whines.
|
122
|
+
require 'integration_example_group'
|
123
|
+
RSpec.configure do |c|
|
124
|
+
c.include RSpec::Rails::IntegrationExampleGroup, :example_group => { :file_path => /\bspec\/integration\// }
|
125
|
+
end
|
126
|
+
|
121
127
|
# Ensure this is defined for Ruby 1.8
|
122
128
|
module MiniTest; class Assertion < Exception; end; end
|
123
129
|
|
124
|
-
|
130
|
+
RSpec::Matchers.define :have_tag do |*args|
|
125
131
|
|
126
132
|
match_unless_raises Test::Unit::AssertionFailedError do |response|
|
127
133
|
tag = args.shift
|
@@ -8,8 +8,9 @@ gsub_file 'config/database.yml', /\z/, "\ncucumber:\n <<: *test\n database: db
|
|
8
8
|
# Generate some test models
|
9
9
|
generate :model, "post title:string body:text published_at:datetime author_id:integer category_id:integer"
|
10
10
|
inject_into_file 'app/models/post.rb', " belongs_to :author, :class_name => 'User'\n belongs_to :category\n accepts_nested_attributes_for :author\n", :after => "class Post < ActiveRecord::Base\n"
|
11
|
-
generate :model, "user first_name:string last_name:string username:string"
|
11
|
+
generate :model, "user type:string first_name:string last_name:string username:string"
|
12
12
|
inject_into_file 'app/models/user.rb', " has_many :posts, :foreign_key => 'author_id'\n", :after => "class User < ActiveRecord::Base\n"
|
13
|
+
generate :model, "publisher --migration=false --parent=User"
|
13
14
|
generate :model, 'category name:string description:text'
|
14
15
|
inject_into_file 'app/models/category.rb', " has_many :posts\n", :after => "class Category < ActiveRecord::Base\n"
|
15
16
|
|
@@ -1,4 +1,5 @@
|
|
1
|
-
require
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'fileutils'
|
2
3
|
|
3
4
|
describe ActiveAdmin do
|
4
5
|
|
@@ -13,11 +14,11 @@ describe ActiveAdmin do
|
|
13
14
|
it "should remove app/admin from the eager load paths (Active Admin deals with loading)" do
|
14
15
|
Rails.application.config.eager_load_paths.should_not include(File.join(Rails.root, "app/admin"))
|
15
16
|
end
|
16
|
-
|
17
|
+
|
17
18
|
it "should default the application name" do
|
18
19
|
ActiveAdmin.site_title.should == Rails.application.class.to_s.split('::').first
|
19
20
|
end
|
20
|
-
|
21
|
+
|
21
22
|
it "should set the site title" do
|
22
23
|
old_title = ActiveAdmin.site_title.dup
|
23
24
|
ActiveAdmin.site_title = "New Title"
|
@@ -28,13 +29,25 @@ describe ActiveAdmin do
|
|
28
29
|
it "should have a view factory" do
|
29
30
|
ActiveAdmin.view_factory.should be_an_instance_of(ActiveAdmin::ViewFactory)
|
30
31
|
end
|
31
|
-
|
32
|
+
|
32
33
|
it "should have admin notes by default" do
|
33
34
|
ActiveAdmin.admin_notes.should be_true
|
34
35
|
end
|
35
|
-
|
36
|
+
|
36
37
|
it "should have a default current_user_method" do
|
37
38
|
ActiveAdmin.current_user_method.should == false
|
38
39
|
end
|
39
|
-
|
40
|
+
|
41
|
+
describe "files in load path" do
|
42
|
+
it "should load files in the first level directory" do
|
43
|
+
ActiveAdmin.files_in_load_path.should include(File.expand_path("app/admin/dashboards.rb", Rails.root))
|
44
|
+
end
|
45
|
+
it "should load files from subdirectories" do
|
46
|
+
FileUtils.mkdir_p(File.expand_path("app/admin/public", Rails.root))
|
47
|
+
test_file = File.expand_path("app/admin/public/posts.rb", Rails.root)
|
48
|
+
FileUtils.touch(test_file)
|
49
|
+
ActiveAdmin.files_in_load_path.should include(test_file)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
40
53
|
end
|
@@ -148,6 +148,27 @@ HTML
|
|
148
148
|
end
|
149
149
|
end
|
150
150
|
|
151
|
+
describe "self-closing nodes" do
|
152
|
+
it "should not self-close script tags" do
|
153
|
+
tag = script :type => 'text/javascript'
|
154
|
+
tag.to_html.should == <<-HTML
|
155
|
+
<script type="text/javascript"></script>
|
156
|
+
HTML
|
157
|
+
end
|
158
|
+
it "should self-close meta tags" do
|
159
|
+
tag = meta :content => "text/html; charset=utf-8"
|
160
|
+
tag.to_html.should == <<-HTML
|
161
|
+
<meta content="text/html; charset=utf-8\"/>
|
162
|
+
HTML
|
163
|
+
end
|
164
|
+
it "should self-close link tags" do
|
165
|
+
tag = link :rel => "stylesheet"
|
166
|
+
tag.to_html.should == <<-HTML
|
167
|
+
<link rel="stylesheet"/>
|
168
|
+
HTML
|
169
|
+
end
|
170
|
+
end
|
171
|
+
|
151
172
|
describe "html safe" do
|
152
173
|
it "should escape the contents" do
|
153
174
|
span("<br />").to_html.should == <<-HTML
|
@@ -179,7 +200,11 @@ HTML
|
|
179
200
|
HTML
|
180
201
|
end
|
181
202
|
|
182
|
-
it "should escape the contents of attributes"
|
203
|
+
it "should escape the contents of attributes" do
|
204
|
+
span(:class => "<br />").to_html.should == <<-HTML
|
205
|
+
<span class="<br />"></span>
|
206
|
+
HTML
|
207
|
+
end
|
183
208
|
end
|
184
209
|
|
185
210
|
end
|
data/spec/unit/comments_spec.rb
CHANGED
data/spec/unit/menu_item_spec.rb
CHANGED
data/spec/unit/menu_spec.rb
CHANGED
data/spec/unit/namespace_spec.rb
CHANGED
data/spec/unit/renderer_spec.rb
CHANGED
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe ActiveAdmin::ResourceController::Collection do
|
4
|
+
let(:params) do
|
5
|
+
{}
|
6
|
+
end
|
7
|
+
|
8
|
+
let(:controller) do
|
9
|
+
rc = Admin::PostsController.new
|
10
|
+
rc.stub!(:params) do
|
11
|
+
params
|
12
|
+
end
|
13
|
+
rc
|
14
|
+
end
|
15
|
+
|
16
|
+
describe ActiveAdmin::ResourceController::Collection::Search do
|
17
|
+
let(:params){ {:q => {} }}
|
18
|
+
it "should call the metasearch method" do
|
19
|
+
chain = mock("ChainObj")
|
20
|
+
chain.should_receive(:metasearch).with(params[:q]).once.and_return(Post.search)
|
21
|
+
controller.send :search, chain
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
describe ActiveAdmin::ResourceController::Collection::Sorting do
|
26
|
+
let(:params){ {:order => "id_asc" }}
|
27
|
+
it "should prepend the table name" do
|
28
|
+
chain = mock("ChainObj")
|
29
|
+
chain.should_receive(:order).with("posts.id asc").once.and_return(Post.search)
|
30
|
+
controller.send :sort_order, chain
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|