mongo_browser 0.1.3 → 0.2.0.rc2

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.
Files changed (118) hide show
  1. data/.gitignore +3 -0
  2. data/.travis.yml +3 -3
  3. data/README.md +1 -25
  4. data/Rakefile +0 -1
  5. data/app/assets/images/background.png +0 -0
  6. data/app/assets/javascripts/app/controllers/alerts.js.coffee +12 -0
  7. data/app/assets/javascripts/app/controllers/breadcrumbs.js.coffee +25 -0
  8. data/app/assets/javascripts/app/controllers/collections.js.coffee +40 -0
  9. data/app/assets/javascripts/app/controllers/databases.js.coffee +39 -0
  10. data/app/assets/javascripts/app/controllers/documents.js.coffee +49 -0
  11. data/app/assets/javascripts/app/controllers/main.js.coffee +10 -0
  12. data/app/assets/javascripts/app/controllers/server_info.js.coffee +14 -0
  13. data/app/assets/javascripts/app/controllers.js.coffee +2 -0
  14. data/app/assets/javascripts/app/directives.js.coffee +20 -0
  15. data/app/assets/javascripts/app/filters.js.coffee +48 -0
  16. data/app/assets/javascripts/app/modules/dialogs.js.coffee +29 -0
  17. data/app/assets/javascripts/app/modules/pager.js.coffee +87 -0
  18. data/app/assets/javascripts/app/modules/table_filter.js.coffee +27 -0
  19. data/app/assets/javascripts/app/resources.js.coffee +22 -0
  20. data/app/assets/javascripts/app/services.js.coffee +36 -0
  21. data/app/assets/javascripts/app.js.coffee +8 -0
  22. data/app/assets/javascripts/application.js.coffee +35 -6
  23. data/app/assets/javascripts/templates/.gitkeep +0 -0
  24. data/app/assets/javascripts/templates.js.coffee +1 -0
  25. data/app/assets/javascripts/vendor.js.coffee +5 -0
  26. data/app/assets/stylesheets/application.css.scss +46 -3
  27. data/app/assets/templates/collections.html +53 -0
  28. data/app/assets/templates/databases.html +32 -0
  29. data/app/assets/templates/documents.html +45 -0
  30. data/app/assets/templates/pager.html +13 -0
  31. data/app/{views/server_info.erb → assets/templates/server_info.html} +5 -7
  32. data/app/assets/templates/table_filter.html +10 -0
  33. data/bin/mongo_browser +8 -45
  34. data/config-e2e.ru +20 -0
  35. data/grunt.js +36 -0
  36. data/lib/mongo_browser/application.rb +143 -64
  37. data/lib/mongo_browser/middleware/sprockets_base.rb +11 -0
  38. data/lib/mongo_browser/middleware/sprockets_sinatra.rb +3 -7
  39. data/lib/mongo_browser/middleware/sprockets_specs.rb +18 -0
  40. data/lib/mongo_browser/models/collection.rb +67 -0
  41. data/lib/mongo_browser/models/database.rb +52 -0
  42. data/lib/mongo_browser/models/document.rb +17 -0
  43. data/lib/mongo_browser/models/pager.rb +30 -0
  44. data/lib/mongo_browser/models/server.rb +51 -0
  45. data/lib/mongo_browser/version.rb +1 -1
  46. data/lib/mongo_browser.rb +10 -5
  47. data/mongo_browser.gemspec +4 -11
  48. data/public/index.html +47 -0
  49. data/script/ci_all +21 -0
  50. data/script/ci_e2e +11 -0
  51. data/script/ci_javascripts +4 -0
  52. data/script/ci_rspec +3 -0
  53. data/spec/features/collections_list_spec.rb +6 -49
  54. data/spec/features/documents_list_spec.rb +15 -14
  55. data/spec/features/server_info_spec.rb +3 -3
  56. data/spec/javascripts/app/controllers/alerts_spec.js.coffee +36 -0
  57. data/spec/javascripts/app/controllers/breadcrumbs_spec.js.coffee +28 -0
  58. data/spec/javascripts/app/controllers/collections_spec.js.coffee +78 -0
  59. data/spec/javascripts/app/controllers/databases_spec.js.coffee +55 -0
  60. data/spec/javascripts/app/controllers/documents_spec.js.coffee +62 -0
  61. data/spec/javascripts/app/controllers/main_spec.js.coffee +20 -0
  62. data/spec/javascripts/app/controllers/server_info_spec.js.coffee +21 -0
  63. data/spec/javascripts/app/directives_spec.js.coffee +58 -0
  64. data/spec/javascripts/app/filters_spec.js.coffee +99 -0
  65. data/spec/javascripts/app/modules/dialogs_spec.js.coffee +51 -0
  66. data/spec/javascripts/app/modules/pager_spec.js.coffee +104 -0
  67. data/spec/javascripts/app/modules/table_filter_spec.js.coffee +76 -0
  68. data/spec/javascripts/app/services_spec.js.coffee +83 -0
  69. data/spec/javascripts/config/testacular-e2e.conf.js +19 -0
  70. data/spec/javascripts/config/testacular.conf.js +43 -0
  71. data/spec/javascripts/e2e/collections_scenario.js.coffee +49 -0
  72. data/spec/javascripts/e2e/databases_scenario.js.coffee +74 -0
  73. data/spec/javascripts/e2e/documents_scenario.js.coffee +18 -0
  74. data/spec/javascripts/e2e/server_info_scenario.js.coffee +12 -0
  75. data/spec/javascripts/helpers/matchers.js.coffee +5 -0
  76. data/spec/javascripts/helpers/mocks.js.coffee +7 -0
  77. data/spec/javascripts/helpers_e2e/app_element.js.coffee +6 -0
  78. data/spec/javascripts/lib/angular-mocks.js +1740 -0
  79. data/spec/javascripts/lib/angular-scenario.js +26147 -0
  80. data/spec/javascripts/lib/jasmine-html.js +681 -0
  81. data/spec/javascripts/lib/jasmine.css +82 -0
  82. data/spec/javascripts/lib/jasmine.js +2600 -0
  83. data/spec/javascripts/runner.html +54 -0
  84. data/spec/javascripts/runner_e2e.html +10 -0
  85. data/spec/javascripts/spec.js.coffee +2 -0
  86. data/spec/javascripts/spec_e2e.js.coffee +2 -0
  87. data/spec/lib/models/collection_spec.rb +80 -0
  88. data/spec/lib/models/database_spec.rb +75 -0
  89. data/spec/lib/models/document_spec.rb +17 -0
  90. data/spec/lib/models/pager_spec.rb +64 -0
  91. data/spec/lib/models/server_spec.rb +76 -0
  92. data/spec/lib/mongo_browser_spec.rb +1 -1
  93. data/spec/spec_helper.rb +2 -19
  94. data/spec/support/feature_example_group.rb +8 -3
  95. data/spec/support/fixtures/databases.json +8 -0
  96. data/spec/support/fixtures.rb +20 -3
  97. data/spec/support/matchers/have_flash_message.rb +1 -1
  98. data/spec/support/mongod.rb +37 -21
  99. data/spec/support/mongodb.conf +47 -0
  100. data/vendor/assets/javascripts/angular/angular-bootstrap.js +166 -0
  101. data/vendor/assets/javascripts/angular/angular-resource.js +435 -0
  102. data/vendor/assets/javascripts/angular/angular-sanitize.js +535 -0
  103. data/vendor/assets/javascripts/angular/angular.js +14531 -0
  104. data/vendor/assets/javascripts/underscore.js +1200 -0
  105. metadata +136 -148
  106. data/app/assets/javascripts/app/table_filter.js.coffee +0 -50
  107. data/app/assets/javascripts/ujs.js.coffee +0 -23
  108. data/app/views/collections/index.erb +0 -59
  109. data/app/views/databases/index.erb +0 -29
  110. data/app/views/documents/index.erb +0 -61
  111. data/app/views/layout/_flash_messages.erb +0 -10
  112. data/app/views/layout/_navbar.erb +0 -22
  113. data/app/views/layout.erb +0 -20
  114. data/app/views/shared/_filter.erb +0 -14
  115. data/features/mongo_browser.feature +0 -18
  116. data/features/step_definitions/mongo_browser_steps.rb +0 -1
  117. data/features/support/env.rb +0 -18
  118. data/spec/features/databases_list_spec.rb +0 -65
