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.
- data/.gitignore +3 -1
- data/.rspec +1 -1
- data/.travis.yml +6 -1
- data/CHANGELOG.md +15 -0
- data/{grunt.js → Gruntfile.js} +10 -8
- data/Procfile +1 -0
- data/README.md +44 -2
- data/Rakefile +1 -12
- data/app/assets/images/ajax-loader.gif +0 -0
- data/app/assets/javascripts/app/controllers/{breadcrumbs.js.coffee → breadcrumbs_controller.js.coffee} +4 -7
- data/app/assets/javascripts/app/controllers/collections/index_controller.js.coffee +38 -0
- data/app/assets/javascripts/app/controllers/collections/stats_controller.js.coffee +17 -0
- data/app/assets/javascripts/app/controllers/{databases.js.coffee → databases/index_controller.js.coffee} +11 -15
- data/app/assets/javascripts/app/controllers/databases/stats_controller.js.coffee +15 -0
- data/app/assets/javascripts/app/controllers/documents/index_controller.js.coffee +54 -0
- data/app/assets/javascripts/app/controllers/documents/show_controller.js.coffee +38 -0
- data/app/assets/javascripts/app/controllers/main_controller.js.coffee +15 -0
- data/app/assets/javascripts/app/controllers/servers/show_controller.js.coffee +17 -0
- data/app/assets/javascripts/app/directives.js.coffee +23 -0
- data/app/assets/javascripts/app/filters.js.coffee +14 -1
- data/app/assets/javascripts/app/modules/alerts.js.coffee +58 -0
- data/app/assets/javascripts/app/modules/pager.js.coffee +2 -2
- data/app/assets/javascripts/app/modules/spinner.js.coffee +29 -0
- data/app/assets/javascripts/app/modules/table_filter.js.coffee +4 -4
- data/app/assets/javascripts/app/resources.js.coffee +14 -8
- data/app/assets/javascripts/app/services.js.coffee +11 -33
- data/app/assets/javascripts/application.js.coffee +62 -34
- data/app/assets/javascripts/application.test.js.coffee +5 -0
- data/app/assets/javascripts/compiled_templates.js.coffee +1 -0
- data/app/assets/javascripts/vendor.js.coffee +0 -1
- data/app/assets/stylesheets/application.css.scss +36 -18
- data/{public/index.html → app/views/index.erb} +8 -8
- data/bin/mongo_browser +2 -13
- data/config.ru +3 -1
- data/lib/mongo_browser.rb +1 -0
- data/lib/mongo_browser/api.rb +11 -0
- data/lib/mongo_browser/api/collections.rb +34 -0
- data/lib/mongo_browser/api/databases.rb +32 -0
- data/lib/mongo_browser/api/documents.rb +37 -0
- data/lib/mongo_browser/api/mongo.rb +41 -0
- data/lib/mongo_browser/application.rb +8 -174
- data/lib/mongo_browser/application/development.rb +32 -0
- data/lib/mongo_browser/cli.rb +48 -0
- data/lib/mongo_browser/entities.rb +43 -0
- data/lib/mongo_browser/models/collection.rb +7 -12
- data/lib/mongo_browser/models/document.rb +5 -1
- data/lib/mongo_browser/models/pager.rb +22 -9
- data/lib/mongo_browser/version.rb +1 -1
- data/mongo_browser.gemspec +22 -15
- data/package.json +30 -0
- data/public/ng/templates/alerts.html +6 -0
- data/public/ng/templates/collections/index.html +39 -0
- data/public/ng/templates/collections/stats.html +18 -0
- data/public/ng/templates/databases/index.html +35 -0
- data/public/ng/templates/databases/stats.html +18 -0
- data/public/ng/templates/documents/index.html +40 -0
- data/public/ng/templates/documents/show.html +17 -0
- data/{app/assets → public/ng}/templates/pager.html +0 -0
- data/{app/assets/templates/server_info.html → public/ng/templates/server/show.html} +1 -1
- data/{app/assets → public/ng}/templates/table_filter.html +0 -0
- data/script/ci_all +5 -1
- data/script/ci_e2e +5 -2
- data/script/ci_javascripts +1 -1
- data/script/ci_rspec +1 -1
- data/spec/javascripts/app/controllers/{breadcrumbs_spec.js.coffee → breadcrumbs_controller_spec.js.coffee} +1 -1
- data/spec/javascripts/app/controllers/collections/index_controller_spec.js.coffee +95 -0
- data/spec/javascripts/app/controllers/collections/stats_controller_spec.js.coffee +34 -0
- data/spec/javascripts/app/controllers/databases/index_controller_spec.js.coffee +93 -0
- data/spec/javascripts/app/controllers/databases/stats_controller_spec.js.coffee +30 -0
- data/spec/javascripts/app/controllers/documents/index_controller_spec.js.coffee +108 -0
- data/spec/javascripts/app/controllers/documents/show_controller_spec.js.coffee +94 -0
- data/spec/javascripts/app/controllers/{main_spec.js.coffee → main_controller_spec.js.coffee} +2 -2
- data/spec/javascripts/app/controllers/{server_info_spec.js.coffee → server/show_controller_spec.js.coffee} +5 -6
- data/spec/javascripts/app/directives_spec.js.coffee +108 -24
- data/spec/javascripts/app/filters_spec.js.coffee +31 -5
- data/spec/javascripts/app/modules/alerts_spec.js.coffee +138 -0
- data/spec/javascripts/app/modules/dialogs_spec.js.coffee +1 -2
- data/spec/javascripts/app/modules/pager_spec.js.coffee +0 -1
- data/spec/javascripts/app/modules/spinner_spec.js.coffee +65 -0
- data/spec/javascripts/app/modules/table_filter_spec.js.coffee +9 -9
- data/spec/javascripts/app/resources_spec.js.coffee +99 -0
- data/spec/javascripts/app/services_spec.js.coffee +31 -71
- data/spec/javascripts/config/{testacular-e2e.conf.js → karma-e2e.conf.js} +1 -1
- data/spec/javascripts/config/{testacular.conf.js → karma.conf.js} +2 -3
- data/spec/javascripts/e2e/collection_stats_scenario.js.coffee +12 -0
- data/spec/javascripts/e2e/collections_scenario.js.coffee +59 -20
- data/spec/javascripts/e2e/database_stats_scenario.js.coffee +11 -0
- data/spec/javascripts/e2e/databases_scenario.js.coffee +37 -36
- data/spec/javascripts/e2e/document_show_scenario.js.coffee +31 -0
- data/spec/javascripts/e2e/documents_pagination_scenario.js.coffee +33 -0
- data/spec/javascripts/e2e/documents_scenario.js.coffee +43 -4
- data/spec/javascripts/e2e/server_info_scenario.js.coffee +8 -2
- data/spec/javascripts/helpers/mocks.js.coffee +2 -0
- data/spec/javascripts/helpers_e2e/dsl.js.coffee +20 -0
- data/spec/javascripts/lib/angular-mocks.js +64 -16
- data/spec/javascripts/lib/angular-scenario.js +724 -561
- data/spec/javascripts/runner.html +5 -5
- data/spec/lib/api/collections_spec.rb +62 -0
- data/spec/lib/api/databases_spec.rb +58 -0
- data/spec/lib/api/documents_spec.rb +135 -0
- data/spec/lib/api/mongo_spec.rb +27 -0
- data/spec/lib/cli_spec.rb +19 -0
- data/spec/lib/entities_spec.rb +39 -0
- data/spec/lib/models/collection_spec.rb +16 -10
- data/spec/lib/models/database_spec.rb +4 -4
- data/spec/lib/models/document_spec.rb +5 -5
- data/spec/lib/models/pager_spec.rb +20 -11
- data/spec/spec_helper.rb +7 -15
- data/spec/support/api_example_group.rb +45 -0
- data/spec/support/fixtures.rb +10 -6
- data/spec/support/matchers/expose.rb +18 -0
- data/vendor/assets/javascripts/angular/angular-bootstrap.js +1 -1
- data/vendor/assets/javascripts/angular/angular-resource.js +78 -56
- data/vendor/assets/javascripts/angular/angular-sanitize.js +3 -1
- data/vendor/assets/javascripts/angular/angular.js +720 -404
- metadata +323 -183
- data/app/assets/javascripts/app.js.coffee +0 -8
- data/app/assets/javascripts/app/controllers.js.coffee +0 -2
- data/app/assets/javascripts/app/controllers/alerts.js.coffee +0 -12
- data/app/assets/javascripts/app/controllers/collections.js.coffee +0 -40
- data/app/assets/javascripts/app/controllers/documents.js.coffee +0 -49
- data/app/assets/javascripts/app/controllers/main.js.coffee +0 -10
- data/app/assets/javascripts/app/controllers/server_info.js.coffee +0 -14
- data/app/assets/javascripts/templates.js.coffee +0 -1
- data/app/assets/javascripts/templates/.gitkeep +0 -0
- data/app/assets/templates/collections.html +0 -53
- data/app/assets/templates/databases.html +0 -32
- data/app/assets/templates/documents.html +0 -45
- data/config-e2e.ru +0 -20
- data/spec/features/collections_list_spec.rb +0 -64
- data/spec/features/documents_list_spec.rb +0 -139
- data/spec/features/server_info_spec.rb +0 -23
- data/spec/javascripts/app/controllers/alerts_spec.js.coffee +0 -36
- data/spec/javascripts/app/controllers/collections_spec.js.coffee +0 -78
- data/spec/javascripts/app/controllers/databases_spec.js.coffee +0 -55
- data/spec/javascripts/app/controllers/documents_spec.js.coffee +0 -62
- data/spec/javascripts/helpers_e2e/app_element.js.coffee +0 -6
- data/spec/support/feature_example_group.rb +0 -53
- data/spec/support/matchers/have_flash_message.rb +0 -16
- data/spec/support/mongod.rb +0 -91
- data/spec/support/mongodb.conf +0 -47
|
@@ -15,11 +15,11 @@
|
|
|
15
15
|
<script type="text/javascript" src="/assets/app.js"></script>
|
|
16
16
|
|
|
17
17
|
<!-- Load specs -->
|
|
18
|
-
<script type="text/javascript" src="/assets/
|
|
18
|
+
<script type="text/javascript" src="/assets/compiled_templates.js"></script>
|
|
19
19
|
<script type="text/javascript" src="/_specs/spec.js"></script>
|
|
20
20
|
|
|
21
21
|
<script type="text/javascript">
|
|
22
|
-
(function
|
|
22
|
+
(function() {
|
|
23
23
|
var jasmineEnv = jasmine.getEnv();
|
|
24
24
|
jasmineEnv.updateInterval = 1000;
|
|
25
25
|
|
|
@@ -27,14 +27,14 @@
|
|
|
27
27
|
|
|
28
28
|
jasmineEnv.addReporter(trivialReporter);
|
|
29
29
|
|
|
30
|
-
jasmineEnv.specFilter = function
|
|
30
|
+
jasmineEnv.specFilter = function(spec) {
|
|
31
31
|
return trivialReporter.specFilter(spec);
|
|
32
32
|
};
|
|
33
33
|
|
|
34
34
|
var currentWindowOnload = window.onload;
|
|
35
35
|
|
|
36
|
-
window.onload = function
|
|
37
|
-
if
|
|
36
|
+
window.onload = function() {
|
|
37
|
+
if(currentWindowOnload) {
|
|
38
38
|
currentWindowOnload();
|
|
39
39
|
}
|
|
40
40
|
execJasmine();
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
require "spec_helper"
|
|
2
|
+
|
|
3
|
+
describe MongoBrowser::API::Collections do
|
|
4
|
+
include ApiExampleGroup
|
|
5
|
+
|
|
6
|
+
def app
|
|
7
|
+
described_class
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
describe "collections" do
|
|
11
|
+
let(:db_name) { "first_database" }
|
|
12
|
+
|
|
13
|
+
describe_endpoint :get, "/databases/:db_name/collections" do
|
|
14
|
+
it { should be_successful }
|
|
15
|
+
|
|
16
|
+
describe "returned collections" do
|
|
17
|
+
subject(:collections) { JSON.parse(response.body) }
|
|
18
|
+
|
|
19
|
+
it { should_not be_empty }
|
|
20
|
+
it("contains all collections") { expect(collections).to have(4).items }
|
|
21
|
+
|
|
22
|
+
describe "a collection" do
|
|
23
|
+
subject(:collection) { collections.find { |collection| collection["name"] == "first_collection" } }
|
|
24
|
+
|
|
25
|
+
it { should_not be_nil }
|
|
26
|
+
it("contains database name") { expect(collection["dbName"]).to eq("first_database") }
|
|
27
|
+
it("contains collection name") { expect(collection["name"]).to eq("first_collection") }
|
|
28
|
+
it("contains number of documents") { expect(collection["size"]).to eq(2) }
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
describe_endpoint :get, "/databases/:db_name/collections/:collection_name/stats" do
|
|
34
|
+
let(:collection_name) { "first_collection" }
|
|
35
|
+
|
|
36
|
+
it { should be_successful }
|
|
37
|
+
|
|
38
|
+
it "returns stats for the collection with the given name" do
|
|
39
|
+
stats = JSON.parse(response.body)
|
|
40
|
+
expect(stats).not_to be_empty
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
describe_endpoint :delete, "/databases/:db_name/collections/:collection_name" do
|
|
45
|
+
let(:collection_name) { "first_collection" }
|
|
46
|
+
|
|
47
|
+
before do
|
|
48
|
+
expect { do_request }.to \
|
|
49
|
+
change { server.database(db_name).collections.count }.by(-1)
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
it { should be_successful }
|
|
53
|
+
|
|
54
|
+
it "deletes a collection with the given name" do
|
|
55
|
+
data = JSON.parse(response.body)
|
|
56
|
+
expect(data["success"]).to be_true
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
end
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
require "spec_helper"
|
|
2
|
+
|
|
3
|
+
describe MongoBrowser::API::Databases do
|
|
4
|
+
include ApiExampleGroup
|
|
5
|
+
|
|
6
|
+
def app
|
|
7
|
+
described_class
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
describe "databases" do
|
|
11
|
+
describe_endpoint :get, "/databases" do
|
|
12
|
+
it { should be_successful }
|
|
13
|
+
|
|
14
|
+
describe "returned databases" do
|
|
15
|
+
subject(:data) { JSON.parse(response.body) }
|
|
16
|
+
|
|
17
|
+
it { should_not be_empty }
|
|
18
|
+
it("contains all databases") { should have_at_least(3).items }
|
|
19
|
+
|
|
20
|
+
describe "a database" do
|
|
21
|
+
subject(:database) { data.find { |db| db["name"] == "first_database" } }
|
|
22
|
+
|
|
23
|
+
it { should_not be_nil }
|
|
24
|
+
it("contains name") { expect(database["name"]).to eq("first_database") }
|
|
25
|
+
it("contains number of collections") { expect(database["count"]).to eq(4) }
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
describe_endpoint :delete, "/databases/:db_name" do
|
|
31
|
+
let(:db_name) { "first_database" }
|
|
32
|
+
|
|
33
|
+
before do
|
|
34
|
+
expect { do_request }.to \
|
|
35
|
+
change { server.databases.count }.by(-1)
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
it { should be_successful }
|
|
39
|
+
|
|
40
|
+
it "deletes a database with the given name" do
|
|
41
|
+
data = JSON.parse(response.body)
|
|
42
|
+
expect(data["success"]).to be_true
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
describe_endpoint :get, "/databases/:db_name/stats" do
|
|
47
|
+
let(:db_name) { "first_database" }
|
|
48
|
+
|
|
49
|
+
it { should be_successful }
|
|
50
|
+
|
|
51
|
+
it "gets stats for the given database" do
|
|
52
|
+
stats = JSON.parse(response.body)
|
|
53
|
+
expect(stats).to_not be_empty
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
end
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
require "spec_helper"
|
|
2
|
+
|
|
3
|
+
describe MongoBrowser::API::Documents do
|
|
4
|
+
include ApiExampleGroup
|
|
5
|
+
|
|
6
|
+
def app
|
|
7
|
+
described_class
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
describe "documents" do
|
|
11
|
+
let(:db_name) { "first_database" }
|
|
12
|
+
let(:collection_name) { "first_collection" }
|
|
13
|
+
|
|
14
|
+
describe "paged documents list" do
|
|
15
|
+
shared_examples :returned_documents do
|
|
16
|
+
it("contains all documents") do
|
|
17
|
+
expect(data["documents"]).not_to be_nil
|
|
18
|
+
expect(data["documents"]).to have_at_least(1).item
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
describe "a document" do
|
|
22
|
+
subject(:document) { data["documents"].first }
|
|
23
|
+
|
|
24
|
+
it { should_not be_nil }
|
|
25
|
+
it("contains id") { expect(document["id"]).to_not be_nil }
|
|
26
|
+
it("contains document data") { expect(document["data"]).to_not be_nil }
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
describe_endpoint :get, "/databases/:db_name/collections/:collection_name/documents" do
|
|
31
|
+
it { should be_successful }
|
|
32
|
+
|
|
33
|
+
describe "returned documents" do
|
|
34
|
+
subject(:data) { JSON.parse(response.body) }
|
|
35
|
+
|
|
36
|
+
it("contains the current page") { expect(data["page"]).to equal(1) }
|
|
37
|
+
it("contains size") { expect(data["size"]).to equal(2) }
|
|
38
|
+
it("contains total pages") { expect(data["totalPages"]).to equal(1) }
|
|
39
|
+
|
|
40
|
+
include_examples :returned_documents
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
describe "for a large set of documents" do
|
|
45
|
+
before { Fixtures.instance.load_documents! }
|
|
46
|
+
let(:collection_name) { "second_collection" }
|
|
47
|
+
|
|
48
|
+
describe_endpoint :get, "/databases/:db_name/collections/:collection_name/documents?page=:page" do
|
|
49
|
+
let(:page) { 3 }
|
|
50
|
+
|
|
51
|
+
it { should be_successful }
|
|
52
|
+
|
|
53
|
+
describe "returned documents" do
|
|
54
|
+
subject(:data) { JSON.parse(response.body) }
|
|
55
|
+
|
|
56
|
+
it("contains the current page") { expect(data["page"]).to equal(3) }
|
|
57
|
+
it("contains size") { expect(data["size"]).to equal(70) }
|
|
58
|
+
it("contains total pages") { expect(data["totalPages"]).to equal(3) }
|
|
59
|
+
|
|
60
|
+
include_examples :returned_documents
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
context "when the page number is invalid" do
|
|
64
|
+
let(:page) { "invalid" }
|
|
65
|
+
|
|
66
|
+
it { should_not be_successful }
|
|
67
|
+
it("responds with 403") { expect(response.status).to eq(403) }
|
|
68
|
+
|
|
69
|
+
it("should notify about invalid param") do
|
|
70
|
+
error = JSON.parse(response.body)["error"]
|
|
71
|
+
expect(error).not_to be_nil
|
|
72
|
+
expect(error).to eq("invalid parameter: page")
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
end
|
|
76
|
+
end
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
describe_endpoint :get, "/databases/:db_name/collections/:collection_name/documents/:id" do
|
|
80
|
+
let(:id) do
|
|
81
|
+
document = server.database(db_name).collection(collection_name).mongo_collection.find({}, limit: 1).first
|
|
82
|
+
document["_id"]
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
context "whe the document has been found" do
|
|
86
|
+
it { should be_successful }
|
|
87
|
+
|
|
88
|
+
it "returns the document" do
|
|
89
|
+
data = JSON.parse(response.body)
|
|
90
|
+
expect(data["id"]).to eq(id.to_s)
|
|
91
|
+
expect(data["dbName"]).to eq(db_name)
|
|
92
|
+
expect(data["collectionName"]).to eq(collection_name)
|
|
93
|
+
end
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
context "when the documents has not been found" do
|
|
97
|
+
before do
|
|
98
|
+
collection = server.database(db_name).collection(collection_name)
|
|
99
|
+
document = collection.find(id)
|
|
100
|
+
collection.remove!(document)
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
it { should_not be_successful }
|
|
104
|
+
its(:status) { should == 404 }
|
|
105
|
+
|
|
106
|
+
it("should notify about not found document") do
|
|
107
|
+
error = JSON.parse(response.body)["error"]
|
|
108
|
+
expect(error).not_to be_nil
|
|
109
|
+
expect(error).to eq("Document not found")
|
|
110
|
+
end
|
|
111
|
+
end
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
describe_endpoint :delete, "/databases/:db_name/collections/:collection_name/documents/:id" do
|
|
115
|
+
let(:id) do
|
|
116
|
+
document = server.database(db_name).collection(collection_name).mongo_collection.find({}, limit: 1).first
|
|
117
|
+
document["_id"]
|
|
118
|
+
end
|
|
119
|
+
|
|
120
|
+
before do
|
|
121
|
+
expect { do_request }.to \
|
|
122
|
+
change { server.database(db_name).collection(collection_name).size }.by(-1)
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
it { should be_successful }
|
|
126
|
+
|
|
127
|
+
it "deletes a document with the given id" do
|
|
128
|
+
data = JSON.parse(response.body)
|
|
129
|
+
expect(data["success"]).to be_true
|
|
130
|
+
end
|
|
131
|
+
end
|
|
132
|
+
end
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
end
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
require "spec_helper"
|
|
2
|
+
|
|
3
|
+
describe MongoBrowser::API::Mongo do
|
|
4
|
+
include ApiExampleGroup
|
|
5
|
+
|
|
6
|
+
def app
|
|
7
|
+
described_class
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
describe_endpoint :get, "/server_info" do
|
|
11
|
+
it { should be_successful }
|
|
12
|
+
|
|
13
|
+
it "returns info about the server" do
|
|
14
|
+
server_info = JSON.parse(response.body)
|
|
15
|
+
expect(server_info).to_not be_empty
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
describe_endpoint :get, "/version" do
|
|
20
|
+
it { should be_successful }
|
|
21
|
+
|
|
22
|
+
it "returns application version" do
|
|
23
|
+
data = JSON.parse(response.body)
|
|
24
|
+
expect(data["version"]).to eq(MongoBrowser::VERSION)
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
require "spec_helper"
|
|
2
|
+
require "mongo_browser/cli"
|
|
3
|
+
|
|
4
|
+
describe MongoBrowser::CLI do
|
|
5
|
+
|
|
6
|
+
describe "#start" do
|
|
7
|
+
let(:runner) { double("runer", run!: true) }
|
|
8
|
+
before { Thin::Runner.stub(:new).and_return(runner) }
|
|
9
|
+
|
|
10
|
+
it "starts the application" do
|
|
11
|
+
args = ["start", "--port=1234"]
|
|
12
|
+
MongoBrowser::CLI.start(args)
|
|
13
|
+
|
|
14
|
+
expect(Thin::Runner).to have_received(:new).with(kind_of(Array))
|
|
15
|
+
expect(runner).to have_received(:run!)
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
end
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
require "spec_helper"
|
|
2
|
+
|
|
3
|
+
describe MongoBrowser::Entities::Database do
|
|
4
|
+
let(:database) { double }
|
|
5
|
+
subject(:database_entity) { described_class.new(database) }
|
|
6
|
+
|
|
7
|
+
it { should expose :name }
|
|
8
|
+
it { should expose :size }
|
|
9
|
+
it { should expose :count }
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
describe MongoBrowser::Entities::Collection do
|
|
13
|
+
let(:collection) { double }
|
|
14
|
+
subject(:database_entity) { described_class.new(collection) }
|
|
15
|
+
|
|
16
|
+
it { should expose :dbName }
|
|
17
|
+
it { should expose :name }
|
|
18
|
+
it { should expose :size }
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
describe MongoBrowser::Entities::Document do
|
|
22
|
+
let(:document) { double }
|
|
23
|
+
subject(:database_entity) { described_class.new(document) }
|
|
24
|
+
|
|
25
|
+
it { should expose :id }
|
|
26
|
+
it { should expose :dbName }
|
|
27
|
+
it { should expose :collectionName }
|
|
28
|
+
it { should expose :data }
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
describe MongoBrowser::Entities::PagedDocuments do
|
|
32
|
+
let(:pager) { double }
|
|
33
|
+
subject(:database_entity) { described_class.new(pager) }
|
|
34
|
+
|
|
35
|
+
it { should expose :page }
|
|
36
|
+
it { should expose :size }
|
|
37
|
+
it { should expose :totalPages }
|
|
38
|
+
it { should expose :documents }
|
|
39
|
+
end
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
require "spec_helper"
|
|
2
2
|
|
|
3
3
|
describe MongoBrowser::Models::Collection do
|
|
4
|
-
let(:
|
|
5
|
-
let(:
|
|
4
|
+
let(:db_name) { "first_database" }
|
|
5
|
+
let(:collection_name) { "first_collection" }
|
|
6
6
|
|
|
7
7
|
let(:server) { MongoBrowser::Models::Server.current }
|
|
8
8
|
|
|
9
9
|
let(:mongo_collection) do
|
|
10
|
-
server.connection[
|
|
11
|
-
.collection(
|
|
10
|
+
server.connection[db_name]
|
|
11
|
+
.collection(collection_name)
|
|
12
12
|
end
|
|
13
13
|
|
|
14
14
|
let(:collection) { described_class.new(mongo_collection) }
|
|
@@ -18,8 +18,8 @@ describe MongoBrowser::Models::Collection do
|
|
|
18
18
|
collection.mongo_collection.should == mongo_collection
|
|
19
19
|
end
|
|
20
20
|
|
|
21
|
-
its(:db_name) { should ==
|
|
22
|
-
its(:name) { should ==
|
|
21
|
+
its(:db_name) { should == db_name }
|
|
22
|
+
its(:name) { should == collection_name }
|
|
23
23
|
its(:size) { should == 2 }
|
|
24
24
|
|
|
25
25
|
describe "#stats" do
|
|
@@ -32,7 +32,7 @@ describe MongoBrowser::Models::Collection do
|
|
|
32
32
|
end
|
|
33
33
|
|
|
34
34
|
describe "#drop!" do
|
|
35
|
-
let(:database) { server.database(
|
|
35
|
+
let(:database) { server.database(db_name) }
|
|
36
36
|
|
|
37
37
|
it "drops the collection" do
|
|
38
38
|
collection.drop!
|
|
@@ -41,9 +41,15 @@ describe MongoBrowser::Models::Collection do
|
|
|
41
41
|
end
|
|
42
42
|
|
|
43
43
|
describe "#documents_with_pagination" do
|
|
44
|
-
|
|
44
|
+
subject { collection.documents_with_pagination }
|
|
45
45
|
|
|
46
|
-
it
|
|
46
|
+
it { should be_an_instance_of(OpenStruct) }
|
|
47
|
+
its(:size) { should == 2 }
|
|
48
|
+
its(:page) { should == 1 }
|
|
49
|
+
its(:total_pages) { should == 1 }
|
|
50
|
+
|
|
51
|
+
its(:documents) { should be_an_instance_of(Array) }
|
|
52
|
+
its(:documents) { should have(2).items }
|
|
47
53
|
end
|
|
48
54
|
|
|
49
55
|
describe "#find" do
|
|
@@ -70,7 +76,7 @@ describe MongoBrowser::Models::Collection do
|
|
|
70
76
|
end
|
|
71
77
|
|
|
72
78
|
describe "#remove!" do
|
|
73
|
-
let(:document) { MongoBrowser::Models::Document.new(mongo_collection.find.first) }
|
|
79
|
+
let(:document) { MongoBrowser::Models::Document.new(db_name, collection_name, mongo_collection.find.first) }
|
|
74
80
|
|
|
75
81
|
it "removes a document from the collection" do
|
|
76
82
|
expect(collection.remove!(document)).to be_true
|
|
@@ -2,8 +2,8 @@ require "spec_helper"
|
|
|
2
2
|
|
|
3
3
|
describe MongoBrowser::Models::Database do
|
|
4
4
|
let(:connection) { MongoBrowser::Models::Server.current.connection }
|
|
5
|
-
let(:
|
|
6
|
-
let(:mongo_db) { connection[
|
|
5
|
+
let(:db_name) { "first_database" }
|
|
6
|
+
let(:mongo_db) { connection[db_name] }
|
|
7
7
|
|
|
8
8
|
let(:database) { described_class.new(mongo_db) }
|
|
9
9
|
subject { database }
|
|
@@ -12,8 +12,8 @@ describe MongoBrowser::Models::Database do
|
|
|
12
12
|
database.mongo_db.should == mongo_db
|
|
13
13
|
end
|
|
14
14
|
|
|
15
|
-
its(:id) { should ==
|
|
16
|
-
its(:name) { should ==
|
|
15
|
+
its(:id) { should == db_name }
|
|
16
|
+
its(:name) { should == db_name }
|
|
17
17
|
|
|
18
18
|
its(:size) { should be_an_instance_of(Fixnum) }
|
|
19
19
|
|