mongo_browser 0.2.0.rc2 → 0.2.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (141) hide show
  1. data/.gitignore +3 -1
  2. data/.rspec +1 -1
  3. data/.travis.yml +6 -1
  4. data/CHANGELOG.md +15 -0
  5. data/{grunt.js → Gruntfile.js} +10 -8
  6. data/Procfile +1 -0
  7. data/README.md +44 -2
  8. data/Rakefile +1 -12
  9. data/app/assets/images/ajax-loader.gif +0 -0
  10. data/app/assets/javascripts/app/controllers/{breadcrumbs.js.coffee → breadcrumbs_controller.js.coffee} +4 -7
  11. data/app/assets/javascripts/app/controllers/collections/index_controller.js.coffee +38 -0
  12. data/app/assets/javascripts/app/controllers/collections/stats_controller.js.coffee +17 -0
  13. data/app/assets/javascripts/app/controllers/{databases.js.coffee → databases/index_controller.js.coffee} +11 -15
  14. data/app/assets/javascripts/app/controllers/databases/stats_controller.js.coffee +15 -0
  15. data/app/assets/javascripts/app/controllers/documents/index_controller.js.coffee +54 -0
  16. data/app/assets/javascripts/app/controllers/documents/show_controller.js.coffee +38 -0
  17. data/app/assets/javascripts/app/controllers/main_controller.js.coffee +15 -0
  18. data/app/assets/javascripts/app/controllers/servers/show_controller.js.coffee +17 -0
  19. data/app/assets/javascripts/app/directives.js.coffee +23 -0
  20. data/app/assets/javascripts/app/filters.js.coffee +14 -1
  21. data/app/assets/javascripts/app/modules/alerts.js.coffee +58 -0
  22. data/app/assets/javascripts/app/modules/pager.js.coffee +2 -2
  23. data/app/assets/javascripts/app/modules/spinner.js.coffee +29 -0
  24. data/app/assets/javascripts/app/modules/table_filter.js.coffee +4 -4
  25. data/app/assets/javascripts/app/resources.js.coffee +14 -8
  26. data/app/assets/javascripts/app/services.js.coffee +11 -33
  27. data/app/assets/javascripts/application.js.coffee +62 -34
  28. data/app/assets/javascripts/application.test.js.coffee +5 -0
  29. data/app/assets/javascripts/compiled_templates.js.coffee +1 -0
  30. data/app/assets/javascripts/vendor.js.coffee +0 -1
  31. data/app/assets/stylesheets/application.css.scss +36 -18
  32. data/{public/index.html → app/views/index.erb} +8 -8
  33. data/bin/mongo_browser +2 -13
  34. data/config.ru +3 -1
  35. data/lib/mongo_browser.rb +1 -0
  36. data/lib/mongo_browser/api.rb +11 -0
  37. data/lib/mongo_browser/api/collections.rb +34 -0
  38. data/lib/mongo_browser/api/databases.rb +32 -0
  39. data/lib/mongo_browser/api/documents.rb +37 -0
  40. data/lib/mongo_browser/api/mongo.rb +41 -0
  41. data/lib/mongo_browser/application.rb +8 -174
  42. data/lib/mongo_browser/application/development.rb +32 -0
  43. data/lib/mongo_browser/cli.rb +48 -0
  44. data/lib/mongo_browser/entities.rb +43 -0
  45. data/lib/mongo_browser/models/collection.rb +7 -12
  46. data/lib/mongo_browser/models/document.rb +5 -1
  47. data/lib/mongo_browser/models/pager.rb +22 -9
  48. data/lib/mongo_browser/version.rb +1 -1
  49. data/mongo_browser.gemspec +22 -15
  50. data/package.json +30 -0
  51. data/public/ng/templates/alerts.html +6 -0
  52. data/public/ng/templates/collections/index.html +39 -0
  53. data/public/ng/templates/collections/stats.html +18 -0
  54. data/public/ng/templates/databases/index.html +35 -0
  55. data/public/ng/templates/databases/stats.html +18 -0
  56. data/public/ng/templates/documents/index.html +40 -0
  57. data/public/ng/templates/documents/show.html +17 -0
  58. data/{app/assets → public/ng}/templates/pager.html +0 -0
  59. data/{app/assets/templates/server_info.html → public/ng/templates/server/show.html} +1 -1
  60. data/{app/assets → public/ng}/templates/table_filter.html +0 -0
  61. data/script/ci_all +5 -1
  62. data/script/ci_e2e +5 -2
  63. data/script/ci_javascripts +1 -1
  64. data/script/ci_rspec +1 -1
  65. data/spec/javascripts/app/controllers/{breadcrumbs_spec.js.coffee → breadcrumbs_controller_spec.js.coffee} +1 -1
  66. data/spec/javascripts/app/controllers/collections/index_controller_spec.js.coffee +95 -0
  67. data/spec/javascripts/app/controllers/collections/stats_controller_spec.js.coffee +34 -0
  68. data/spec/javascripts/app/controllers/databases/index_controller_spec.js.coffee +93 -0
  69. data/spec/javascripts/app/controllers/databases/stats_controller_spec.js.coffee +30 -0
  70. data/spec/javascripts/app/controllers/documents/index_controller_spec.js.coffee +108 -0
  71. data/spec/javascripts/app/controllers/documents/show_controller_spec.js.coffee +94 -0
  72. data/spec/javascripts/app/controllers/{main_spec.js.coffee → main_controller_spec.js.coffee} +2 -2
  73. data/spec/javascripts/app/controllers/{server_info_spec.js.coffee → server/show_controller_spec.js.coffee} +5 -6
  74. data/spec/javascripts/app/directives_spec.js.coffee +108 -24
  75. data/spec/javascripts/app/filters_spec.js.coffee +31 -5
  76. data/spec/javascripts/app/modules/alerts_spec.js.coffee +138 -0
  77. data/spec/javascripts/app/modules/dialogs_spec.js.coffee +1 -2
  78. data/spec/javascripts/app/modules/pager_spec.js.coffee +0 -1
  79. data/spec/javascripts/app/modules/spinner_spec.js.coffee +65 -0
  80. data/spec/javascripts/app/modules/table_filter_spec.js.coffee +9 -9
  81. data/spec/javascripts/app/resources_spec.js.coffee +99 -0
  82. data/spec/javascripts/app/services_spec.js.coffee +31 -71
  83. data/spec/javascripts/config/{testacular-e2e.conf.js → karma-e2e.conf.js} +1 -1
  84. data/spec/javascripts/config/{testacular.conf.js → karma.conf.js} +2 -3
  85. data/spec/javascripts/e2e/collection_stats_scenario.js.coffee +12 -0
  86. data/spec/javascripts/e2e/collections_scenario.js.coffee +59 -20
  87. data/spec/javascripts/e2e/database_stats_scenario.js.coffee +11 -0
  88. data/spec/javascripts/e2e/databases_scenario.js.coffee +37 -36
  89. data/spec/javascripts/e2e/document_show_scenario.js.coffee +31 -0
  90. data/spec/javascripts/e2e/documents_pagination_scenario.js.coffee +33 -0
  91. data/spec/javascripts/e2e/documents_scenario.js.coffee +43 -4
  92. data/spec/javascripts/e2e/server_info_scenario.js.coffee +8 -2
  93. data/spec/javascripts/helpers/mocks.js.coffee +2 -0
  94. data/spec/javascripts/helpers_e2e/dsl.js.coffee +20 -0
  95. data/spec/javascripts/lib/angular-mocks.js +64 -16
  96. data/spec/javascripts/lib/angular-scenario.js +724 -561
  97. data/spec/javascripts/runner.html +5 -5
  98. data/spec/lib/api/collections_spec.rb +62 -0
  99. data/spec/lib/api/databases_spec.rb +58 -0
  100. data/spec/lib/api/documents_spec.rb +135 -0
  101. data/spec/lib/api/mongo_spec.rb +27 -0
  102. data/spec/lib/cli_spec.rb +19 -0
  103. data/spec/lib/entities_spec.rb +39 -0
  104. data/spec/lib/models/collection_spec.rb +16 -10
  105. data/spec/lib/models/database_spec.rb +4 -4
  106. data/spec/lib/models/document_spec.rb +5 -5
  107. data/spec/lib/models/pager_spec.rb +20 -11
  108. data/spec/spec_helper.rb +7 -15
  109. data/spec/support/api_example_group.rb +45 -0
  110. data/spec/support/fixtures.rb +10 -6
  111. data/spec/support/matchers/expose.rb +18 -0
  112. data/vendor/assets/javascripts/angular/angular-bootstrap.js +1 -1
  113. data/vendor/assets/javascripts/angular/angular-resource.js +78 -56
  114. data/vendor/assets/javascripts/angular/angular-sanitize.js +3 -1
  115. data/vendor/assets/javascripts/angular/angular.js +720 -404
  116. metadata +323 -183
  117. data/app/assets/javascripts/app.js.coffee +0 -8
  118. data/app/assets/javascripts/app/controllers.js.coffee +0 -2
  119. data/app/assets/javascripts/app/controllers/alerts.js.coffee +0 -12
  120. data/app/assets/javascripts/app/controllers/collections.js.coffee +0 -40
  121. data/app/assets/javascripts/app/controllers/documents.js.coffee +0 -49
  122. data/app/assets/javascripts/app/controllers/main.js.coffee +0 -10
  123. data/app/assets/javascripts/app/controllers/server_info.js.coffee +0 -14
  124. data/app/assets/javascripts/templates.js.coffee +0 -1
  125. data/app/assets/javascripts/templates/.gitkeep +0 -0
  126. data/app/assets/templates/collections.html +0 -53
  127. data/app/assets/templates/databases.html +0 -32
  128. data/app/assets/templates/documents.html +0 -45
  129. data/config-e2e.ru +0 -20
  130. data/spec/features/collections_list_spec.rb +0 -64
  131. data/spec/features/documents_list_spec.rb +0 -139
  132. data/spec/features/server_info_spec.rb +0 -23
  133. data/spec/javascripts/app/controllers/alerts_spec.js.coffee +0 -36
  134. data/spec/javascripts/app/controllers/collections_spec.js.coffee +0 -78
  135. data/spec/javascripts/app/controllers/databases_spec.js.coffee +0 -55
  136. data/spec/javascripts/app/controllers/documents_spec.js.coffee +0 -62
  137. data/spec/javascripts/helpers_e2e/app_element.js.coffee +0 -6
  138. data/spec/support/feature_example_group.rb +0 -53
  139. data/spec/support/matchers/have_flash_message.rb +0 -16
  140. data/spec/support/mongod.rb +0 -91
  141. data/spec/support/mongodb.conf +0 -47