@@ -0,0 +1,18 @@
1
+ require "mongo_browser/middleware/sprockets_base"
2
+
3
+ module MongoBrowser
4
+ module Middleware
5
+ class SprocketsSpecs < SprocketsBase
6
+ def initialize(app, options = {})
7
+ @app = app
8
+ @root = options[:root]
9
+ path = options[:path] || "_specs"
10
+ @matcher = /^\/#{path}\/*/
11
+ @environment = ::Sprockets::Environment.new(@root)
12
+
13
+ # Serve specs
14
+ @environment.append_path "spec/javascripts"
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,67 @@
1
+ module MongoBrowser
2
+ module Models
3
+ class Collection
4
+ attr_reader :mongo_collection
5
+
6
+ def initialize(mongo_collection)
7
+ @mongo_collection = mongo_collection
8
+ end
9
+
10
+ # Return database name for the current collection.
11
+ def db_name
12
+ mongo_collection.db.name
13
+ end
14
+
15
+ # Return collection name.
16
+ def name
17
+ mongo_collection.name
18
+ end
19
+
20
+ # Return total number of documents.
21
+ def size
22
+ mongo_collection.size
23
+ end
24
+
25
+ # Return stats on the collection.
26
+ #
27
+ # @return [Hash]
28
+ def stats
29
+ mongo_collection.stats
30
+ end
31
+
32
+ def documents_with_pagination(page_number = 1)
33
+ pager = pager_for(page_number)
34
+
35
+ paged_documents = mongo_collection.find
36
+ .skip(pager.offset)
37
+ .limit(pager.per_page)
38
+
39
+ return paged_documents.map { |doc| Document.new(doc) }, pager
40
+ end
41
+
42
+ def drop!
43
+ mongo_collection.drop
44
+ end
45
+
46
+ # Finds a document with the given id.
47
+ #
48
+ # @return MongoBrowser::Models::Document
49
+ def find(id)
50
+ condition = { _id: BSON::ObjectId(id.to_s) }
51
+ mongo_document = mongo_collection.find(condition).first
52
+ Document.new(mongo_document) if mongo_document
53
+ end
54
+
55
+ # Removes the given document from the collection.
56
+ def remove!(document)
57
+ mongo_collection.remove(_id: document.id)
58
+ end
59
+
60
+ private
61
+
62
+ def pager_for(page)
63
+ Pager.new(page, size)
64
+ end
65
+ end
66
+ end
67
+ end
@@ -0,0 +1,52 @@
1
+ module MongoBrowser
2
+ module Models
3
+ class Database
4
+ attr_reader :mongo_db
5
+
6
+ def initialize(mongo_db)
7
+ @mongo_db = mongo_db
8
+ end
9
+
10
+ def name
11
+ mongo_db.name
12
+ end
13
+ alias :id :name
14
+
15
+ def count
16
+ collections.count
17
+ end
18
+
19
+ def size
20
+ info["sizeOnDisk"].to_i
21
+ end
22
+
23
+ def collection_names
24
+ mongo_db.collection_names
25
+ end
26
+
27
+ def collection(name)
28
+ Collection.new(mongo_db.collection(name))
29
+ end
30
+
31
+ def collections
32
+ collection_names.map { |name| collection(name) }
33
+ end
34
+
35
+ def stats
36
+ mongo_db.stats
37
+ end
38
+
39
+ def drop!
40
+ mongo_db.connection.drop_database(self.name)
41
+ end
42
+
43
+ private
44
+
45
+ def info
46
+ @info ||= mongo_db.connection["admin"].command(listDatabases: true)["databases"].find do |db|
47
+ db["name"] == self.name
48
+ end
49
+ end
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,17 @@
1
+ module MongoBrowser
2
+ module Models
3
+ class Document
4
+ attr_reader :mongo_document
5
+
6
+ def initialize(mongo_document)
7
+ @mongo_document = mongo_document
8
+ end
9
+
10
+ def id
11
+ mongo_document["_id"]
12
+ end
13
+
14
+ alias :data :mongo_document
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,30 @@
1
+ module MongoBrowser
2
+ module Models
3
+ class Pager
4
+ PER_PAGE = 25
5
+
6
+ attr_reader :current_page
7
+ attr_reader :size
8
+
9
+ def initialize(current_page, size)
10
+ @size = size
11
+ @current_page = if current_page.to_i <= 0 then 1
12
+ else
13
+ [current_page.to_i, total_pages].min
14
+ end
15
+ end
16
+
17
+ def per_page
18
+ PER_PAGE
19
+ end
20
+
21
+ def offset
22
+ (current_page - 1) * per_page
23
+ end
24
+
25
+ def total_pages
26
+ (size.to_f / per_page).ceil
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,51 @@
1
+ module MongoBrowser
2
+ module Models
3
+ class Server
4
+
5
+ class << self
6
+ def current
7
+ new(MongoBrowser.mongodb_host, MongoBrowser.mongodb_port)
8
+ end
9
+ end
10
+
11
+ attr_reader :host
12
+ attr_reader :port
13
+
14
+ def initialize(host, port)
15
+ @host, @port = host, port
16
+ end
17
+
18
+ # Return database for the give name.
19
+ #
20
+ # @return MongoBrowser::Models::Database
21
+ def database(name)
22
+ Database.new(connection.db(name))
23
+ end
24
+
25
+ # Return a list of available database names.
26
+ #
27
+ # @return [String]
28
+ def database_names
29
+ connection.database_names.reject { |name| name == "admin" }
30
+ end
31
+
32
+ # Return a list of available databases.
33
+ #
34
+ # @return [MongoBrowser::Models::Database]
35
+ def databases
36
+ database_names.map { |name| database(name) }
37
+ end
38
+
39
+ # Get the build information for the current connection.
40
+ #
41
+ # @return [Hash]
42
+ def info
43
+ connection.server_info
44
+ end
45
+
46
+ def connection
47
+ @connection ||= Mongo::Connection.new(host, port)
48
+ end
49
+ end
50
+ end
51
+ end
@@ -1,3 +1,3 @@
1
1
  module MongoBrowser
