Skip to content

Commit

Permalink
- using agnostic-will_paginate
Browse files Browse the repository at this point in the history
- documents pagination; minor bug fix.
  • Loading branch information
florinpatrascu committed Jul 18, 2012
1 parent 829988a commit d056ff8
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 22 deletions.
5 changes: 5 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 0.1.1 (2012-07-18)

* using agnostic-will_paginate
* documents pagination; minor bug fix.

## 0.1.0 (2012-07-16)

* Initial Release, code name: Simona
3 changes: 2 additions & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ PATH
remote: .
specs:
mongo_fe (0.1.0)
agnostic-will_paginate (>= 3.0.0)
bson
bson_ext
chronic (~> 0.6.7)
Expand All @@ -15,7 +16,6 @@ PATH
sinatra-contrib (~> 1.3.1)
tilt (~> 1.3.0)
vegas (~> 0.1.11)
will_paginate (>= 3.0.0)
will_paginate-bootstrap
yajl-ruby

Expand All @@ -26,6 +26,7 @@ GEM
i18n (~> 0.6)
multi_json (~> 1.0)
addressable (2.2.8)
agnostic-will_paginate (3.0.0)
appraisal (0.4.1)
bundler
rake
Expand Down
18 changes: 1 addition & 17 deletions lib/mongo_fe/controllers/collections_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -201,23 +201,7 @@ class CollectionsController < ApplicationController

end

unless @collection.nil?
@page = params[:page].to_i || 1
@query= session[:query]

begin
@total, @documents = MongoFe::MongoDB::SearchDocuments.new(current_db, @collection).list(@query, @page, 10)
flash_search_results @query, @total
rescue => e
session[:query] = nil
@total, @documents = MongoFe::MongoDB::SearchDocuments.new(current_db, @collection).list(nil, 1, 10)

flash[:error] = "Resetting to find all. Cause: #{e.message}"
end

end

haml :'/collections/index'
redirect "/databases/#{current_db.name}/collections/#{@collection.name}"
end

put "/:collection_name/?" do
Expand Down
2 changes: 1 addition & 1 deletion lib/mongo_fe/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
# http://semver.org/

module MongoFe
VERSION = "0.1.0"
VERSION = "0.1.1"
end
2 changes: 1 addition & 1 deletion mongo_fe.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Gem::Specification.new do |gem|
gem.add_runtime_dependency "bson"
gem.add_runtime_dependency "bson_ext"
gem.add_runtime_dependency "json"
gem.add_runtime_dependency 'will_paginate', '>= 3.0.0'
gem.add_runtime_dependency 'agnostic-will_paginate', '>= 3.0.0'
gem.add_runtime_dependency 'will_paginate-bootstrap'
gem.add_runtime_dependency "sinatra", "~> 1.3.2"
gem.add_runtime_dependency "sinatra-contrib", "~> 1.3.1"
Expand Down
5 changes: 3 additions & 2 deletions spec/controllers/collections_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ def sparse?
describe "POST /databases/:db_name/collections/:collection_name/documents" do
it "should insert a new document" do
post "/databases/#{db_name}/collections/#{collection_name}/documents", {:json_doc_attributes => test_doc_json}
follow_redirect!
last_response.body.should contain("added to: #{db_name}.#{collection_name}")
# todo verify the Document insertion
end
Expand Down Expand Up @@ -112,7 +113,7 @@ def sparse?

follow_redirect!
# "The index: '#{index_name}' was successfully created"
index.name = last_response.body[/index: '([^']+)/,1]
index.name = last_response.body[/index: '([^']+)/, 1]
last_response.body.should contain("was successfully created")
end
end
Expand All @@ -134,7 +135,7 @@ def sparse?
last_response.body.should contain("The index: '#{index.name}', was deleted successfully.")

indexes = collection.index_information
indexes.should_not contain(index.name)
indexes.should_not contain(index.name)
end
end

Expand Down

0 comments on commit d056ff8

Please sign in to comment.