merb-admin 0.4.6 → 0.4.7

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.
data/README.markdown CHANGED
@@ -16,7 +16,7 @@ At the command prompt, type:
16
16
 
17
17
  In your app, add the following dependency to `config/dependencies.rb`:
18
18
 
19
- dependency "merb-admin", "0.4.6"
19
+ dependency "merb-admin", "0.4.7"
20
20
 
21
21
  Add the following route to `config/router.rb`:
22
22
 
data/Rakefile CHANGED
@@ -9,7 +9,7 @@ AUTHOR = "Erik Michaels-Ober"
9
9
  EMAIL = "sferik@gmail.com"
10
10
  HOMEPAGE = "http://twitter.com/sferik"
11
11
  SUMMARY = "MerbAdmin is a Merb plugin that provides an easy-to-use interface for managing your data."
12
- GEM_VERSION = "0.4.6"
12
+ GEM_VERSION = "0.4.7"
13
13
 
14
14
  spec = Gem::Specification.new do |s|
15
15
  s.rubyforge_project = "merb"
@@ -137,6 +137,7 @@ class MerbAdmin::Main < MerbAdmin::Application
137
137
  statements << "#{property[:name]} LIKE ?"
138
138
  values << "%#{params[:query]}%"
139
139
  end
140
+ conditions[0] += " AND " unless conditions == [""]
140
141
  conditions[0] += statements.join(" OR ")
141
142
  conditions += values
142
143
  options.merge!(:conditions => conditions) unless conditions == [""]
@@ -155,10 +156,10 @@ class MerbAdmin::Main < MerbAdmin::Application
155
156
  values << (value == "true")
156
157
  end
157
158
  end
159
+ conditions[0] += " AND " unless conditions == [""]
158
160
  conditions[0] += statements.join(" AND ")
159
161
  conditions += values
160
162
  options.merge!(:conditions => conditions) unless conditions == [""]
161
- puts options.inspect
162
163
  end
163
164
 
164
165
  def merge_sort!(options)
@@ -16,7 +16,7 @@
16
16
  <form id="changelist-search" action="" method="get">
17
17
  <div>
18
18
  <label for="searchbar"><img src="<%= image_path("icon_searchbox.png") %>" alt="Search" /></label>
19
- <input type="text" size="40" name="query" value="" id="searchbar" />
19
+ <input type="text" size="40" name="query" value="<%= query %>" id="searchbar" />
20
20
  <input type="submit" value="Search" />
21
21
  <% if query || filter %>
22
22
  <span class="small quiet"><%= @record_count %> <%= @record_count == 1 ? "result" : "results" %> (<a href="?"><%= @abstract_model.count %> total</a>)</span>
data/lib/merb-admin.rb CHANGED
@@ -23,7 +23,7 @@ if defined?(Merb::Plugins)
23
23
 
24
24
  # Slice metadata
25
25
  self.description = "MerbAdmin is a Merb plugin that provides an easy-to-use interface for managing your data."
26
- self.version = "0.4.6"
26
+ self.version = "0.4.7"
27
27
  self.author = "Erik Michaels-Ober"
28
28
 
29
29
  # Stub classes loaded hook - runs before LoadClasses BootLoader
@@ -8,7 +8,7 @@ class CreatePlayersMigration < ActiveRecord::Migration
8
8
  t.string :position, :limit => 50
9
9
  t.integer :number
10
10
  t.float :batting_average, :default => 0.0
11
- t.boolean :all_star, :default => false
11
+ t.boolean :retired, :default => false
12
12
  t.boolean :injured, :default => false
13
13
  t.date :born_on
14
14
  t.timestamp :wake_at
@@ -10,7 +10,7 @@ class Player
10
10
  property :position, String
11
11
  property :number, Integer, :nullable => false
12
12
  property :batting_average, Float, :default => 0.0, :precision => 4, :scale => 3
13
- property :all_star, Boolean, :default => false
13
+ property :retired, Boolean, :default => false
14
14
  property :injured, Boolean, :default => false
15
15
  property :born_on, Date
16
16
  property :wake_at, Time