2
- VERSION = "0.1.3"
2
+ VERSION = "0.2.0.rc2"
3
3
  end
data/lib/mongo_browser.rb CHANGED
@@ -2,24 +2,29 @@ require "mongo_browser/version"
2
2
 
3
3
  require "mongo"
4
4
  require "json"
5
- require "ap"
6
5
 
7
6
  module MongoBrowser
8
- DEFAULT_HOST = "127.0.0.1"
9
- DEFAULT_PORT = 27017
7
+ DEFAULT_MONGODB_HOST = "127.0.0.1"
8
+ DEFAULT_MONGODB_PORT = 27017
10
9
 
11
10
  class << self
12
11
  attr_writer :mongodb_host
13
12
  attr_writer :mongodb_port
14
13
 
15
14
  def mongodb_host
16
- @mongodb_host || DEFAULT_HOST
15
+ @mongodb_host || DEFAULT_MONGODB_HOST
17
16
  end
18
17
 
19
18
  def mongodb_port
20
- @mongodb_port || DEFAULT_PORT
19
+ @mongodb_port || DEFAULT_MONGODB_PORT
21
20
  end
22
21
  end
23
22
  end
24
23
 
24
+ require "mongo_browser/models/pager"
25
+ require "mongo_browser/models/server"
26
+ require "mongo_browser/models/database"
27
+ require "mongo_browser/models/collection"
28
+ require "mongo_browser/models/document"
29
+
25
30
  require "mongo_browser/application"
