metasploit_data_models 0.16.9 → 0.17.0
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/.coveralls.yml +1 -0
- data/.travis.yml +3 -0
- data/Gemfile +2 -0
- data/README.md +1 -1
- data/app/models/mdm/task.rb +0 -2
- data/app/models/mdm/workspace.rb +0 -2
- data/lib/metasploit_data_models/version.rb +1 -1
- data/spec/app/models/mdm/task_spec.rb +0 -1
- data/spec/app/models/mdm/workspace_spec.rb +0 -10
- data/spec/spec_helper.rb +11 -0
- metadata +28 -15
- checksums.yaml +0 -15
- data/app/models/mdm/report.rb +0 -50
- data/app/models/mdm/report_template.rb +0 -27
- data/spec/app/models/mdm/report_spec.rb +0 -104
- data/spec/app/models/mdm/report_template_spec.rb +0 -52
- data/spec/factories/mdm/report_templates.rb +0 -8
- data/spec/factories/mdm/reports.rb +0 -13
data/.coveralls.yml
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
service_name: travis-ci
|
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
|
@@ -19,6 +19,8 @@ group :development, :test do
|
|
|
19
19
|
end
|
|
20
20
|
|
|
21
21
|
group :test do
|
|
22
|
+
# Upload coverage reports to coveralls.io
|
|
23
|
+
gem 'coveralls', require: false
|
|
22
24
|
# In a full rails project, factory_girl_rails would be in both the :development, and :test group, but since we only
|
|
23
25
|
# want rails in :test, factory_girl_rails must also only be in :test.
|
|
24
26
|
# add matchers from shoulda, such as validates_presence_of, which are useful for testing validations
|
data/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
#MetasploitDataModels [](https://travis-ci.org/rapid7/metasploit_data_models)
|
|
1
|
+
#MetasploitDataModels [](https://travis-ci.org/rapid7/metasploit_data_models)[](https://codeclimate.com/github/rapid7/metasploit_data_models)[](https://coveralls.io/r/rapid7/metasploit_data_models)[](https://gemnasium.com/rapid7/metasploit_data_models)[](http://badge.fury.io/rb/metasploit_data_models)
|
|
2
2
|
|
|
3
3
|
The database layer for Metasploit
|
|
4
4
|
|
data/app/models/mdm/task.rb
CHANGED
data/app/models/mdm/workspace.rb
CHANGED
|
@@ -21,8 +21,6 @@ class Mdm::Workspace < ActiveRecord::Base
|
|
|
21
21
|
has_many :listeners, :dependent => :destroy, :class_name => 'Mdm::Listener'
|
|
22
22
|
has_many :notes, :class_name => 'Mdm::Note'
|
|
23
23
|
belongs_to :owner, :class_name => 'Mdm::User', :foreign_key => 'owner_id'
|
|
24
|
-
has_many :report_templates, :dependent => :destroy, :class_name => 'Mdm::ReportTemplate'
|
|
25
|
-
has_many :reports, :dependent => :destroy, :class_name => 'Mdm::Report'
|
|
26
24
|
has_many :tasks, :dependent => :destroy, :class_name => 'Mdm::Task', :order => 'created_at DESC'
|
|
27
25
|
has_and_belongs_to_many :users, :join_table => 'workspace_members', :uniq => true, :class_name => 'Mdm::User'
|
|
28
26
|
|
|
@@ -4,5 +4,5 @@ module MetasploitDataModels
|
|
|
4
4
|
# metasploit-framework/data/sql/migrate to db/migrate in this project, not all models have specs that verify the
|
|
5
5
|
# migrations (with have_db_column and have_db_index) and certain models may not be shared between metasploit-framework
|
|
6
6
|
# and pro, so models may be removed in the future. Because of the unstable API the version should remain below 1.0.0
|
|
7
|
-
VERSION = '0.
|
|
7
|
+
VERSION = '0.17.0'
|
|
8
8
|
end
|
|
@@ -55,7 +55,6 @@ describe Mdm::Task do
|
|
|
55
55
|
it { should have_many(:task_services).class_name('Mdm::TaskService').dependent(:destroy) }
|
|
56
56
|
it { should have_many(:services).class_name('Mdm::Service').through(:task_services) }
|
|
57
57
|
it { should belong_to(:workspace).class_name('Mdm::Workspace') }
|
|
58
|
-
it { should have_many(:reports).class_name('Mdm::Report')}
|
|
59
58
|
|
|
60
59
|
end
|
|
61
60
|
|
|
@@ -20,8 +20,6 @@ describe Mdm::Workspace do
|
|
|
20
20
|
it 'should successfully destroy the object and dependent objects' do
|
|
21
21
|
workspace = FactoryGirl.create(:mdm_workspace)
|
|
22
22
|
listener = FactoryGirl.create(:mdm_listener, :workspace => workspace)
|
|
23
|
-
report_template = FactoryGirl.create(:mdm_report_template, :workspace => workspace)
|
|
24
|
-
report = FactoryGirl.create(:mdm_report, :workspace => workspace)
|
|
25
23
|
task = FactoryGirl.create(:mdm_task, :workspace => workspace)
|
|
26
24
|
|
|
27
25
|
expect {
|
|
@@ -33,12 +31,6 @@ describe Mdm::Workspace do
|
|
|
33
31
|
expect {
|
|
34
32
|
listener.reload
|
|
35
33
|
}.to raise_error(ActiveRecord::RecordNotFound)
|
|
36
|
-
expect {
|
|
37
|
-
report_template.reload
|
|
38
|
-
}.to raise_error(ActiveRecord::RecordNotFound)
|
|
39
|
-
expect {
|
|
40
|
-
report.reload
|
|
41
|
-
}.to raise_error(ActiveRecord::RecordNotFound)
|
|
42
34
|
expect {
|
|
43
35
|
task.reload
|
|
44
36
|
}.to raise_error(ActiveRecord::RecordNotFound)
|
|
@@ -55,8 +47,6 @@ describe Mdm::Workspace do
|
|
|
55
47
|
it { should have_many(:loots).class_name('Mdm::Loot').through(:hosts) }
|
|
56
48
|
it { should have_many(:notes).class_name('Mdm::Note') }
|
|
57
49
|
it { should belong_to(:owner).class_name('Mdm::User').with_foreign_key('owner_id') }
|
|
58
|
-
it { should have_many(:report_templates).class_name('Mdm::ReportTemplate').dependent(:destroy) }
|
|
59
|
-
it { should have_many(:reports).class_name('Mdm::Report').dependent(:destroy) }
|
|
60
50
|
it { should have_many(:services).class_name('Mdm::Service').through(:hosts).with_foreign_key('service_id') }
|
|
61
51
|
it { should have_many(:sessions).class_name('Mdm::Session').through(:hosts) }
|
|
62
52
|
it { should have_many(:tasks).class_name('Mdm::Task').dependent(:destroy).order('created_at DESC') }
|
data/spec/spec_helper.rb
CHANGED
|
@@ -8,6 +8,17 @@ Bundler.setup(:default, :test)
|
|
|
8
8
|
# Require simplecov before loading ..dummy/config/environment.rb because it will cause metasploit_data_models/lib to
|
|
9
9
|
# be loaded, which would result in Coverage not recording hits for any of the files.
|
|
10
10
|
require 'simplecov'
|
|
11
|
+
require 'coveralls'
|
|
12
|
+
|
|
13
|
+
if ENV['TRAVIS'] == 'true'
|
|
14
|
+
# don't generate local report as it is inaccessible on travis-ci, which is why coveralls is being used.
|
|
15
|
+
SimpleCov.formatter = Coveralls::SimpleCov::Formatter
|
|
16
|
+
else
|
|
17
|
+
SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
|
|
18
|
+
# either generate the local report
|
|
19
|
+
SimpleCov::Formatter::HTMLFormatter
|
|
20
|
+
]
|
|
21
|
+
end
|
|
11
22
|
|
|
12
23
|
require File.expand_path('../dummy/config/environment.rb', __FILE__)
|
|
13
24
|
require 'rspec/rails'
|
metadata
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: metasploit_data_models
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.17.0
|
|
5
|
+
prerelease:
|
|
5
6
|
platform: ruby
|
|
6
7
|
authors:
|
|
7
8
|
- Samuel Huckins
|
|
@@ -11,11 +12,12 @@ authors:
|
|
|
11
12
|
autorequire:
|
|
12
13
|
bindir: bin
|
|
13
14
|
cert_chain: []
|
|
14
|
-
date:
|
|
15
|
+
date: 2014-03-19 00:00:00.000000000 Z
|
|
15
16
|
dependencies:
|
|
16
17
|
- !ruby/object:Gem::Dependency
|
|
17
18
|
name: rake
|
|
18
19
|
requirement: !ruby/object:Gem::Requirement
|
|
20
|
+
none: false
|
|
19
21
|
requirements:
|
|
20
22
|
- - ! '>='
|
|
21
23
|
- !ruby/object:Gem::Version
|
|
@@ -23,6 +25,7 @@ dependencies:
|
|
|
23
25
|
type: :development
|
|
24
26
|
prerelease: false
|
|
25
27
|
version_requirements: !ruby/object:Gem::Requirement
|
|
28
|
+
none: false
|
|
26
29
|
requirements:
|
|
27
30
|
- - ! '>='
|
|
28
31
|
- !ruby/object:Gem::Version
|
|
@@ -30,6 +33,7 @@ dependencies:
|
|
|
30
33
|
- !ruby/object:Gem::Dependency
|
|
31
34
|
name: yard
|
|
32
35
|
requirement: !ruby/object:Gem::Requirement
|
|
36
|
+
none: false
|
|
33
37
|
requirements:
|
|
34
38
|
- - ! '>='
|
|
35
39
|
- !ruby/object:Gem::Version
|
|
@@ -37,6 +41,7 @@ dependencies:
|
|
|
37
41
|
type: :development
|
|
38
42
|
prerelease: false
|
|
39
43
|
version_requirements: !ruby/object:Gem::Requirement
|
|
44
|
+
none: false
|
|
40
45
|
requirements:
|
|
41
46
|
- - ! '>='
|
|
42
47
|
- !ruby/object:Gem::Version
|
|
@@ -44,6 +49,7 @@ dependencies:
|
|
|
44
49
|
- !ruby/object:Gem::Dependency
|
|
45
50
|
name: pry
|
|
46
51
|
requirement: !ruby/object:Gem::Requirement
|
|
52
|
+
none: false
|
|
47
53
|
requirements:
|
|
48
54
|
- - ! '>='
|
|
49
55
|
- !ruby/object:Gem::Version
|
|
@@ -51,6 +57,7 @@ dependencies:
|
|
|
51
57
|
type: :development
|
|
52
58
|
prerelease: false
|
|
53
59
|
version_requirements: !ruby/object:Gem::Requirement
|
|
60
|
+
none: false
|
|
54
61
|
requirements:
|
|
55
62
|
- - ! '>='
|
|
56
63
|
- !ruby/object:Gem::Version
|
|
@@ -58,6 +65,7 @@ dependencies:
|
|
|
58
65
|
- !ruby/object:Gem::Dependency
|
|
59
66
|
name: activerecord
|
|
60
67
|
requirement: !ruby/object:Gem::Requirement
|
|
68
|
+
none: false
|
|
61
69
|
requirements:
|
|
62
70
|
- - ! '>='
|
|
63
71
|
- !ruby/object:Gem::Version
|
|
@@ -65,6 +73,7 @@ dependencies:
|
|
|
65
73
|
type: :runtime
|
|
66
74
|
prerelease: false
|
|
67
75
|
version_requirements: !ruby/object:Gem::Requirement
|
|
76
|
+
none: false
|
|
68
77
|
requirements:
|
|
69
78
|
- - ! '>='
|
|
70
79
|
- !ruby/object:Gem::Version
|
|
@@ -72,6 +81,7 @@ dependencies:
|
|
|
72
81
|
- !ruby/object:Gem::Dependency
|
|
73
82
|
name: activesupport
|
|
74
83
|
requirement: !ruby/object:Gem::Requirement
|
|
84
|
+
none: false
|
|
75
85
|
requirements:
|
|
76
86
|
- - ! '>='
|
|
77
87
|
- !ruby/object:Gem::Version
|
|
@@ -79,6 +89,7 @@ dependencies:
|
|
|
79
89
|
type: :runtime
|
|
80
90
|
prerelease: false
|
|
81
91
|
version_requirements: !ruby/object:Gem::Requirement
|
|
92
|
+
none: false
|
|
82
93
|
requirements:
|
|
83
94
|
- - ! '>='
|
|
84
95
|
- !ruby/object:Gem::Version
|
|
@@ -86,6 +97,7 @@ dependencies:
|
|
|
86
97
|
- !ruby/object:Gem::Dependency
|
|
87
98
|
name: redcarpet
|
|
88
99
|
requirement: !ruby/object:Gem::Requirement
|
|
100
|
+
none: false
|
|
89
101
|
requirements:
|
|
90
102
|
- - ! '>='
|
|
91
103
|
- !ruby/object:Gem::Version
|
|
@@ -93,6 +105,7 @@ dependencies:
|
|
|
93
105
|
type: :development
|
|
94
106
|
prerelease: false
|
|
95
107
|
version_requirements: !ruby/object:Gem::Requirement
|
|
108
|
+
none: false
|
|
96
109
|
requirements:
|
|
97
110
|
- - ! '>='
|
|
98
111
|
- !ruby/object:Gem::Version
|
|
@@ -100,6 +113,7 @@ dependencies:
|
|
|
100
113
|
- !ruby/object:Gem::Dependency
|
|
101
114
|
name: pg
|
|
102
115
|
requirement: !ruby/object:Gem::Requirement
|
|
116
|
+
none: false
|
|
103
117
|
requirements:
|
|
104
118
|
- - ! '>='
|
|
105
119
|
- !ruby/object:Gem::Version
|
|
@@ -107,6 +121,7 @@ dependencies:
|
|
|
107
121
|
type: :runtime
|
|
108
122
|
prerelease: false
|
|
109
123
|
version_requirements: !ruby/object:Gem::Requirement
|
|
124
|
+
none: false
|
|
110
125
|
requirements:
|
|
111
126
|
- - ! '>='
|
|
112
127
|
- !ruby/object:Gem::Version
|
|
@@ -123,6 +138,7 @@ executables:
|
|
|
123
138
|
extensions: []
|
|
124
139
|
extra_rdoc_files: []
|
|
125
140
|
files:
|
|
141
|
+
- .coveralls.yml
|
|
126
142
|
- .gitignore
|
|
127
143
|
- .rspec
|
|
128
144
|
- .simplecov
|
|
@@ -157,8 +173,6 @@ files:
|
|
|
157
173
|
- app/models/mdm/note.rb
|
|
158
174
|
- app/models/mdm/profile.rb
|
|
159
175
|
- app/models/mdm/ref.rb
|
|
160
|
-
- app/models/mdm/report.rb
|
|
161
|
-
- app/models/mdm/report_template.rb
|
|
162
176
|
- app/models/mdm/route.rb
|
|
163
177
|
- app/models/mdm/service.rb
|
|
164
178
|
- app/models/mdm/session.rb
|
|
@@ -328,8 +342,6 @@ files:
|
|
|
328
342
|
- spec/app/models/mdm/nexpose_console_spec.rb
|
|
329
343
|
- spec/app/models/mdm/note_spec.rb
|
|
330
344
|
- spec/app/models/mdm/ref_spec.rb
|
|
331
|
-
- spec/app/models/mdm/report_spec.rb
|
|
332
|
-
- spec/app/models/mdm/report_template_spec.rb
|
|
333
345
|
- spec/app/models/mdm/route_spec.rb
|
|
334
346
|
- spec/app/models/mdm/service_spec.rb
|
|
335
347
|
- spec/app/models/mdm/session_event_spec.rb
|
|
@@ -411,8 +423,6 @@ files:
|
|
|
411
423
|
- spec/factories/mdm/nexpose_consoles.rb
|
|
412
424
|
- spec/factories/mdm/notes.rb
|
|
413
425
|
- spec/factories/mdm/refs.rb
|
|
414
|
-
- spec/factories/mdm/report_templates.rb
|
|
415
|
-
- spec/factories/mdm/reports.rb
|
|
416
426
|
- spec/factories/mdm/routes.rb
|
|
417
427
|
- spec/factories/mdm/services.rb
|
|
418
428
|
- spec/factories/mdm/session_events.rb
|
|
@@ -439,26 +449,33 @@ files:
|
|
|
439
449
|
- spec/support/shared/examples/mdm/module/detail/supports_stance_with_mtype.rb
|
|
440
450
|
homepage: ''
|
|
441
451
|
licenses: []
|
|
442
|
-
metadata: {}
|
|
443
452
|
post_install_message:
|
|
444
453
|
rdoc_options: []
|
|
445
454
|
require_paths:
|
|
446
455
|
- lib
|
|
447
456
|
required_ruby_version: !ruby/object:Gem::Requirement
|
|
457
|
+
none: false
|
|
448
458
|
requirements:
|
|
449
459
|
- - ! '>='
|
|
450
460
|
- !ruby/object:Gem::Version
|
|
451
461
|
version: '0'
|
|
462
|
+
segments:
|
|
463
|
+
- 0
|
|
464
|
+
hash: 430178368308150255
|
|
452
465
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
466
|
+
none: false
|
|
453
467
|
requirements:
|
|
454
468
|
- - ! '>='
|
|
455
469
|
- !ruby/object:Gem::Version
|
|
456
470
|
version: '0'
|
|
471
|
+
segments:
|
|
472
|
+
- 0
|
|
473
|
+
hash: 430178368308150255
|
|
457
474
|
requirements: []
|
|
458
475
|
rubyforge_project:
|
|
459
|
-
rubygems_version:
|
|
476
|
+
rubygems_version: 1.8.25
|
|
460
477
|
signing_key:
|
|
461
|
-
specification_version:
|
|
478
|
+
specification_version: 3
|
|
462
479
|
summary: Database code for MSF and Metasploit Pro
|
|
463
480
|
test_files:
|
|
464
481
|
- spec/app/models/mdm/client_spec.rb
|
|
@@ -482,8 +499,6 @@ test_files:
|
|
|
482
499
|
- spec/app/models/mdm/nexpose_console_spec.rb
|
|
483
500
|
- spec/app/models/mdm/note_spec.rb
|
|
484
501
|
- spec/app/models/mdm/ref_spec.rb
|
|
485
|
-
- spec/app/models/mdm/report_spec.rb
|
|
486
|
-
- spec/app/models/mdm/report_template_spec.rb
|
|
487
502
|
- spec/app/models/mdm/route_spec.rb
|
|
488
503
|
- spec/app/models/mdm/service_spec.rb
|
|
489
504
|
- spec/app/models/mdm/session_event_spec.rb
|
|
@@ -565,8 +580,6 @@ test_files:
|
|
|
565
580
|
- spec/factories/mdm/nexpose_consoles.rb
|
|
566
581
|
- spec/factories/mdm/notes.rb
|
|
567
582
|
- spec/factories/mdm/refs.rb
|
|
568
|
-
- spec/factories/mdm/report_templates.rb
|
|
569
|
-
- spec/factories/mdm/reports.rb
|
|
570
583
|
- spec/factories/mdm/routes.rb
|
|
571
584
|
- spec/factories/mdm/services.rb
|
|
572
585
|
- spec/factories/mdm/session_events.rb
|
checksums.yaml
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
!binary "U0hBMQ==":
|
|
3
|
-
metadata.gz: !binary |-
|
|
4
|
-
MjU1NGM5ZjAwZjAwYThjNTQ2YmE4OTk4MTQ2ZGRhYzA5ZmY2OTE1Mw==
|
|
5
|
-
data.tar.gz: !binary |-
|
|
6
|
-
NWZkNjZkYTY0ODE4ODI5NzRjYjRhZWY3MzAwZmZhZmFmY2NjNzBlZA==
|
|
7
|
-
SHA512:
|
|
8
|
-
metadata.gz: !binary |-
|
|
9
|
-
NGY1YjlhYzhiMjMyMzQ1MjFjMTllMTA2N2RlNGMwM2U4NWVlMGQ0OTMzNzE4
|
|
10
|
-
ZTliMjViMjFlYjJkZjEwNDA2ODFhN2ViOWY3MDQ1MTVjMjY2ZmY0MDg4ODFl
|
|
11
|
-
NTkxNzgwYjE4ZjhlNTg1MWRjY2JiYmVhNWE5YTQ4OTE0ZTJiMTU=
|
|
12
|
-
data.tar.gz: !binary |-
|
|
13
|
-
YzdjZWYxNGVlNTAxYjRlOWNkZDc0ZWIwZjYzODYzMTlmMDAwYzg4NmRmZmM3
|
|
14
|
-
YmQ1ZDVkM2FlZjNkYjNhYTEwZThmZTE3MjJiODM3YjkzMzMyZjY1OWYyYzQw
|
|
15
|
-
ZjYxZDQ2NzdkNWU3OTkzZTUzZmFkYjE3OTU0ZTkwZDFjNzkxZjQ=
|
data/app/models/mdm/report.rb
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
class Mdm::Report < ActiveRecord::Base
|
|
2
|
-
#
|
|
3
|
-
# Callbacks
|
|
4
|
-
#
|
|
5
|
-
|
|
6
|
-
before_destroy :delete_file
|
|
7
|
-
|
|
8
|
-
#
|
|
9
|
-
# Relations
|
|
10
|
-
#
|
|
11
|
-
|
|
12
|
-
belongs_to :workspace, :class_name => 'Mdm::Workspace'
|
|
13
|
-
belongs_to :task, :class_name => 'Mdm::Task'
|
|
14
|
-
#
|
|
15
|
-
# Scopes
|
|
16
|
-
#
|
|
17
|
-
|
|
18
|
-
scope :flagged, where('reports.downloaded_at is NULL')
|
|
19
|
-
|
|
20
|
-
#
|
|
21
|
-
# Serializations
|
|
22
|
-
#
|
|
23
|
-
|
|
24
|
-
serialize :options, MetasploitDataModels::Base64Serializer.new
|
|
25
|
-
|
|
26
|
-
#
|
|
27
|
-
# Validations
|
|
28
|
-
#
|
|
29
|
-
|
|
30
|
-
validates :name,
|
|
31
|
-
:format => {
|
|
32
|
-
:allow_blank => true,
|
|
33
|
-
:message => "name must consist of A-Z, 0-9, space, dot, underscore, or dash",
|
|
34
|
-
:with => /^[A-Za-z0-9\x20\x2e\x2d\x5f\x5c]+$/
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
private
|
|
38
|
-
|
|
39
|
-
def delete_file
|
|
40
|
-
c = Pro::Client.get rescue nil
|
|
41
|
-
if c
|
|
42
|
-
c.report_delete_file(self[:id])
|
|
43
|
-
else
|
|
44
|
-
::File.unlink(self.path) rescue nil
|
|
45
|
-
end
|
|
46
|
-
end
|
|
47
|
-
|
|
48
|
-
ActiveSupport.run_load_hooks(:mdm_report, self)
|
|
49
|
-
end
|
|
50
|
-
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
class Mdm::ReportTemplate < ActiveRecord::Base
|
|
2
|
-
#
|
|
3
|
-
# Callbacks
|
|
4
|
-
#
|
|
5
|
-
|
|
6
|
-
before_destroy :delete_file
|
|
7
|
-
|
|
8
|
-
#
|
|
9
|
-
# Relations
|
|
10
|
-
#
|
|
11
|
-
|
|
12
|
-
belongs_to :workspace, :class_name => 'Mdm::Workspace'
|
|
13
|
-
|
|
14
|
-
private
|
|
15
|
-
|
|
16
|
-
def delete_file
|
|
17
|
-
c = Pro::Client.get rescue nil
|
|
18
|
-
if c
|
|
19
|
-
c.report_template_delete_file(self[:id])
|
|
20
|
-
else
|
|
21
|
-
::File.unlink(self.path) rescue nil
|
|
22
|
-
end
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
ActiveSupport.run_load_hooks(:mdm_report_template, self)
|
|
26
|
-
end
|
|
27
|
-
|
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
2
|
-
|
|
3
|
-
describe Mdm::Report do
|
|
4
|
-
|
|
5
|
-
context 'associations' do
|
|
6
|
-
it { should belong_to(:workspace).class_name('Mdm::Workspace') }
|
|
7
|
-
it { should belong_to(:task).class_name('Mdm::Task') }
|
|
8
|
-
end
|
|
9
|
-
|
|
10
|
-
context 'validations' do
|
|
11
|
-
context 'name' do
|
|
12
|
-
it 'may be blank' do
|
|
13
|
-
blank_name = FactoryGirl.build(:mdm_report, :name => '')
|
|
14
|
-
blank_name.should be_valid
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
it 'may contain A-Z, 0-9, space, dot, underscore, or dash' do
|
|
18
|
-
named_report = FactoryGirl.build(:mdm_report, :name => 'A1 B2.C_3-D')
|
|
19
|
-
named_report.should be_valid
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
it 'may not contain other characters' do
|
|
23
|
-
invalid_name = FactoryGirl.build(:mdm_report, :name => 'A/1')
|
|
24
|
-
invalid_name.should_not be_valid
|
|
25
|
-
invalid_name.errors[:name].should include('name must consist of A-Z, 0-9, space, dot, underscore, or dash')
|
|
26
|
-
invalid_name = FactoryGirl.build(:mdm_report, :name => '#A1')
|
|
27
|
-
invalid_name.should_not be_valid
|
|
28
|
-
invalid_name.errors[:name].should include('name must consist of A-Z, 0-9, space, dot, underscore, or dash')
|
|
29
|
-
invalid_name = FactoryGirl.build(:mdm_report, :name => 'A,1')
|
|
30
|
-
invalid_name.should_not be_valid
|
|
31
|
-
invalid_name.errors[:name].should include('name must consist of A-Z, 0-9, space, dot, underscore, or dash')
|
|
32
|
-
invalid_name = FactoryGirl.build(:mdm_report, :name => 'A;1')
|
|
33
|
-
invalid_name.should_not be_valid
|
|
34
|
-
invalid_name.errors[:name].should include('name must consist of A-Z, 0-9, space, dot, underscore, or dash')
|
|
35
|
-
invalid_name = FactoryGirl.build(:mdm_report, :name => "A' or '1'='1'")
|
|
36
|
-
invalid_name.should_not be_valid
|
|
37
|
-
invalid_name.errors[:name].should include('name must consist of A-Z, 0-9, space, dot, underscore, or dash')
|
|
38
|
-
end
|
|
39
|
-
end
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
context 'scopes' do
|
|
43
|
-
context 'flagged' do
|
|
44
|
-
it 'should return un-downlaoded reports' do
|
|
45
|
-
flagged_report = FactoryGirl.create(:mdm_report)
|
|
46
|
-
Mdm::Report.flagged.should include(flagged_report)
|
|
47
|
-
end
|
|
48
|
-
|
|
49
|
-
it 'should not return reports that have been downloaded' do
|
|
50
|
-
downlaoded_report = FactoryGirl.create(:mdm_report, :downloaded_at => Time.now)
|
|
51
|
-
Mdm::Report.flagged.should_not include(downlaoded_report)
|
|
52
|
-
end
|
|
53
|
-
end
|
|
54
|
-
end
|
|
55
|
-
|
|
56
|
-
context 'callbacks' do
|
|
57
|
-
context 'before_destroy' do
|
|
58
|
-
it 'should call #delete_file' do
|
|
59
|
-
myreport = FactoryGirl.create(:mdm_report)
|
|
60
|
-
myreport.should_receive(:delete_file)
|
|
61
|
-
myreport.destroy
|
|
62
|
-
end
|
|
63
|
-
end
|
|
64
|
-
end
|
|
65
|
-
|
|
66
|
-
context 'factory' do
|
|
67
|
-
it 'should be valid' do
|
|
68
|
-
report = FactoryGirl.build(:mdm_report)
|
|
69
|
-
report.should be_valid
|
|
70
|
-
end
|
|
71
|
-
end
|
|
72
|
-
|
|
73
|
-
context '#destroy' do
|
|
74
|
-
it 'should successfully destroy the object' do
|
|
75
|
-
report = FactoryGirl.create(:mdm_report)
|
|
76
|
-
expect {
|
|
77
|
-
report.destroy
|
|
78
|
-
}.to_not raise_error
|
|
79
|
-
expect {
|
|
80
|
-
report.reload
|
|
81
|
-
}.to raise_error(ActiveRecord::RecordNotFound)
|
|
82
|
-
end
|
|
83
|
-
end
|
|
84
|
-
|
|
85
|
-
context 'database' do
|
|
86
|
-
|
|
87
|
-
context 'timestamps'do
|
|
88
|
-
it { should have_db_column(:created_at).of_type(:datetime).with_options(:null => false) }
|
|
89
|
-
it { should have_db_column(:updated_at).of_type(:datetime).with_options(:null => false) }
|
|
90
|
-
it { should have_db_column(:downloaded_at).of_type(:datetime) }
|
|
91
|
-
end
|
|
92
|
-
|
|
93
|
-
context 'columns' do
|
|
94
|
-
it { should have_db_column(:workspace_id).of_type(:integer).with_options(:null => false, :default =>1) }
|
|
95
|
-
it { should have_db_column(:created_by).of_type(:string) }
|
|
96
|
-
it { should have_db_column(:rtype).of_type(:string) }
|
|
97
|
-
it { should have_db_column(:path).of_type(:string) }
|
|
98
|
-
it { should have_db_column(:options).of_type(:text) }
|
|
99
|
-
it { should have_db_column(:name).of_type(:string) }
|
|
100
|
-
|
|
101
|
-
end
|
|
102
|
-
end
|
|
103
|
-
|
|
104
|
-
end
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
2
|
-
|
|
3
|
-
describe Mdm::ReportTemplate do
|
|
4
|
-
|
|
5
|
-
context 'associations' do
|
|
6
|
-
it { should belong_to(:workspace).class_name('Mdm::Workspace') }
|
|
7
|
-
end
|
|
8
|
-
|
|
9
|
-
context 'callbacks' do
|
|
10
|
-
context 'before_destroy' do
|
|
11
|
-
it 'should call #delete_file' do
|
|
12
|
-
report_template = FactoryGirl.create(:mdm_report_template)
|
|
13
|
-
report_template.should_receive(:delete_file)
|
|
14
|
-
report_template.destroy
|
|
15
|
-
end
|
|
16
|
-
end
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
context 'factory' do
|
|
20
|
-
it 'should be valid' do
|
|
21
|
-
report_template = FactoryGirl.build(:mdm_report_template)
|
|
22
|
-
report_template.should be_valid
|
|
23
|
-
end
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
context '#destroy' do
|
|
27
|
-
it 'should successfully destroy the object' do
|
|
28
|
-
report_template = FactoryGirl.create(:mdm_report_template)
|
|
29
|
-
expect {
|
|
30
|
-
report_template.destroy
|
|
31
|
-
}.to_not raise_error
|
|
32
|
-
expect {
|
|
33
|
-
report_template.reload
|
|
34
|
-
}.to raise_error(ActiveRecord::RecordNotFound)
|
|
35
|
-
end
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
context 'database' do
|
|
39
|
-
|
|
40
|
-
context 'timestamps'do
|
|
41
|
-
it { should have_db_column(:created_at).of_type(:datetime).with_options(:null => false) }
|
|
42
|
-
it { should have_db_column(:updated_at).of_type(:datetime).with_options(:null => false) }
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
context 'columns' do
|
|
46
|
-
it { should have_db_column(:workspace_id).of_type(:integer).with_options(:null => false, :default =>1) }
|
|
47
|
-
it { should have_db_column(:created_by).of_type(:string) }
|
|
48
|
-
it { should have_db_column(:path).of_type(:string) }
|
|
49
|
-
it { should have_db_column(:name).of_type(:text) }
|
|
50
|
-
end
|
|
51
|
-
end
|
|
52
|
-
end
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
FactoryGirl.define do
|
|
2
|
-
factory :mdm_report, :aliases => [:report], :class => Mdm::Report do
|
|
3
|
-
#
|
|
4
|
-
# Associations
|
|
5
|
-
#
|
|
6
|
-
association :workspace, :factory => :mdm_workspace
|
|
7
|
-
name{generate :report_name}
|
|
8
|
-
end
|
|
9
|
-
|
|
10
|
-
sequence :report_name do |n|
|
|
11
|
-
"Some Report#{n}"
|
|
12
|
-
end
|
|
13
|
-
end
|