@@ -89,10 +89,42 @@ describe "MerbAdmin" do
89
89
  end
90
90
  end
91
91
 
92
- describe "list with query" do
92
+ describe "list with sort" do
93
93
  before(:each) do
94
+ MerbAdmin::AbstractModel.new("Player").create(:team_id => rand(99999), :number => 32, :name => "Sandy Koufax", :position => "pitcher")
94
95
  MerbAdmin::AbstractModel.new("Player").create(:team_id => rand(99999), :number => 42, :name => "Jackie Robinson", :position => "second")
96
+ @response = request(url(:admin_list, :model_name => "player"), :params => {:sort => "name"})
97
+ end
98
+
99
+ it "should respond sucessfully" do
100
+ @response.should be_successful
101
+ end
102
+
103
+ it "should be sorted correctly" do
104
+ @response.body.should contain(/Jackie Robinson.*Sandy Koufax/m)
105
+ end
106
+ end
107
+
108
+ describe "list with reverse sort" do
109
+ before(:each) do
110
+ MerbAdmin::AbstractModel.new("Player").create(:team_id => rand(99999), :number => 32, :name => "Sandy Koufax", :position => "pitcher")
111
+ MerbAdmin::AbstractModel.new("Player").create(:team_id => rand(99999), :number => 42, :name => "Jackie Robinson", :position => "second")
112
+ @response = request(url(:admin_list, :model_name => "player"), :params => {:sort => "name", :sort_reverse => "true"})
113
+ end
114
+
115
+ it "should respond sucessfully" do
116
+ @response.should be_successful
117
+ end
118
+
119
+ it "should be sorted correctly" do
120
+ @response.body.should contain(/Sandy Koufax.*Jackie Robinson/m)
121
+ end
122
+ end
123
+
124
+ describe "list with query" do
125
+ before(:each) do
95
126
  MerbAdmin::AbstractModel.new("Player").create(:team_id => rand(99999), :number => 32, :name => "Sandy Koufax", :position => "pitcher")
127
+ MerbAdmin::AbstractModel.new("Player").create(:team_id => rand(99999), :number => 42, :name => "Jackie Robinson", :position => "second")
96
128
  @response = request(url(:admin_list, :model_name => "player"), :params => {:query => "Jackie Robinson"})
97
129
  end
98
130
 
@@ -109,43 +141,58 @@ describe "MerbAdmin" do
109
141
  end
110
142
  end
111
143
 
112
- describe "list with sort" do
144
+ describe "list with query and boolean filter" do
113
145
  before(:each) do
114
- MerbAdmin::AbstractModel.new("Player").create(:team_id => rand(99999), :number => 42, :name => "Jackie Robinson", :position => "second")
115
- MerbAdmin::AbstractModel.new("Player").create(:team_id => rand(99999), :number => 32, :name => "Sandy Koufax", :position => "pitcher")
116
- @response = request(url(:admin_list, :model_name => "player"), :params => {:sort => "name"})
146
+ MerbAdmin::AbstractModel.new("Player").create(:team_id => rand(99999), :number => 32, :name => "Sandy Koufax", :position => "pitcher", :retired => true, :injured => true)
147
+ MerbAdmin::AbstractModel.new("Player").create(:team_id => rand(99999), :number => 42, :name => "Jackie Robinson", :position => "second", :retired => true, :injured => false)
148
+ MerbAdmin::AbstractModel.new("Player").create(:team_id => rand(99999), :number => 18, :name => "Moises Alou", :position => "left", :retired => false, :injured => true)
149
+ MerbAdmin::AbstractModel.new("Player").create(:team_id => rand(99999), :number => 5, :name => "David Wright", :position => "third", :retired => false, :injured => false)
150
+ @response = request(url(:admin_list, :model_name => "player"), :params => {:query => "Sandy Koufax", :filter => {:injured => "true"}})
117
151
  end
118
152
 
119
153
  it "should respond sucessfully" do
120
154
  @response.should be_successful
121
155
  end
122
156
 