@@ -16,26 +16,19 @@ Gem::Specification.new do |gem|
16
16
  gem.version = MongoBrowser::VERSION
17
17
 
18
18
  gem.add_development_dependency("rdoc", "~> 3.12")
19
- gem.add_development_dependency("aruba", "~> 0.5.1")
20
19
  gem.add_development_dependency("rake", "~> 10.0.2")
21
20
 
21
+ gem.add_development_dependency("thin", "~> 1.5.0")
22
22
  gem.add_development_dependency("rspec", "~> 2.12.0")
23
- gem.add_development_dependency("capybara", "~> 1.1.3")
24
- gem.add_development_dependency("capybara-webkit", "~> 0.13.0")
25
- gem.add_development_dependency("launchy", "~> 2.1.2")
26
23
  gem.add_development_dependency("simplecov", "~> 0.7.1")
27
24
  gem.add_development_dependency("debugger", "~> 1.2.2")
28
25
 
29
- gem.add_dependency("mongo", "~> 1.7.0")
30
- gem.add_dependency("bson_ext", "~> 1.7.0")
31
- gem.add_dependency("methadone", "~> 1.2.2")
32
- gem.add_dependency("foreverb", "~> 0.3.2")
33
- gem.add_dependency("awesome_print", "~> 1.1.0")
26
+ gem.add_dependency("mongo", "~> 1.8.0")
27
+ gem.add_dependency("bson_ext", "~> 1.8.0")
28
+ gem.add_dependency("vegas", "~> 0.1.11")
34
29
 
