administer 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- data/app/controllers/administer/models_controller.rb +7 -2
- data/app/helpers/administer/dashboard_helper.rb +1 -1
- data/app/views/administer/dashboard/index.html.haml +1 -1
- data/app/views/administer/models/index.html.haml +14 -0
- data/spec/rails_root/app/models/category.rb +2 -0
- data/spec/rails_root/db/migrate/20101206203354_create_categories.rb +12 -0
- data/spec/rails_root/spec/controllers/administer/models_controller_spec.rb +7 -1
- metadata +37 -9
@@ -1,11 +1,16 @@
|
|
1
1
|
module Administer
|
2
|
-
class ModelsController < ApplicationController
|
2
|
+
class Administer::ModelsController < ApplicationController
|
3
3
|
unloadable
|
4
4
|
before_filter :collection, :only => :index
|
5
5
|
|
6
6
|
protected
|
7
|
+
def model_class
|
8
|
+
Administer::Model.lookup(params[:model_name])
|
9
|
+
end
|
10
|
+
helper_method :model_class
|
11
|
+
|
7
12
|
def collection
|
8
|
-
@collection =
|
13
|
+
@collection = model_class.all
|
9
14
|
end
|
10
15
|
end
|
11
16
|
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
%ul.actions
|
2
|
+
%li= link_to('back', administer_dashboard_index_path)
|
3
|
+
%h1= model_class.model_name.human.pluralize
|
4
|
+
%table.items_list
|
5
|
+
%thead
|
6
|
+
%tr
|
7
|
+
- model_class.column_names.each do |column_name|
|
8
|
+
%th= column_name
|
9
|
+
|
10
|
+
%tbody
|
11
|
+
- @collection.each do |object|
|
12
|
+
%tr{:class => cycle('odd', 'even')}
|
13
|
+
- model_class.column_names.each do |column_name|
|
14
|
+
%td= object.send(column_name).to_s
|
@@ -3,11 +3,17 @@ require 'spec_helper'
|
|
3
3
|
describe Administer::ModelsController do
|
4
4
|
describe "GET /index" do
|
5
5
|
it "should lookup for proper collection" do
|
6
|
-
|
6
|
+
controller.should_receive(:model_class).and_return(Post)
|
7
7
|
posts = mock_model(Post)
|
8
8
|
Post.should_receive(:all).and_return(posts)
|
9
9
|
get :index, :model_name => 'post'
|
10
10
|
assigns[:collection].should == posts
|
11
11
|
end
|
12
12
|
end
|
13
|
+
|
14
|
+
it "model_class should lookup for proper model" do
|
15
|
+
controller.should_receive(:params).and_return({:model_name => 'Post'})
|
16
|
+
Administer::Model.should_receive(:lookup).with('Post').and_return(Post)
|
17
|
+
controller.send(:model_class).should == Post
|
18
|
+
end
|
13
19
|
end
|
metadata
CHANGED
@@ -1,13 +1,12 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: administer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash: 21
|
5
4
|
prerelease: false
|
6
5
|
segments:
|
7
6
|
- 0
|
8
7
|
- 2
|
9
|
-
-
|
10
|
-
version: 0.2.
|
8
|
+
- 2
|
9
|
+
version: 0.2.2
|
11
10
|
platform: ruby
|
12
11
|
authors:
|
13
12
|
- Piotr Jakubowski
|
@@ -18,8 +17,35 @@ cert_chain: []
|
|
18
17
|
|
19
18
|
date: 2010-12-06 00:00:00 +01:00
|
20
19
|
default_executable:
|
21
|
-
dependencies:
|
22
|
-
|
20
|
+
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
22
|
+
name: jeweler
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
none: false
|
25
|
+
requirements:
|
26
|
+
- - ">="
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
segments:
|
29
|
+
- 0
|
30
|
+
version: "0"
|
31
|
+
type: :runtime
|
32
|
+
prerelease: false
|
33
|
+
version_requirements: *id001
|
34
|
+
- !ruby/object:Gem::Dependency
|
35
|
+
name: haml
|
36
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
37
|
+
none: false
|
38
|
+
requirements:
|
39
|
+
- - ">="
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
segments:
|
42
|
+
- 3
|
43
|
+
- 0
|
44
|
+
- 18
|
45
|
+
version: 3.0.18
|
46
|
+
type: :runtime
|
47
|
+
prerelease: false
|
48
|
+
version_requirements: *id002
|
23
49
|
description: ""
|
24
50
|
email:
|
25
51
|
- piotrj@gmail.com
|
@@ -45,6 +71,7 @@ files:
|
|
45
71
|
- spec/rails_root/app/controllers/posts_controller.rb
|
46
72
|
- spec/rails_root/app/helpers/application_helper.rb
|
47
73
|
- spec/rails_root/app/helpers/posts_helper.rb
|
74
|
+
- spec/rails_root/app/models/category.rb
|
48
75
|
- spec/rails_root/app/models/post.rb
|
49
76
|
- spec/rails_root/autotest/discover.rb
|
50
77
|
- spec/rails_root/config/application.rb
|
@@ -60,6 +87,7 @@ files:
|
|
60
87
|
- spec/rails_root/config/initializers/session_store.rb
|
61
88
|
- spec/rails_root/config/routes.rb
|
62
89
|
- spec/rails_root/db/migrate/20101113123123_create_posts.rb
|
90
|
+
- spec/rails_root/db/migrate/20101206203354_create_categories.rb
|
63
91
|
- spec/rails_root/db/seeds.rb
|
64
92
|
- spec/rails_root/features/step_definitions/post_steps.rb
|
65
93
|
- spec/rails_root/features/step_definitions/web_steps.rb
|
@@ -82,8 +110,8 @@ homepage: http://github.com/piotrj/administer
|
|
82
110
|
licenses: []
|
83
111
|
|
84
112
|
post_install_message:
|
85
|
-
rdoc_options:
|
86
|
-
|
113
|
+
rdoc_options: []
|
114
|
+
|
87
115
|
require_paths:
|
88
116
|
- lib
|
89
117
|
required_ruby_version: !ruby/object:Gem::Requirement
|
@@ -91,7 +119,6 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
91
119
|
requirements:
|
92
120
|
- - ">="
|
93
121
|
- !ruby/object:Gem::Version
|
94
|
-
hash: 3
|
95
122
|
segments:
|
96
123
|
- 0
|
97
124
|
version: "0"
|
@@ -100,7 +127,6 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
100
127
|
requirements:
|
101
128
|
- - ">="
|
102
129
|
- !ruby/object:Gem::Version
|
103
|
-
hash: 3
|
104
130
|
segments:
|
105
131
|
- 0
|
106
132
|
version: "0"
|
@@ -116,6 +142,7 @@ test_files:
|
|
116
142
|
- spec/rails_root/app/controllers/posts_controller.rb
|
117
143
|
- spec/rails_root/app/helpers/application_helper.rb
|
118
144
|
- spec/rails_root/app/helpers/posts_helper.rb
|
145
|
+
- spec/rails_root/app/models/category.rb
|
119
146
|
- spec/rails_root/app/models/post.rb
|
120
147
|
- spec/rails_root/autotest/discover.rb
|
121
148
|
- spec/rails_root/config/application.rb
|
@@ -131,6 +158,7 @@ test_files:
|
|
131
158
|
- spec/rails_root/config/initializers/session_store.rb
|
132
159
|
- spec/rails_root/config/routes.rb
|
133
160
|
- spec/rails_root/db/migrate/20101113123123_create_posts.rb
|
161
|
+
- spec/rails_root/db/migrate/20101206203354_create_categories.rb
|
134
162
|
- spec/rails_root/db/seeds.rb
|
135
163
|
- spec/rails_root/features/step_definitions/post_steps.rb
|
136
164
|
- spec/rails_root/features/step_definitions/web_steps.rb
|