123
- it "should be sorted correctly" do
124
- @response.body.should contain(/Jackie Robinson.*Sandy Koufax/m)
157
+ it "should contain a correct result" do
158
+ @response.body.should contain("Sandy Koufax")
159
+ end
160
+
161
+ it "should not contain an incorrect result" do
162
+ @response.body.should_not contain("Jackie Robinson")
163
+ @response.body.should_not contain("Moises Alou")
164
+ @response.body.should_not contain("David Wright")
125
165
  end
126
166
  end
127
167
 
128
- describe "list with reverse sort" do
168
+
169
+ describe "list with boolean filter" do
129
170
  before(:each) do
130
- MerbAdmin::AbstractModel.new("Player").create(:team_id => rand(99999), :number => 42, :name => "Jackie Robinson", :position => "second")
131
- MerbAdmin::AbstractModel.new("Player").create(:team_id => rand(99999), :number => 32, :name => "Sandy Koufax", :position => "pitcher")
132
- @response = request(url(:admin_list, :model_name => "player"), :params => {:sort => "name", :sort_reverse => "true"})
171
+ MerbAdmin::AbstractModel.new("Player").create(:team_id => rand(99999), :number => 18, :name => "Moises Alou", :position => "left", :injured => true)
172
+ MerbAdmin::AbstractModel.new("Player").create(:team_id => rand(99999), :number => 5, :name => "David Wright", :position => "third", :injured => false)
173
+ @response = request(url(:admin_list, :model_name => "player"), :params => {:filter => {:injured => "true"}})
133
174
  end
134
175
 
135
176
  it "should respond sucessfully" do
136
177
  @response.should be_successful
137
178
  end
138
179
 
139
- it "should be sorted correctly" do
140
- @response.body.should contain(/Sandy Koufax.*Jackie Robinson/m)
180
+ it "should contain a correct result" do
181
+ @response.body.should contain("Moises Alou")
182
+ end
183
+
184
+ it "should not contain an incorrect result" do
185
+ @response.body.should_not contain("David Wright")
141
186
  end
142
187
  end
143
188
 
144
- describe "list with boolean filter" do
189
+ describe "list with boolean filters" do
145
190
  before(:each) do
146
- MerbAdmin::AbstractModel.new("Player").create(:team_id => rand(99999), :number => 18, :name => "Moises Alou", :position => "left", :injured => true)
147
- MerbAdmin::AbstractModel.new("Player").create(:team_id => rand(99999), :number => 5, :name => "David Wright", :position => "third", :injured => false)
148
- @response = request(url(:admin_list, :model_name => "player"), :params => {:filter => {:injured => true}})
191
+ MerbAdmin::AbstractModel.new("Player").create(:team_id => rand(99999), :number => 32, :name => "Sandy Koufax", :position => "pitcher", :retired => true, :injured => true)
192
+ MerbAdmin::AbstractModel.new("Player").create(:team_id => rand(99999), :number => 42, :name => "Jackie Robinson", :position => "second", :retired => true, :injured => false)
193
+ MerbAdmin::AbstractModel.new("Player").create(:team_id => rand(99999), :number => 18, :name => "Moises Alou", :position => "left", :retired => false, :injured => true)
194
+ MerbAdmin::AbstractModel.new("Player").create(:team_id => rand(99999), :number => 5, :name => "David Wright", :position => "third", :retired => false, :injured => false)
195
+ @response = request(url(:admin_list, :model_name => "player"), :params => {:filter => {:retired => "true", :injured => "true"}})
149
196
  end
150
197
 
151
198
  it "should respond sucessfully" do
@@ -153,10 +200,11 @@ describe "MerbAdmin" do
153
200
  end
154
201
 
155
202
  it "should contain a correct result" do
156
- @response.body.should contain("Moises Alou")
157
203
  end
158
204
 
159
205
  it "should not contain an incorrect result" do
206
+ @response.body.should_not contain("Jackie Robinson")
207
+ @response.body.should_not contain("Moises Alou")
160
208
  @response.body.should_not contain("David Wright")
161
209
  end
162
210
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: merb-admin
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.6
4
+ version: 0.4.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Erik Michaels-Ober