35
30
  gem.add_dependency("sinatra", "~> 1.3.3")
36
31
  gem.add_dependency("sinatra-contrib", "~> 1.3.2")
37
- gem.add_dependency("sinatra-flash", "~> 0.3.0")
38
- gem.add_dependency("will_paginate-bootstrap", "~> 0.2.1")
39
32
  gem.add_dependency("json", "~> 1.7.5")
40
33
 
41
34
  gem.add_dependency("sprockets", "~> 2.8.1")
data/public/index.html ADDED
@@ -0,0 +1,47 @@
1
+ <!DOCTYPE html>
2
+ <html ng-app="mb">
3
+ <head>
4
+ <title>Mongo Browser</title>
5
+ <link href="/assets/application.css" rel="stylesheet" media="screen">
6
+ </head>
7
+ <body ng-controller="main">
8
+ <div class="navbar navbar navbar-fixed-top">
9
+ <div class="navbar-inner">
10
+ <div class="container">
11
+ <a class="brand" href="/">MongoBrowser</a>
12
+ <div class="nav-collapse collapse">
13
+ <ul ng-controller="breadcrumbs" class="nav breadcrumbs">
14
+ <li ng-show="showDatabase()">
15
+ <a href="{{database | collectionsPath}}">{{database.name}}</a>
16
+ </li>
17
+
18
+ <li ng-show="showCollection()">
19
+ <a href="{{collection | documentsPath}}">{{collection.name}}</a>
20
+ </li>
21
+ </ul>
22
+
23
+ <ul class="nav pull-right">
24
+ <li><a href="/server_info">Server Info</a></li>
25
+ <li><a>v. {{appVersion}}</a></li>
26
+ </ul>
27
+ </div>
28
+ </div>
29
+ </div>
30
+ </div>
31
+
32
+ <aside ng-controller="alerts" id="alerts">
33
+ <div ng-repeat="message in alertMessages" class="alert alert-{{message.type}}">
34
+ <button ng-click="disposeAlert(message.id)" type="button" class="close">×</button>
35
+ <strong>{{message.type}}</strong> <span>{{message.text}}</span>
36
+ </div>
37
+ </aside>
38
+
39
+ <section class="container fluid">
40
+ <section ng-view></section>
41
+ </section>
42
+
43
+ <!--<link type="text/css" rel="stylesheet" href="//fonts.googleapis.com/css?family=Rokkitt:400,700|Source+Code+Pro">-->
44
+ <script src="/assets/vendor.js"></script>
45
+ <script src="/assets/application.js"></script>
46
+ </body>
47
+ </html>
data/script/ci_all ADDED
@@ -0,0 +1,21 @@
1
+ #!/bin/bash
2
+
3
+ echo "Running rspec scenarios.."
4
+ ./script/ci_rspec
5
+ RSPEC_RESULT=$?
6
+
7
+ echo -e "\nRunning javascripts scenarios..\n"
8
+ ./script/ci_javascripts
9
+ JAVASCRIPTS_RESULT=$?
10
+
11
+ echo -e "\nRunning e2e scenarios..\n"
12
+ ./script/ci_e2e
13
+ E2E_RESULT=$?
14
+
15
+ if [ $RSPEC_RESULT -eq 1 -o $CUCUMBER_RESULT -eq 1 -o $JAVASCRIPTS_RESULT -eq 1 -o $E2E_RESULT -eq 1 ]; then
16
+ echo "error"
17
+ exit 1
18
+ else
19
+ echo "allOk"
20
+ exit 0
21
+ fi
data/script/ci_e2e ADDED
@@ -0,0 +1,11 @@
1
+ #!/bin/bash
2
+
3
+ # Start test backend instance
4
+ bundle exec thin start -R config-e2e.ru -e test -p 3001 -d
5
+
6
+ testacular start spec/javascripts/config/testacular-e2e.conf.js --single-run
7
+ RESULT=$?
8
+
9
+ # Kill test backend instance
10
+ kill `cat tmp/pids/thin.pid`
11
+ exit $RESULT
@@ -0,0 +1,4 @@
1
+ #!/bin/bash
2
+
3
+ grunt html2js
4
+ testacular start spec/javascripts/config/testacular.conf.js --single-run
data/script/ci_rspec ADDED
@@ -0,0 +1,3 @@
1
+ #!/bin/bash
2
+
3
+ bundle exec rspec spec/
@@ -1,65 +1,22 @@
1
1
  require "spec_helper"
