mongo_browser 0.2.0.rc2 → 0.2.5

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 (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
@@ -22,8 +22,7 @@ describe "mb.dialogs", ->
22
22
  confirmationDialog(message: "This is a test message")
23
23
 
24
24
  # Then
25
- expect(dialogsHandler.confirm).toHaveBeenCalledWith \
26
- "This is a test message",
25
+ expect(dialogsHandler.confirm).toHaveBeenCalledWith "This is a test message",
27
26
  jasmine.any(Function)
28
27
 
29
28
  describe "when the dialog was confirmed", ->
@@ -14,7 +14,6 @@ describe "mb.pager", ->
14
14
  expect(p.outerWindow).toEqual(0)
15
15
 
16
16
  describe "windowedPageNumbers", ->
17
-
18
17
  it "calculates windowed visible links", inject (pager) ->
19
18
  prepare = pager(page: 6, totalPages: 11, innerWindow: 1, outerWindow: 1)
20
19
  expect(prepare.windowedPageNumbers()).toEqual [1, 2, null, 5, 6, 7, null, 10, 11]
@@ -0,0 +1,65 @@
1
+ describe "mb.spinner", ->
2
+ beforeEach module("mb.spinner")
3
+
4
+ describe "httpRequestTracker", ->
5
+ $http = null
6
+ httpRequestTracker = null
7
+
8
+ beforeEach inject ($injector) ->
9
+ httpRequestTracker = $injector.get("httpRequestTracker")
10
+ $http = $injector.get("$http")
11
+
12
+ describe "when no requests is progress", ->
13
+ it "does not report pending requests", ->
14
+ expect(httpRequestTracker.hasPendingRequests()).toBeFalsy()
15
+
16
+ describe "when requests are in progress", ->
17
+ beforeEach -> $http.pendingRequests.push({})
18
+
19
+ it "reports pending requests", ->
20
+ expect(httpRequestTracker.hasPendingRequests()).toBeTruthy()
21
+
22
+ describe "controller", ->
23
+ httpRequestTracker = null
24
+ controller = null
25
+ $scope = null
26
+
27
+ beforeEach inject ($injector, $rootScope, $controller) ->
28
+ httpRequestTracker = $injector.get("httpRequestTracker")
29
+ $scope = $rootScope.$new()
30
+ controller = $controller "spinner",
31
+ $scope: $scope
32
+
33
+ describe "#showSpinner", ->
34
+ describe "when there is a pending request", ->
35
+ beforeEach ->
36
+ spyOn(httpRequestTracker, "hasPendingRequests").andReturn(true)
37
+
38
+ it "returns true", ->
39
+ expect($scope.showSpinner()).toBeTruthy()
40
+
41
+ describe "otherwise", ->
42
+ beforeEach ->
43
+ spyOn(httpRequestTracker, "hasPendingRequests").andReturn(false)
44
+
45
+ it "returns false", ->
46
+ expect($scope.showSpinner()).toBeFalsy()
47
+
48
+ describe "directive", ->
49
+ element = null
50
+
51
+ beforeEach inject ($compile, $rootScope) ->
52
+ $scope = $rootScope
53
+ $scope.showSpinner = -> false
54
+
55
+ element = angular.element """
56
+ <spinner></spinner>
57
+ """
58
+ $compile(element)($scope)
59
+ $scope.$digest()
60
+
61
+ it "renders the spinner", ->
62
+ img = element.find("img")
63
+
64
+ expect(img.length).toBe(1)
65
+ expect(img.attr("src")).toEqual("/assets/ajax-loader.gif")
@@ -1,7 +1,7 @@
1
1
  describe "mb.tableFilter", ->
2
2
  beforeEach module("mb.tableFilter")
3
3
 
4
- describe "tableFilter controller", ->
4
+ describe "controller", ->
5
5
  $scope = null
6
6
 
7
7
  beforeEach inject ($controller, $rootScope) ->
@@ -25,21 +25,21 @@ describe "mb.tableFilter", ->
25
25
 
26
26
  expect($scope.value).toEqual("")
27
27
 
28
- describe "tableFilter", ->
28
+ describe "directive", ->
29
29
  $scope = null
30
30
  element = null
31
31
 
32
- beforeEach module("app/assets/templates/table_filter.html")
32
+ beforeEach module("public/ng/templates/table_filter.html")
33
33
 
34
34
  beforeEach inject ($rootScope, $compile) ->
35
35
  $scope = $rootScope
36
36
 
37
- tpl = """
38
- <div>
39
- <table-filter value="filterValue" placeholder="Enter database name"></table-filter>
40
- </div>
41
- """
42
- element = $compile(tpl)($scope)
37
+ element = angular.element """
38
+ <div>
39
+ <table-filter value="filterValue" placeholder="Enter database name"></table-filter>
40
+ </div>
41
+ """
42
+ $compile(element)($scope)
43
43
  $scope.$digest()
44
44
 
45
45
  it "sets the valid placeholder", ->
@@ -0,0 +1,99 @@
1
+ describe "reources", ->
2
+ beforeEach module("mb.resources")
3
+
4
+ $httpBackend = null
5
+ beforeEach inject ($injector) ->
6
+ $httpBackend = $injector.get("$httpBackend")
7
+
8
+ afterEach ->
9
+ $httpBackend.verifyNoOutstandingExpectation()
10
+ $httpBackend.verifyNoOutstandingRequest()
11
+
12
+ describe "Database", ->
13
+ Database = null
14
+ beforeEach inject ($injector) ->
15
+ Database = $injector.get("Database")
16
+
17
+ it "is defined", ->
18
+ expect(Database).toBeDefined()
19
+
20
+ describe "#query", ->
21
+ it "queries for all databases", ->
22
+ $httpBackend.whenGET("/api/databases").respond([])
23
+ Database.query()
24
+ $httpBackend.flush()
25
+
26
+ describe "#$stats", ->
27
+ it "queries for database stats", ->
28
+ $httpBackend.whenGET("/api/databases/test_database/stats").respond({})
29
+
30
+ database = new Database(name: "test_database")
31
+ database.$stats()
32
+
33
+ $httpBackend.flush()
34
+
35
+ describe "Collection", ->
36
+ Collection = null
37
+ beforeEach inject ($injector) ->
38
+ Collection = $injector.get("Collection")
39
+ $httpBackend.whenGET("/api/databases/test_database/collections")
40
+ .respond([])
41
+
42
+ it "is defined", ->
43
+ expect(Collection).toBeDefined()
44
+
45
+ describe "#query", ->
46
+ it "queries for all collections", ->
47
+ Collection.query(dbName: "test_database")
48
+ $httpBackend.flush()
49
+
50
+ describe "#$stats", ->
51
+ it "queries for collection stats", ->
52
+ fakeResponse = foo: "bar"
53
+ $httpBackend.whenGET("/api/databases/test_database/collections/test_collection/stats")
54
+ .respond(fakeResponse)
55
+
56
+ collection = new Collection(dbName: "test_database", name: "test_collection")
57
+ collection.$stats (data) ->
58
+ expect(angular.equals(data, fakeResponse)).toBeTruthy()
59
+
60
+ $httpBackend.flush()
61
+
62
+ describe "Document", ->
63
+ Document = null
64
+ beforeEach inject ($injector) ->
65
+ Document = $injector.get("Document")
66
+ $httpBackend.whenGET("/api/databases/test_database/collections/test_collection/documents")
67
+ .respond([])
68
+
69
+ it "is defined", ->
70
+ expect(Document).toBeDefined()
71
+
72
+ describe "#query", ->
73
+ it "queries for all documents", ->
74
+ Document.query(dbName: "test_database", collectionName: "test_collection")
75
+ $httpBackend.flush()
76
+
77
+ describe "#$query", ->
78
+ it "queries for all documents", ->
79
+ document = new Document(dbName: "test_database", collectionName: "test_collection")
80
+ document.$query()
81
+ $httpBackend.flush()
82
+
83
+ describe "$get", ->
84
+ it "gets a document", ->
85
+ $httpBackend.whenGET("/api/databases/test_database/collections/test_collection/documents/document-id").respond([])
86
+
87
+ document = new Document(dbName: "test_database", collectionName: "test_collection", id: "document-id")
88
+ document.$get()
89
+
90
+ $httpBackend.flush()
91
+
92
+ describe "$delete", ->
93
+ it "deletes a document", ->
94
+ $httpBackend.whenDELETE("/api/databases/test_database/collections/test_collection/documents/document-id").respond([])
95
+
96
+ document = new Document(dbName: "test_database", collectionName: "test_collection", id: "document-id")
97
+ document.$delete()
98
+
99
+ $httpBackend.flush()
@@ -1,83 +1,43 @@
1
1
  describe "services", ->
2
+ beforeEach module("mb.alerts")
2
3
  beforeEach module("mb.services")
4
+ beforeEach module("mocks")
3
5
 
4
- describe "alerts", ->
5
- it "is defined", inject (alerts) ->
6
- expect(alerts).toBeDefined()
6
+ describe "httpErrorsInterceptor", ->
7
+ $http = null
8
+ promise = null
7
9
 
8
- describe "#nextId", ->
9
- it "return the next id for the new flash message", inject (alerts) ->
10
- expect(alerts.nextId()).toEqual(1)
11
- _(4).times -> alerts.nextId()
12
- expect(alerts.nextId()).toEqual(6)
10
+ interceptor = null
11
+ alerts = null
12
+ $q = null
13
13
 
14
- describe "#push", ->
15
- beforeEach inject (alerts) ->
16
- spyOn(alerts, "delayedDispose")
14
+ errorHandler = null
17
15
 
18
- it "returns an id for the new flash message", inject (alerts) ->
19
- expect(alerts.push("info", "Test..")).toEqual(1)
20
- expect(alerts.delayedDispose).toHaveBeenCalledWith(1)
16
+ beforeEach inject ($injector) ->
17
+ $http = $injector.get("$http")
18
+ interceptor = $injector.get("httpErrorsInterceptor")
19
+ alerts = $injector.get("alerts")
20
+ $q = $injector.get("$q")
21
21
 
22
- expect(alerts.push("error", "Test error..")).toEqual(2)
23
- expect(alerts.delayedDispose).toHaveBeenCalledWith(2)
22
+ promise = then: jasmine.createSpy("then").andReturn({})
23
+ interceptor(promise)
24
24
 
25
- describe "#info", ->
26
- it "pushesh the given message", inject (alerts) ->
27
- # Given
28
- testMessage = "This is a test message!"
29
- otherTestMessage = "This is a second test message!"
25
+ spyOn(alerts, "push")
26
+ spyOn($q, "reject")
27
+ errorHandler = promise.then.mostRecentCall.args[1]
30
28
 
31
- # When
32
- alerts.info(testMessage)
33
- expect(alerts.delayedDispose).toHaveBeenCalledWith(1)
29
+ it "alerts an error on failed http request", ->
30
+ httpResponse = status: 500
31
+ errorHandler(httpResponse)
34
32
 
35
- alerts.info(otherTestMessage)
36
- expect(alerts.delayedDispose).toHaveBeenCalledWith(2)
33
+ expect(alerts.push).toHaveBeenCalledWith("error", "Unexpected HTTP error")
34
+ expect($q.reject).toHaveBeenCalledWith(httpResponse)
37
35
 
38
- # Then
39
- expect(alerts.messages).toContain(id: 1, type: "info", text: testMessage)
40
- expect(alerts.messages).toContain(id: 2, type: "info", text: otherTestMessage)
36
+ describe "when http response includes an error message", ->
37
+ it "alerts this error", ->
38
+ httpResponse = status: 500, data:
39
+ error: "The custom message"
40
+ errorHandler(httpResponse)
41
41
 
42
- describe "#error", ->
43
- it "pushesh the given message", inject (alerts) ->
44
- # Given
45
- testMessage = "This is a test message!"
46
-
47
- # When
48
- alerts.error(testMessage)
49
- expect(alerts.delayedDispose).toHaveBeenCalledWith(1)
50
-
51
- # Then
52
- expect(alerts.messages).toContain(id: 1, type: "error", text: testMessage)
53
-
54
- describe "#dispose", ->
55
- it "removes a message with the given id", inject (alerts) ->
56
- # Given
57
- alerts.info("First message")
58
- alerts.info("Second message")
59
- alerts.info("Third message")
60
- alerts.error("Error message")
61
-
62
- # When
63
- alerts.dispose(2)
64
-
65
- # Then
66
- expect(alerts.messages).toContain(id: 1, type: "info", text: "First message")
67
- expect(alerts.messages).not.toContain(id: 2, type: "info", text: "Second message")
68
- expect(alerts.messages).toContain(id: 3, type: "info", text: "Third message")
69
- expect(alerts.messages).toContain(id: 4, type: "error", text: "Error message")
70
-
71
- describe "#delayedDispose", ->
72
- it "removes a message after the given time", inject (alerts, $timeout) ->
73
- # Given
74
- alerts.info("First message")
75
-
76
- # When
77
- alerts.delayedDispose(1)
78
- expect(alerts.messages).toContain(id: 1, type: "info", text: "First message")
79
-
80
- $timeout.flush()
81
-
82
- # Then
83
- expect(alerts.messages).toEqual([])
42
+ expect(alerts.push).toHaveBeenCalledWith("error", "The custom message")
43
+ expect($q.reject).toHaveBeenCalledWith(httpResponse)
@@ -13,7 +13,7 @@ browsers = ["PhantomJS"];
13
13
  autoWatch = false;
14
14
  singleRun = true;
15
15
 
16
- urlRoot = '/__testacular/';
16
+ urlRoot = '/__karma__/';
17
17
  proxies = {
18
18
  "/": "http://localhost:3001/"
19
19
  };
@@ -13,9 +13,8 @@ files = [
13
13
  "vendor/assets/javascripts/*.js",
14
14
 
15
15
  // The app
16
- "app/assets/javascripts/app/controllers.js.coffee",
17
- "app/assets/javascripts/app/**/*.js.coffee",
18
16
  "app/assets/javascripts/application.js.coffee",
17
+ "app/assets/javascripts/app/**/*.js.coffee",
19
18
 
20
19
  // Specs
21
20
  "spec/javascripts/lib/angular-mocks.js",
@@ -25,7 +24,7 @@ files = [
25
24
  "spec/javascripts/**/*_spec.js.coffee",
26
25
 
27
26
  // Templates
28
- "app/assets/javascripts/templates/*.html.js"
27
+ "app/assets/javascripts/compiled_templates/*.html.js"
29
28
  ];
30
29
 
31
30
  preprocessors = {
@@ -0,0 +1,12 @@
1
+ describe "collection stats page", ->
2
+
3
+ beforeEach ->
4
+ browser().navigateTo("/e2e/load_fixtures")
5
+ browser().navigateTo("/")
6
+
7
+ element("table.databases tbody tr a:contains('first_database')").click()
8
+ element("table.collections tbody tr a:contains('first_collection')").click()
9
+ element("a.btn:contains('Collection stats')").click()
10
+
11
+ it "displays database stats", ->
12
+ expect(repeater("table tbody tr").count()).toBeGreaterThan(0)
@@ -1,49 +1,88 @@
1
1
  describe "collections list page", ->
2
+ collectionsList = null
3
+
2
4
  beforeEach ->
3
5
  browser().navigateTo("/e2e/load_fixtures")
4
6
  browser().navigateTo("/")
5
7
 
6
8
  element("table.databases tbody tr a:contains('first_database')").click()
9
+ collectionsList = repeater("table.collections tbody tr")
7
10
 
8
11
  it "navigates to the valid url", ->
9
12
  expect(browser().location().url()).toBe("/databases/first_database/collections")
10
13
 
14
+ it "shows the breadcrumbs", ->
15
+ link = element(".container a.brand")
16
+ expect(link.text()).toEqual("Mongo Browser")
17
+ expect(link.attr("href")).toEqual("/")
18
+
19
+ dbLink = element(".container .breadcrumbs li:nth-child(1) a")
20
+ expect(dbLink.text()).toEqual("first_database")
21
+ expect(dbLink.attr("href")).toEqual("/databases/first_database/collections")
22
+
11
23
  it "displays a valid section title", ->
12
24
  title = element("h2").text()
13
25
  expect(title).toEqual("first_database collections")
14
26
 
15
27
  it "displays available collections ordered by name", ->
16
- expect(repeater("table.collections tbody tr").column("collection.name"))
17
- .toEqual(["first_collection", "second_collection", "system.indexes", "third_collection"])
28
+ expect(collectionsList.column("collection.name"))
29
+ .toEqual(["first_collection", "second_collection", "system.indexes", "third_collection"])
18
30
 
19
31
  it "filters the collections list", ->
20
32
  input("value").enter("")
21
- expect(repeater("table.collections tbody tr").count()).toBe(4)
22
- expect(repeater("table.collections tbody tr").column("collection.name"))
23
- .toEqual(["first_collection", "second_collection", "system.indexes", "third_collection"])
33
+ expect(collectionsList.count()).toBe(4)
34
+ expect(collectionsList.column("collection.name"))
35
+ .toEqual(["first_collection", "second_collection", "system.indexes", "third_collection"])
24
36
 
25
37
  input("value").enter("first")
26
- expect(repeater("table.collections tbody tr").count()).toBe(1)
27
- expect(repeater("table.collections tbody tr").column("collection.name"))
28
- .toEqual(["first_collection"])
38
+ expect(collectionsList.count()).toBe(1)
39
+ expect(collectionsList.column("collection.name"))
40
+ .toEqual(["first_collection"])
29
41
 
30
42
  input("value").enter("second")
31
- expect(repeater("table.collections tbody tr").count()).toBe(1)
32
- expect(repeater("table.collections tbody tr").column("collection.name"))
33
- .toEqual(["second_collection"])
43
+ expect(collectionsList.count()).toBe(1)
44
+ expect(collectionsList.column("collection.name"))
45
+ .toEqual(["second_collection"])
34
46
 
35
47
  input("value").enter("collection")
36
- expect(repeater("table.collections tbody tr").count()).toBe(3)
37
- expect(repeater("table.collections tbody tr").column("collection.name"))
38
- .toEqual(["first_collection", "second_collection", "third_collection"])
48
+ expect(collectionsList.count()).toBe(3)
49
+ expect(collectionsList.column("collection.name"))
50
+ .toEqual(["first_collection", "second_collection", "third_collection"])
39
51
 
40
52
  input("value").enter("not existing")
41
- expect(repeater("table.collections tbody tr").count()).toBe(0)
42
- expect(element(".filter.alert:visible").text()).toMatch(/Nothing has been found./)
53
+ expect(collectionsList.count()).toBe(0)
54
+ expect(element(".alert:visible").text()).toMatch(/Nothing has been found./)
43
55
 
44
56
  element("button:contains('Clear')").click()
45
- expect(repeater("table.collections tbody tr").count()).toBe(4)
57
+ expect(collectionsList.count()).toBe(4)
58
+
59
+ describe "delete a collection", ->
60
+ deleteCollection = (name) ->
61
+ element("table.collections tbody tr:contains('#{name}') td:last-child a:contains('Delete')")
62
+ .click()
63
+
64
+ beforeEach ->
65
+ deleteCollection("third_collection")
66
+ expect(element("div.modal .modal-body").text())
67
+ .toContain("Deleting third_collection. Are you sure?")
68
+
69
+ describe "when the dialog was disposed", ->
70
+ beforeEach -> disposeDialog()
71
+
72
+ it "does nothig", ->
73
+ expect(collectionsList.count()).toBe(4)
74
+ expect(collectionsList.column("collection.name"))
75
+ .toEqual(["first_collection", "second_collection", "system.indexes", "third_collection"])
76
+
77
+ describe "when the dialog was confirmed", ->
78
+ beforeEach -> confirmDialog()
79
+
80
+ it "shows the alert", ->
81
+ expect(repeater("aside#alerts .alert").count()).toBe(1)
82
+ expect(repeater("aside#alerts .alert").column("message.text"))
83
+ .toContain("Collection third_collection has been deleted.")
46
84
 
47
- it "displays a tab with database stats", ->
48
- element(".tabbable a:contains('Database stats')").click()
49
- expect(repeater("table tbody tr").count()).toBeGreaterThan(0)
85
+ it "deletes a database", ->
86
+ expect(collectionsList.count()).toBe(3)
87
+ expect(collectionsList.column("collection.name"))
88
+ .toEqual(["first_collection", "second_collection", "system.indexes"])