@@ -1,8 +0,0 @@
1
- #= require app/services
2
- #= require app/resources
3
- #= require app/directives
4
- #= require app/filters
5
- #= require_tree ./app/modules
6
-
7
- #= require app/controllers
8
- #= require_tree ./app/controllers
@@ -1,2 +0,0 @@
1
- # Simply define a module for controllers..
2
- angular.module("mb.controllers", ["mb.services", "mb.resources"])
@@ -1,12 +0,0 @@
1
- module = angular.module("mb.controllers")
2
-
3
- class AlertsController
4
- constructor: (@$scope, @alerts) ->
5
- @$scope.alertMessages = @alerts.messages
6
-
7
- @$scope.disposeAlert = (id) =>
8
- @alerts.dispose(id)
9
-
10
- AlertsController.$inject = ["$scope", "alerts"]
11
-
12
- module.controller "alerts", AlertsController
@@ -1,40 +0,0 @@
1
- module = angular.module("mb.controllers")
2
-
3
- # TODO clenup this controller, see DatabasesController
4
- class CollectionsController
5
- constructor: (@$scope, @$routeParams, @Collection, @$http, @confirmationDialog, @alerts) ->
6
-
7
- @$scope.dbName = @$routeParams.dbName
8
- @$scope.filterValue = ""
9
-
10
- _onLoadComplete = (data) =>
11
- @$scope.collections = data
12
- @$scope.loading = false
13
-
14
- @$scope.fetchCollections = =>
15
- @$scope.loading = true
16
- @$scope.collections = @Collection.query({ dbName: @$scope.dbName }, _onLoadComplete)
17
-
18
- @$scope.fetchCollections()
19
-
20
- # TODO create resource for this call
21
- @$http.get("/api/databases/#{@$scope.dbName}/stats.json").success (data) =>
22
- @$scope.dbStats = data
23
-
24
- @$scope.isLoading = => @$scope.loading
25
-
26
- @$scope.delete = (collection) =>
27
- @confirmationDialog
28
- message: "Deleting #{collection.name}. Are you sure?"
29
- onOk: =>
30
- resource = new @Collection()
31
- params = dbName: collection.dbName, id: collection.name
32
-
33
- resource.$delete params, =>
34
- @alerts.info("Collection #{collection.name} has been deleted.")
35
- @$scope.fetchCollections()
36
-
37
- CollectionsController.$inject = ["$scope", "$routeParams",
38
- "Collection", "$http", "confirmationDialog", "alerts"]
39
-
40
- module.controller "collections", CollectionsController
@@ -1,49 +0,0 @@
1
- module = angular.module("mb.controllers")
2
-
3
- # TODO clenup this controller, see DatabasesController
4
- class DocumentsController
5
- constructor: (@$scope, @$routeParams, @$http, @Document, @confirmationDialog, @alerts) ->
6
- @$scope.dbName = @$routeParams.dbName
7
- @$scope.collectionName = @$routeParams.collectionName
8
-
9
- @$scope.isLoading = => @$scope.loading
10
-
11
- _onLoadComplete = (data) =>
12
- @$scope.loading = false
13
-
14
- @$scope.documents = data.documents
15
- @$scope.page = data.page
16
- @$scope.totalPages = data.totalPages
17
- @$scope.size = data.size
18
-
19
- @$scope.fetchDocuments = (page = 1) =>
20
- return if @$scope.isLoading() # TODO workaround for doule request
21
- @$scope.loading = true
22
-
23
- params = dbName: @$scope.dbName, collectionName: @$scope.collectionName, page: page
24
- @Document.query(params, _onLoadComplete)
25
-
26
- @$scope.page = 1
27
- @$scope.fetchDocuments()
28
-
29
- @$scope.$watch "page", (page) =>
30
- @$scope.fetchDocuments(page)
31
-
32
- # TODO create resource for this call
33
- @$http.get("/api/databases/#{@$scope.dbName}/collections/#{@$scope.collectionName}/stats.json").success (data) =>
34
- @$scope.collectionStats = data
35
-
36
- @$scope.delete = (document) =>
37
- @confirmationDialog
38
- message: "Are you sure?"
39
- onOk: =>
40
- resource = new @Document()
41
- params = dbName: @$scope.dbName, collectionName: @$scope.collectionName, id: document.id
42
-
43
- resource.$delete params, =>
44
- @alerts.info("Document #{document.id} has been deleted.")
45
- @$scope.fetchDocuments()
46
-
47
- DocumentsController.$inject = ["$scope", "$routeParams", "$http", "Document", "confirmationDialog", "alerts"]
48
-
49
- module.controller "documents", DocumentsController
@@ -1,10 +0,0 @@
1
- module = angular.module("mb.controllers")
2
-
3
- class MainController
4
- constructor: (@$scope, @$http) ->
5
- @$http.get("/api/version.json").success (data) =>
6
- @$scope.appVersion = data.version
7
-
8
- MainController.$inject = ["$scope", "$http"]
9
-
10
- module.controller "main", MainController
@@ -1,14 +0,0 @@
1
- module = angular.module("mb.controllers")
2
-
3
- class ServerInfo
4
- constructor: (@$scope, @$http) ->
5
- @$scope.loading = true
6
- @$http.get("/api/server_info.json").success(@onLoadComplete)
7
-
8
- onLoadComplete: (data) =>
9
- @$scope.serverInfo = data
10
- @$scope.loading = false
11
-
12
- ServerInfo.$inject = ["$scope", "$http"]
13
-
14
- module.controller "serverInfo", ServerInfo
@@ -1 +0,0 @@
1
- #= require_tree ./templates
File without changes
@@ -1,53 +0,0 @@
1
- <header>
2
- <h2>{{dbName}} collections</h2>
3
- </header>
4
-
5
- <div class="tabbable">
6
- <div class="tab-pane" title="Collections" ng-hide="isLoading()">
7
- <table-filter value="filterValue.name" placeholder="Enter collection name"></table-filter>
8
-
9
- <table ng-show="(collections | filter:filterValue).length" class="table table-striped table-hover collections">
10
- <thead>
11
- <tr>
12
- <th>Name</th>
13
- <th>Documents</th>
14
- <th class="actions">&nbsp;</th>
15
- </tr>
16
- </thead>
17
- <tbody>
18
- <tr ng-repeat="collection in collections | orderBy:'name' | filter:filterValue">
19
- <td>
20
- <a href="{{collection | documentsPath}}">
21
- {{collection.name}}
22
- </a>
23
- </td>
24
- <td>{{collection.size}}</td>
25
- <td class="actions">
26
- <delete-button ng-click="delete(collection)" />
27
- </td>
28
- </tr>
29
- </tbody>
30
- </table>
31
-
32
- <div ng-hide="(collections | filter:filterValue).length" class="filter alert">
33
- Nothing has been found.
34
- </div>
35
- </div>
36
-
37
- <div class="tab-pane" title="Database stats">
38
- <table class="table table-striped table-hover">
39
- <thead>
40
- <tr>
41
- <th>Property</th>
42
- <th>Value</th>
43
- </tr>
44
- </thead>
45
- <tbody>
46
- <tr ng-repeat="(property, value) in dbStats">
47
- <td>{{property}}</td>
48
- <td>{{value}}</td>
49
- </tr>
50
- </tbody>
51
- </table>
52
- </div>
53
- </div>
@@ -1,32 +0,0 @@
1
- <header>
2
- <h2>localhost databases</h2>
3
- </header>
4
-
5
- <div ng-hide="isLoading()">
6
- <table-filter value="filterValue.name" placeholder="Enter database name"></table-filter>
7
-
8
- <table ng-show="(databases | filter:filterValue).length" class="table table-striped table-hover databases">
9
- <thead>
10
- <tr>
11
- <th>Name</th>
12
- <th>Collections</th>
13
- <th>Size</th>
14
- <th class="actions">&nbsp;</th>
15
- </tr>
16
- </thead>
17
- <tbody>
18
- <tr ng-repeat="database in databases | orderBy:'name' | filter:filterValue">
19
- <td><a href="{{database | collectionsPath}}">{{database.name}}</a></td>
20
- <td>{{database.count}}</td>
21
- <td>{{database.size | humanSize}}</td>
22
- <td class="actions">
23
- <delete-button ng-click="delete(database)" />
24
- </td>
25
- </tr>
26
- </tbody>
27
- </table>
28
-
29
- <div ng-hide="(databases | filter:filterValue).length" class="filter alert">
30
- Nothing has been found.
31
- </div>
32
- </div>
@@ -1,45 +0,0 @@
1
- <header>
2
- <h2>{{collectionName}} documents</h2>
3
- </header>
4
-
5
- <div class="tabbable">
6
- <div class="tab-pane" title="Documents">
7
- <pager page="page" total-pages="totalPages"></pager>
8
-
9
- <table class="table table-striped table-hover documents">
10
- <thead>
11
- <tr>
12
- <th>Data</th>
13
- <th class="actions">&nbsp;</th>
14
- </tr>
15
- </thead>
16
- <tbody>
17
- <tr ng-repeat="document in documents" class="document id-{{document.id}}">
18
- <td class="data" ng-bind-html="document.data | jsonDocument"></td>
19
- <td class="actions">
20
- <delete-button ng-click="delete(document)" />
21
- </td>
22
- </tr>
23
- </tbody>
24
- </table>
25
-
26
- <pager page="page" total-pages="totalPages"></pager>
27
- </div>
28
-
29
- <div class="tab-pane" title="Collection stats">
30
- <table class="table table-striped table-hover">
31
- <thead>
32
- <tr>
33
- <th>Property</th>
34
- <th>Value</th>
35
- </tr>
36
- </thead>
37
- <tbody>
38
- <tr ng-repeat="(property, value) in collectionStats">
39
- <td>{{property}}</td>
40
- <td>{{value}}</td>
41
- </tr>
42
- </tbody>
43
- </table>
44
- </div>
45
- </div>
@@ -1,20 +0,0 @@
1
- require "mongo_browser"
2
-
3
- require File.expand_path("spec/support/mongod")
4
- require File.expand_path("spec/support/fixtures")
5
-
6
- test_server = Mongod.instance
7
- fixtures = Fixtures.instance
8
-
9
- test_server.start! do |port|
10
- MongoBrowser.mongodb_host = "127.0.0.1"
11
- MongoBrowser.mongodb_port = port
12
- end
13
-
14
- fixtures.load!
15
-
16
- run MongoBrowser::Application
17
-
18
- at_exit do
19
- test_server.shutdown!
20
- end
@@ -1,64 +0,0 @@
1
- require "spec_helper"
2
-
3
- describe "Collections list", type: :request, js: true do
4
- before do
5
- visit "/"
6
-
7
- within("table.databases") { click_link "first_database" }
8
- end
9
-
10
- xit "displays the breadcrumb" do
11
- within ".breadcrumbs" do
12
- within "li:nth-child(1)" do
13
- expect(page).to have_link("first_database", href: "/databases/first_database/collections")
14
- end
15
- end
16
- end
17
-
18
- describe "click on delete collection button" do
19
- xit "deletes a collection" do
20
- click_delete_button_for("second_collection")
21
- confirm_dialog
22
-
23
- expect(page).to have_flash_message("Collection second_collection has been deleted.")
24
-
25
- within "table.collections" do
26
- expect(page).to have_link("first_collection")
27
- expect(page).to_not have_link("second_collection")
28
- expect(page).to have_link("third_collection")
29
- end
30
-
31
- click_delete_button_for("first_collection")
32
- confirm_dialog
33
- expect(page).to have_flash_message("Collection first_collection has been deleted.")
34
-
35
- within "table.collections" do
36
- expect(page).to_not have_link("first_collection")
37
- expect(page).to_not have_link("second_collection")
38
- expect(page).to have_link("third_collection")
39
- end
40
-
41
- click_delete_button_for("third_collection")
42
- confirm_dialog
43
- expect(page).to have_flash_message("Collection third_collection has been deleted.")
44
-
45
- should_hide_the_table_and_display_a_notification
46
- end
47
-
48
- xit "displays error message when the collection cannot be deleted" do
49
- click_delete_button_for("system.indexes")
50
- confirm_dialog
51
-
52
- expect(page).to have_flash_message("Database command 'drop' failed")
53
-
54
- within "table.collections" do
55
- expect(page).to have_link("system.indexes")
56
- end
57
- end
58
-
59
- def click_delete_button_for(collection_name)
60
- collection_row = find(:xpath, %Q{//table//tr//*[contains(text(), "#{collection_name}")]/../..})
61
- within(collection_row) { click_link "Delete" }
62
- end
63
- end
64
- end
@@ -1,139 +0,0 @@
1
- require "spec_helper"
2
-
3
- describe "Documents list", type: :request, js: true do
4
- let(:connection) { Fixtures.instance.connection }
5
-
6
- before do
7
- visit "/"
8
-
9
- within("table.databases") { click_link "first_database" }
10
- within("table.collections") { click_link current_collection_name }
11
- end
12
-
13
- shared_examples "breadcrumbs for documents list" do
14
- xit "displays the breadcrumb" do
15
- within ".breadcrumbs" do
16
- within "li:nth-child(1)" do
17
- expect(page).to have_link("first_database")
18
- end
19
-
20
- within "li:nth-child(2)" do
21
- href = "/databases/first_database/collections/#{current_collection_name}/documents"
22
- expect(page).to have_link(current_collection_name, href: href)
23
- end
24
- end
25
- end
26
-
27
- xit "has a valid title" do
28
- within "h2" do
29
- expect(page).to have_content("#{current_collection_name} documents")
30
- end
31
- end
32
- end
33
-
34
- context "with small number for documents" do
35
- let(:current_collection_name) { "first_collection" }
36
-
37
- include_examples "breadcrumbs for documents list"
38
-
39
- xit "displays all documents for the selected collection" do
40
- expect(page).to have_css("tr.document", count: 2)
41
-
42
- within "table" do
43
- expect(page).to have_content("This is a sample record")
44
- expect(page).to have_content("This is the second sample record")
45
- end
46
- end
47
-
48
- xit "displays information about the collection" do
49
- click_link "Collection stats"
50
-
51
- within "table" do
52
- %w(ns count size avgObjSize storageSize numExtents nindexes lastExtentSize paddingFactor totalIndexSize indexSizes ok).each do |field|
53
- expect(page).to have_content(field)
54
- end
55
- end
56
- end
57
-
58
- describe "click on delete document button" do
59
- let(:document) do
60
- database = connection.db("first_database")
61
- collection = database.collection(current_collection_name)
62
- collection.find_one(name: "This is the second sample record")
63
- end
64
-
65
- xit "removes a document from the collection" do
66
- click_delete_button_for(document)
67
- confirm_dialog
68
-
69
- expect(page).to have_flash_message("Document #{document["_id"]} has been deleted.")
70
-
71
- expect(page).to have_css("tr.document", count: 1)
72
-
73
- within "table" do
74
- expect(page).to have_content("This is a sample record")
75
- expect(page).not_to have_content(document["name"])
76
- end
77
- end
78
-
79
- def click_delete_button_for(document)
80
- document_row = find("tr.id-#{document["_id"]}")
81
- within(document_row) { click_link "Delete" }
82
- end
83
- end
84
- end
85
-
86
- context "with large number of documents" do
87
- let(:current_collection_name) { "second_collection" }
88
-
89
- before do
90
- database = connection.db("first_database")
91
- collection = database.collection(current_collection_name)
92
-
93
- 70.times do |n|
94
- collection.insert(name: "Document #{n}", position: n)
95
- end
96
-
97
- visit current_path
98
- end
99
-
100
- include_examples "breadcrumbs for documents list"
101
-
102
- xit "displays a pagination" do
103
- expect(page).to have_css("div.pagination", count: 2)
104
- within "div.pagination" do
105
- (1..3).each do |n|
106
- expect(page).to have_link(n.to_s)
107
- end
108
- end
109
- end
110
-
111
- xit "paginates documents" do
112
- within "table.documents" do
113
- (0...25).each do |n|
114
- expect(page).to have_content("Document #{n}")
115
- end
116
- end
117
-
118
- within "div.pagination" do
119
- click_link "2"
120
- end
121
-
122
- within "table.documents" do
123
- (25...50).each do |n|
124
- expect(page).to have_content("Document #{n}")
125
- end
126
- end
127
-
128
- within "div.pagination" do
129
- click_link "3"
130
- end
131
-
132
- within "table.documents" do
133
- (50...70).each do |n|
134
- expect(page).to have_content("Document #{n}")
135
- end
136
- end
137
- end
138
- end
139
- end