2
2
 
3
- describe "Collections list", type: :request do
3
+ describe "Collections list", type: :request, js: true do
4
4
  before do
5
5
  visit "/"
6
6
 
7
7
  within("table.databases") { click_link "first_database" }
8
8
  end
9
9
 
10
- it "displays the breadcrumb" do
10
+ xit "displays the breadcrumb" do
11
11
  within ".breadcrumbs" do
12
12
  within "li:nth-child(1)" do
13
- expect(page).to have_link("first_database", href: "#")
13
+ expect(page).to have_link("first_database", href: "/databases/first_database/collections")
14
14
  end
15
15
  end
16
16
  end
17
17
 
18
- it "has a valid title" do
19
- within "h2" do
20
- expect(page).to have_content("first_database collections")
21
- end
22
- end
23
-
24
- it "displays all available collections for the selected database" do
25
- within "table" do
26
- expect(page).to have_link("first_collection")
27
- expect(page).to have_link("second_collection")
28
- expect(page).to have_link("third_collection")
29
- end
30
- end
31
-
32
- it "displays information about the database", js: true do
33
- click_link "Stats"
34
-
35
- within "table" do
36
- %w(db collection objects avgObjSize dataSize storageSize numExtents indexes indexSize nsSizeMB ok).each do |field|
37
- expect(page).to have_content(field)
38
- end
39
- end
40
- end
41
-
42
- describe "filtering", js: true do
43
- it "filters collections by name" do
44
- fill_in_filter("second")
45
-
46
- within "table.collections" do
47
- expect(page).to have_link("second_collection")
48
- expect(page).to_not have_link("first_collection")
49
- expect(page).to_not have_link("third_collection")
50
- end
51
- end
52
-
53
- it "displays a notification when nothing has been found" do
54
- fill_in_filter("fifth")
55
-
56
- expect(page).to_not have_css("table.collections")
57
- expect(page).to have_content("Nothing has been found.")
58
- end
59
- end
60
-
61
- describe "click on delete collection button", js: true do
62
- it "deletes a collection" do
18
+ describe "click on delete collection button" do
19
+ xit "deletes a collection" do
63
20
  click_delete_button_for("second_collection")
64
21
  confirm_dialog
65
22
 
@@ -88,7 +45,7 @@ describe "Collections list", type: :request do
88
45
  should_hide_the_table_and_display_a_notification
89
46
  end
90
47
 
91
- it "displays error message when the collection cannot be deleted" do
48
+ xit "displays error message when the collection cannot be deleted" do
92
49
  click_delete_button_for("system.indexes")
93
50
  confirm_dialog
94
51
 
@@ -1,6 +1,6 @@
1
1
  require "spec_helper"
2
2
 
3
- describe "Documents list", type: :request do
3
+ describe "Documents list", type: :request, js: true do
4
4
  let(:connection) { Fixtures.instance.connection }
5
5
 
6
6
  before do
@@ -11,19 +11,20 @@ describe "Documents list", type: :request do
11
11
  end
12
12
 
13
13
  shared_examples "breadcrumbs for documents list" do
14
- it "displays the breadcrumb" do
14
+ xit "displays the breadcrumb" do
15
15
  within ".breadcrumbs" do
16
16
  within "li:nth-child(1)" do
17
17
  expect(page).to have_link("first_database")
18
18
  end
19
19
 
20
20
  within "li:nth-child(2)" do
21
- expect(page).to have_link(current_collection_name, href: "#")
21
+ href = "/databases/first_database/collections/#{current_collection_name}/documents"
22
+ expect(page).to have_link(current_collection_name, href: href)
22
23
  end
23
24
  end
24
25
  end
25
26
 
26
- it "has a valid title" do
27
+ xit "has a valid title" do
27
28
  within "h2" do
28
29
  expect(page).to have_content("#{current_collection_name} documents")
29
30
  end
@@ -35,7 +36,7 @@ describe "Documents list", type: :request do
35
36
 
36
37
  include_examples "breadcrumbs for documents list"
37
38
 
38
- it "displays all documents for the selected collection" do
39
+ xit "displays all documents for the selected collection" do
39
40
  expect(page).to have_css("tr.document", count: 2)
40
41
 
41
42
  within "table" do
@@ -44,24 +45,24 @@ describe "Documents list", type: :request do
44
45
  end
45
46
  end
46
47
 
47
- it "displays information about the collection", js: true do
48
- click_link "Stats"
48
+ xit "displays information about the collection" do
49
+ click_link "Collection stats"
49
50
 
50
51
  within "table" do
51
- %w(ns count size avgObjSize storageSize numExtents nindexes lastExtentSize paddingFactor systemFlags userFlags totalIndexSize indexSizes ok).each do |field|
52
+ %w(ns count size avgObjSize storageSize numExtents nindexes lastExtentSize paddingFactor totalIndexSize indexSizes ok).each do |field|
52
53
  expect(page).to have_content(field)
53
54
  end
54
55
  end
55
56
  end
56
57
 
57
- describe "click on delete document button", js: true do
58
+ describe "click on delete document button" do
58
59
  let(:document) do
59
60
  database = connection.db("first_database")
60
61
  collection = database.collection(current_collection_name)
61
62
  collection.find_one(name: "This is the second sample record")
62
63
  end
63
64
 
64
- it "removes a document from the collection" do
65
+ xit "removes a document from the collection" do
65
66
  click_delete_button_for(document)
66
67
  confirm_dialog
67
68
 
@@ -76,8 +77,8 @@ describe "Documents list", type: :request do
76
77
  end
77
78
 
78
79
  def click_delete_button_for(document)
79
- database_row = find(:xpath, %Q{//table//tr/td[1][contains(text(), "#{document["_id"]}")]/..})
80
- within(database_row) { click_link "Delete" }
80
+ document_row = find("tr.id-#{document["_id"]}")
81
+ within(document_row) { click_link "Delete" }
81
82
  end
82
83
  end
83
84
  end
@@ -98,7 +99,7 @@ describe "Documents list", type: :request do
98
99
 
99
100
  include_examples "breadcrumbs for documents list"
100
101
 
101
- it "displays a pagination" do
102
+ xit "displays a pagination" do
102
103
  expect(page).to have_css("div.pagination", count: 2)
103
104
  within "div.pagination" do
104
105
  (1..3).each do |n|
@@ -107,7 +108,7 @@ describe "Documents list", type: :request do
107
108
  end
108
109
  end
109
110
 
110
- it "paginates documents" do
111
+ xit "paginates documents" do
111
112
  within "table.documents" do
112
113
  (0...25).each do |n|
113
114
  expect(page).to have_content("Document #{n}")
@@ -1,19 +1,19 @@
1
1
  require "spec_helper"
2
2
 
3
- describe "Server info", type: :request do
3
+ describe "Server info", type: :request, js: true do
4
4
  before do
5
5
  visit "/"
6
6
 
7
7
  within(".navbar") { click_link "Server Info" }
8
8
  end
9
9
 
10
- it "has a valid title" do
10
+ xit "has a valid title" do
11
11
  within "h2" do
12
12
  expect(page).to have_content("server info")
13
13
  end
14
14
  end
15
15
 
16
- it "displays information about the server" do
16
+ xit "displays information about the server" do
17
17
  within "table" do
18
18
  %w(version gitVersion sysInfo versionArray bits debug maxBsonObjectSize ok).each do |field|
19
19
  expect(page).to have_content(field)
@@ -0,0 +1,36 @@
1
+ describe "alerts", ->
2
+ beforeEach module("mb.controllers")
3
+
4
+ $scope = null
5
+ alerts = null
6
+
7
+ beforeEach inject ($injector, $rootScope, $controller) ->
8
+ $scope = $rootScope.$new()
9
+
10
+ alerts = $injector.get("alerts")
11
+
12
+ $controller "alerts",
13
+ $scope: $scope,
14
+ alerts: alerts
15
+
16
+ it "assings flash messages", ->
17
+ expect($scope.alertMessages).toBeDefined()
18
+ expect($scope.alertMessages).toEqual([])
19
+
20
+ alerts.info("Test message.")
21
+ expect($scope.alertMessages).toContain(id: 1, type: "info", text: "Test message.")
22
+
23
+ describe "#disposeAlert", ->
24
+ it "disposes an alert at the given index", ->
25
+ # Given
26
+ alerts.info("Information..")
27
+ alerts.error("Error..")
28
+ spyOn(alerts, "dispose").andCallThrough()
29
+
30
+ # When
31
+ $scope.disposeAlert(2)
32
+
33
+ # Then
34
+ expect(alerts.dispose).toHaveBeenCalledWith(2)
35
+ expect($scope.alertMessages).toContain(id: 1, type: "info", text: "Information..")
36
+ expect($scope.alertMessages).not.toContain(id: 2, type: "error", text: "Error..")
@@ -0,0 +1,28 @@
1
+ describe "breadcrumbs", ->
2
+ beforeEach module("mb.controllers")
3
+
4
+ $scope = null
5
+
6
+ beforeEach inject ($rootScope, $controller) ->
7
+ $scope = $rootScope.$new()
8
+
9
+ $controller "breadcrumbs",
10
+ $scope: $scope,
11
+
12
+ describe "#showDatabase", ->
13
+ it "return true when the database is available", ->
14
+ $scope.dbName = "foo"
15
+ expect($scope.showDatabase()).toBeTruthy()
16
+
17
+ it "return false when the database is not available", ->
18
+ $scope.dbName = null
19
+ expect($scope.showDatabase()).toBeFalsy()
20
+
21
+ describe "#showCollection", ->
22
+ it "return true when the database is available", ->
23
+ $scope.collectionName = "foo"
24
+ expect($scope.showCollection()).toBeTruthy()
25
+
26
+ it "return false when the database is not available", ->
27
+ $scope.collectionName = null
28
+ expect($scope.showCollection()).toBeFalsy()