puppet-herald 0.2.0 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (74) hide show
  1. checksums.yaml +5 -13
  2. data/.gitignore +3 -0
  3. data/.jshintrc +19 -0
  4. data/Gemfile +25 -12
  5. data/Gemfile.local.example +3 -0
  6. data/Guardfile +57 -0
  7. data/README.md +1 -1
  8. data/Rakefile +100 -20
  9. data/db/migrate/20141218200108_remove_no_of_reports_from_nodes.rb +7 -0
  10. data/lib/puppet-herald.rb +95 -65
  11. data/lib/puppet-herald/app/api.rb +79 -12
  12. data/lib/puppet-herald/app/configuration.rb +47 -15
  13. data/lib/puppet-herald/app/frontend.rb +6 -6
  14. data/lib/puppet-herald/app/views/app.erb +14 -20
  15. data/lib/puppet-herald/app/views/err500.erb +8 -5
  16. data/lib/puppet-herald/application.rb +9 -1
  17. data/lib/puppet-herald/cli.rb +5 -11
  18. data/lib/puppet-herald/database.rb +1 -7
  19. data/lib/puppet-herald/javascript.rb +16 -10
  20. data/lib/puppet-herald/models.rb +47 -0
  21. data/lib/puppet-herald/models/log-entry.rb +2 -0
  22. data/lib/puppet-herald/models/node.rb +49 -2
  23. data/lib/puppet-herald/models/report.rb +33 -9
  24. data/lib/puppet-herald/project.js +46 -0
  25. data/lib/puppet-herald/public/app.js +11 -9
  26. data/lib/puppet-herald/public/bower.json +10 -3
  27. data/lib/puppet-herald/public/components/artifact/artifact-directive.js +4 -0
  28. data/lib/puppet-herald/public/components/artifact/artifact.js +1 -3
  29. data/lib/puppet-herald/public/components/directives/directives.js +5 -1
  30. data/lib/puppet-herald/public/components/directives/status-button.html +1 -1
  31. data/lib/puppet-herald/public/components/directives/status-button.js +11 -11
  32. data/lib/puppet-herald/public/components/filters/filters.js +6 -2
  33. data/lib/puppet-herald/public/components/page.js +2 -2
  34. data/lib/puppet-herald/public/components/pagination.js +142 -0
  35. data/lib/puppet-herald/public/components/settings.js +25 -0
  36. data/lib/puppet-herald/public/css/herald.css +100 -3
  37. data/lib/puppet-herald/public/general/app.html +73 -0
  38. data/lib/puppet-herald/public/img/shield97-white.svg +53 -0
  39. data/lib/puppet-herald/public/img/shield97.png +0 -0
  40. data/lib/puppet-herald/public/node/node.html +27 -9
  41. data/lib/puppet-herald/public/node/node.js +43 -15
  42. data/lib/puppet-herald/public/nodes/nodes.html +25 -7
  43. data/lib/puppet-herald/public/nodes/nodes.js +29 -14
  44. data/lib/puppet-herald/public/report/report.html +60 -13
  45. data/lib/puppet-herald/public/report/report.js +21 -14
  46. data/lib/puppet-herald/public/router.js +55 -0
  47. data/lib/puppet-herald/purgecronjob.rb +35 -0
  48. data/lib/puppet-herald/version.rb +2 -2
  49. data/package.json +14 -16
  50. data/puppet-herald.gemspec +12 -7
  51. data/spec/integration/app/configuration_spec.rb +33 -0
  52. data/spec/integration/application_spec.rb +139 -20
  53. data/spec/integration/fixtures/nodes.yml +13 -0
  54. data/spec/integration/fixtures/pending-notify.yaml +346 -0
  55. data/spec/integration/fixtures/reports.yml +61 -0
  56. data/spec/integration/models/node_spec.rb +12 -3
  57. data/spec/integration/models/report_spec.rb +60 -4
  58. data/spec/spec_helper.rb +6 -10
  59. data/spec/support/active_record.rb +1 -0
  60. data/spec/support/fixtures.rb +16 -0
  61. data/spec/unit/puppet-herald/cli_spec.rb +4 -4
  62. data/spec/unit/puppet-herald/database_spec.rb +5 -3
  63. data/spec/unit/puppet-herald/purgecronjob_spec.rb +37 -0
  64. data/test/javascript/.bowerrc +3 -0
  65. data/test/javascript/bower.json +21 -0
  66. data/test/javascript/karma.conf.js +17 -22
  67. data/test/javascript/src/app_test.js +10 -61
  68. data/test/javascript/src/components/directives/status-button_test.js +10 -10
  69. data/test/javascript/src/components/paginate_test.js +183 -0
  70. data/test/javascript/src/node/node_test.js +16 -6
  71. data/test/javascript/src/nodes/nodes_test.js +14 -2
  72. data/test/javascript/src/report/report_test.js +6 -6
  73. data/test/javascript/src/router_test.js +79 -0
  74. metadata +642 -23
@@ -0,0 +1,61 @@
1
+ ---
2
+
3
+ master_r1:
4
+ id: 1
5
+ status: 'changed'
6
+ environment: 'production'
7
+ transaction_uuid: '4dda18fb-c4cf-412a-94f6-43d9420e9582'
8
+ configuration_version: '12345678'
9
+ puppet_version: '3.7.3'
10
+ kind: 'apply'
11
+ host: 'master.vm'
12
+ time: '2014-12-17T15:34:08'
13
+ node_id: 1
14
+
15
+ master_r2:
16
+ id: 2
17
+ status: 'failed'
18
+ environment: 'production'
19
+ transaction_uuid: '1d9a613b-a8b1-44d4-87fa-ab8143c8d403'
20
+ configuration_version: '12345698'
21
+ puppet_version: '3.7.3'
22
+ kind: 'apply'
23
+ host: 'master.vm'
24
+ time: '2014-12-17T16:04:08'
25
+ node_id: 1
26
+
27
+ master_r3:
28
+ id: 3
29
+ status: 'unchanged'
30
+ environment: 'production'
31
+ transaction_uuid: 'd28a1795-cc74-42b3-ab9d-88df5fff14cc'
32
+ configuration_version: '12345712'
33
+ puppet_version: '3.7.3'
34
+ kind: 'apply'
35
+ host: 'master.vm'
36
+ time: '2014-12-17T16:34:08'
37
+ node_id: 1
38
+
39
+ master_r4:
40
+ id: 4
41
+ status: 'unchanged'
42
+ environment: 'production'
43
+ transaction_uuid: 'e33516ae-1b28-40b5-89da-615cd73cf324'
44
+ configuration_version: '12345721'
45
+ puppet_version: '3.7.3'
46
+ kind: 'apply'
47
+ host: 'master.vm'
48
+ time: '2014-12-17T17:04:08'
49
+ node_id: 1
50
+
51
+ master_r5:
52
+ id: 5
53
+ status: 'changed'
54
+ environment: 'production'
55
+ transaction_uuid: '7b639655-ba23-4e2c-b81b-80c7dbefd157'
56
+ configuration_version: '12345756'
57
+ puppet_version: '3.7.3'
58
+ kind: 'apply'
59
+ host: 'master.vm'
60
+ time: '2014-12-17T17:34:08'
61
+ node_id: 1
@@ -2,13 +2,14 @@ require 'model_helper'
2
2
  require 'puppet-herald/models/report'
3
3
  require 'puppet-herald/models/log-entry'
4
4
  require 'puppet-herald/models/node'
5
+ require 'puppet-herald/models'
5
6
 
6
- describe PuppetHerald::Models::Node, '.get_with_reports', :rollback => true do
7
+ describe PuppetHerald::Models::Node, '.with_reports', :rollback => true do
7
8
  let(:yaml) { File.read(File.expand_path("../../fixtures/changed-notify.yaml", __FILE__)) }
8
9
  let(:id) { PuppetHerald::Models::Report.create_from_yaml(yaml).node_id }
9
10
 
10
11
  context 'fetching an existing node' do
11
- subject { PuppetHerald::Models::Node.get_with_reports id }
12
+ subject { PuppetHerald::Models::Node.with_reports id }
12
13
 
13
14
  it "should return value that isn't nil" do
14
15
  subject.should_not be_nil
@@ -17,10 +18,18 @@ describe PuppetHerald::Models::Node, '.get_with_reports', :rollback => true do
17
18
  subject.class.should eq(PuppetHerald::Models::Node)
18
19
  end
19
20
  it "should return persisted node" do
20
- subject.persisted?.should be_truthy
21
+ subject.persisted?.should be_falsy
21
22
  end
22
23
  it "should have status 'changed'" do
23
24
  subject.status.should eq('changed')
24
25
  end
25
26
  end
27
+
28
+ context 'paginating nodes' do
29
+ let(:pagination) { PuppetHerald::Models::Pagination.new(1, 10) }
30
+ subject { PuppetHerald::Models::Node.paginate(pagination) }
31
+ it "should return value that isn't nil" do
32
+ expect(subject).to_not be_nil
33
+ end
34
+ end
26
35
  end
@@ -3,7 +3,7 @@ require 'puppet-herald/models/report'
3
3
  require 'puppet-herald/models/log-entry'
4
4
 
5
5
  describe PuppetHerald::Models::Report, ".create_from_yaml", :rollback => true do
6
- context 'for valid YAML' do
6
+ context 'for `changed` status report' do
7
7
  let(:yaml) { File.read(File.expand_path("../../fixtures/changed-notify.yaml", __FILE__)) }
8
8
  it 'that is really not empty' do
9
9
  yaml.should_not be_empty
@@ -28,21 +28,53 @@ describe PuppetHerald::Models::Report, ".create_from_yaml", :rollback => true do
28
28
  log.persisted?.should be_truthy
29
29
  end
30
30
  end
31
- it "should have parent node, that is persistedand has status 'changed'" do
31
+ it "should have parent node, that is persisted and has status 'changed'" do
32
32
  subject.node.should_not be_nil
33
33
  subject.node.status.should eq('changed')
34
34
  subject.node.persisted?.should be_truthy
35
35
  end
36
36
  end
37
37
  end
38
+ context 'for `pending` status report' do
39
+ let(:yaml) { File.read(File.expand_path("../../fixtures/pending-notify.yaml", __FILE__)) }
40
+ it 'that is really not empty' do
41
+ expect(yaml).to_not be_empty
42
+ end
43
+ context 'running on real sqlite3 db' do
44
+ subject { PuppetHerald::Models::Report.create_from_yaml yaml }
45
+ it "should return value that isn't nil" do
46
+ subject.should_not be_nil
47
+ end
48
+ it "should return a report object" do
49
+ subject.class.should eq(PuppetHerald::Models::Report)
50
+ end
51
+ it "should return persisted report" do
52
+ subject.persisted?.should be_truthy
53
+ end
54
+ it "should have status 'pending'" do
55
+ subject.status.should eq('pending')
56
+ end
57
+ it "should have 11 log entries, also persisted" do
58
+ subject.log_entries.size.should eq(11)
59
+ subject.log_entries.each do |log|
60
+ log.persisted?.should be_truthy
61
+ end
62
+ end
63
+ it "should have parent node, that is persisted and has status 'pending'" do
64
+ subject.node.should_not be_nil
65
+ subject.node.status.should eq('pending')
66
+ subject.node.persisted?.should be_truthy
67
+ end
68
+ end
69
+ end
38
70
  end
39
71
 
40
- describe PuppetHerald::Models::Report, '.get_with_log_entries', :rollback => true do
72
+ describe PuppetHerald::Models::Report, '.with_log_entries', :rollback => true do
41
73
  let(:yaml) { File.read(File.expand_path("../../fixtures/changed-notify.yaml", __FILE__)) }
42
74
  let(:id) { PuppetHerald::Models::Report.create_from_yaml(yaml).id }
43
75
 
44
76
  context 'fetching an existing report' do
45
- subject { PuppetHerald::Models::Report.get_with_log_entries id }
77
+ subject { PuppetHerald::Models::Report.with_log_entries id }
46
78
 
47
79
  it "should return value that isn't nil" do
48
80
  subject.should_not be_nil
@@ -68,4 +100,28 @@ describe PuppetHerald::Models::Report, '.get_with_log_entries', :rollback => tru
68
100
  subject.node.persisted?.should be_truthy
69
101
  end
70
102
  end
103
+ end
104
+
105
+ describe PuppetHerald::Models::Report, '.purge_older_then', :rollback => true do
106
+ let(:yaml1) { File.read(File.expand_path("../../fixtures/changed-notify.yaml", __FILE__)) }
107
+ let(:yaml2) { File.read(File.expand_path("../../fixtures/pending-notify.yaml", __FILE__)) }
108
+ let(:date) { DateTime.new(2015, 4, 8, 14, 20, 0, '+2') }
109
+ before(:each) do
110
+ PuppetHerald::Models::LogEntry.delete_all
111
+ PuppetHerald::Models::Report.delete_all
112
+ PuppetHerald::Models::Node.delete_all
113
+ PuppetHerald::Models::Report.create_from_yaml(yaml1)
114
+ PuppetHerald::Models::Report.create_from_yaml(yaml1)
115
+ PuppetHerald::Models::Report.create_from_yaml(yaml2)
116
+ end
117
+ subject { PuppetHerald::Models::Report.purge_older_then(date) }
118
+ context 'running on real sqlite3 db with date `2015-04-08 14:20:00+0200`' do
119
+ it 'return `2` as a number of a reports purged' do
120
+ expect(PuppetHerald::Models::Node.count).to eq(1)
121
+ expect(PuppetHerald::Models::Report.count).to eq(3)
122
+ expect(subject).to eq(2)
123
+ expect(PuppetHerald::Models::Report.count).to eq(1)
124
+ expect(PuppetHerald::Models::Node.count).to eq(1)
125
+ end
126
+ end
71
127
  end
data/spec/spec_helper.rb CHANGED
@@ -3,6 +3,12 @@ require 'rspec/its'
3
3
  begin
4
4
  gem 'simplecov'
5
5
  require 'simplecov'
6
+ require 'simplecov-lcov'
7
+ SimpleCov::Formatter::LcovFormatter.report_with_single_file = true
8
+ SimpleCov.formatters = [
9
+ SimpleCov::Formatter::HTMLFormatter,
10
+ SimpleCov::Formatter::LcovFormatter,
11
+ ]
6
12
  SimpleCov.start do
7
13
  add_filter '/test/'
8
14
  add_filter '/spec/'
@@ -21,16 +27,6 @@ rescue Gem::LoadError
21
27
  # do nothing
22
28
  end
23
29
 
24
- begin
25
- gem 'coveralls'
26
- require 'coveralls'
27
- if ENV['TRAVIS']
28
- Coveralls.wear!
29
- end
30
- rescue Gem::LoadError
31
- # do nothing
32
- end
33
-
34
30
  begin
35
31
  gem 'pry'
36
32
  require 'pry'
@@ -1,4 +1,5 @@
1
1
  require 'support/reconnectdb'
2
+ require 'support/fixtures'
2
3
 
3
4
  reconnectdb
4
5
 
@@ -0,0 +1,16 @@
1
+ require 'sinatra/activerecord'
2
+ require 'rspec-activerecord'
3
+
4
+ RSpec.configure do |c|
5
+ c.fixture_path = File.expand_path("../../integration/fixtures", __FILE__)
6
+ c.use_transactional_fixtures = true
7
+ end
8
+
9
+ def fixtures(symbol)
10
+ ActiveRecord::FixtureSet.create_fixtures(RSpec.configuration.fixture_path, symbol.to_s)
11
+ end
12
+
13
+ def fixture(type, name)
14
+ fixture_set = ActiveRecord::FixtureSet.all_loaded_fixtures[type.to_s]
15
+ fixture_set.fixtures.find { |k, v| k == name.to_s }.second
16
+ end
@@ -2,6 +2,7 @@ require 'spec_helper'
2
2
  require 'puppet-herald'
3
3
  require 'puppet-herald/cli'
4
4
  require 'sinatra/base'
5
+ require 'sinatra/activerecord'
5
6
 
6
7
  class TestCLI < PuppetHerald::CLI
7
8
  def test_parse(argv)
@@ -14,9 +15,9 @@ context 'With silenced loggers' do
14
15
  let(:cli) { TestCLI.new }
15
16
 
16
17
  before :each do
17
- cli.logger.level = 100
18
- cli.errlogger.level = 100
19
- PuppetHerald::database::logger.level = 100
18
+ PuppetHerald.environment = :test
19
+ PuppetHerald.logger.level = 100
20
+ PuppetHerald.errlogger.level = 100
20
21
  PuppetHerald::database::dbconn = nil
21
22
  allow(FileUtils).to receive(:touch)
22
23
  end
@@ -43,7 +44,6 @@ context 'With silenced loggers' do
43
44
  context 'on defaults' do
44
45
  let(:argv) { [] }
45
46
  before :each do
46
- expect(PuppetHerald).to receive(:in_dev?).at_least(:once).and_return(false)
47
47
  expect(Kernel).to receive(:exit).with(0)
48
48
  expect(Sinatra::Application).to receive(:run!).and_return :none
49
49
  dbconn = { :adapter => 'sqlite3', :database => ':memory:' }
@@ -2,6 +2,11 @@ require 'spec_helper'
2
2
  require 'puppet-herald'
3
3
 
4
4
  describe PuppetHerald::Database, '.spec' do
5
+ before(:each) do
6
+ PuppetHerald.environment = :test
7
+ PuppetHerald.logger.level = 100
8
+ PuppetHerald.errlogger.level = 100
9
+ end
5
10
  let(:tempdir) { Dir.tmpdir }
6
11
  let(:echo) { false }
7
12
  subject { PuppetHerald::database::spec echo }
@@ -26,9 +31,6 @@ describe PuppetHerald::Database, '.spec' do
26
31
  its(:size) { should eq 2 }
27
32
  context 'while echoing!!' do
28
33
  let(:echo) { true }
29
- before :each do
30
- PuppetHerald::database::logger.level = Logger::FATAL
31
- end
32
34
  its(:class) { should be Hash }
33
35
  its(:size) { should eq 2 }
34
36
  end
@@ -0,0 +1,37 @@
1
+ require 'puppet-herald/purgecronjob'
2
+
3
+ describe PuppetHerald::PurgeCronJob do
4
+ let(:job) { PuppetHerald::PurgeCronJob.new }
5
+ let(:now) { DateTime.new(2015,4,9,20,3,2,'+2') }
6
+ let(:minus30d) { DateTime.new(2015,3,10,20,3,2,'+2') }
7
+ let(:minus45d) { DateTime.new(2015,2,23,20,3,2,'+2') }
8
+ before(:each) do
9
+ expect(DateTime).to receive(:now).and_return(now)
10
+ ENV['PUPPET_HERALD_PURGE_CRON'] = '*/15 * * * * *'
11
+ ENV['PUPPET_HERALD_PURGE_LIMIT'] = '45d'
12
+ end
13
+ describe '.parse_limit' do
14
+ it 'with "30d" to be equal to `2015-03-10 20:03:02 +0200`' do
15
+ expect(job.parse_limit '30d').to eq(minus30d)
16
+ end
17
+ it 'with "45d" to be equal to `2015-02-23 20:03:02 +0200`' do
18
+ expect(job.parse_limit '45d').to eq(minus45d)
19
+ end
20
+ end
21
+ describe '.run!' do
22
+ level = nil
23
+ before(:each) do
24
+ require 'puppet-herald'
25
+ require 'puppet-herald/models/report'
26
+ expect(PuppetHerald::Models::Report).to receive(:purge_older_then).with(minus45d).and_return(2)
27
+ level = PuppetHerald.logger.level
28
+ PuppetHerald.logger.level = 100
29
+ end
30
+ after(:each) do
31
+ PuppetHerald.logger.level = level
32
+ end
33
+ it 'executes properlly' do
34
+ expect(job.run!).to be_nil
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,3 @@
1
+ {
2
+ "directory": "bower_components"
3
+ }
@@ -0,0 +1,21 @@
1
+ {
2
+ "name": "puppet-herald",
3
+ "description": "Report processor for Puppet",
4
+ "version": "0.2.0",
5
+ "homepage": "https://github.com/wavesoftware/gem-puppet-herald",
6
+ "license": "Apache-2.0",
7
+ "private": false,
8
+ "dependencies": {
9
+ "angular": "1.3.x",
10
+ "angular-moment": "0.10.x",
11
+ "angular-ui-router": "0.2.x",
12
+ "bootstrap": "3.3.x",
13
+ "angular-utils-pagination": "0.6.x",
14
+ "angular-breadcrumb": "0.3.x",
15
+ "ngstorage": "0.3.x"
16
+ },
17
+ "devDependencies": {
18
+ "angular-loader": "1.3.x",
19
+ "angular-mocks": "1.3.x"
20
+ }
21
+ }
@@ -1,7 +1,15 @@
1
+ var project = require('../../lib/puppet-herald/project');
2
+
3
+ var files = project.dependencies.
4
+ concat(project.devDependencies).
5
+ concat(project.files.js).
6
+ concat(project.files.html).
7
+ concat(project.files.tests);
8
+
1
9
  module.exports = function(config) {
2
10
  config.set({
3
11
 
4
- basePath: '../..',
12
+ basePath: project.cwd,
5
13
 
6
14
  singleRun: true,
7
15
 
@@ -9,23 +17,20 @@ module.exports = function(config) {
9
17
 
10
18
  reporters: ['story', 'coverage'],
11
19
 
12
- preprocessors: {
13
- // source files, that you wanna generate coverage for
14
- // do not include tests or libraries
15
- // (these files will be instrumented by Istanbul)
16
- 'lib/puppet-herald/public/**/*.js': ['coverage'],
17
- 'lib/puppet-herald/public/**/*.html': ['ng-html2js']
18
- },
20
+ // source files, that you wanna generate coverage for
21
+ // do not include tests or libraries
22
+ // (these files will be instrumented by Istanbul)
23
+ preprocessors: project.preprocessors,
19
24
 
20
25
  // optionally, configure the reporter
21
26
  coverageReporter: {
22
27
  dir : 'coverage/javascript',
23
28
  reporters: [
24
29
  // reporters not supporting the `file` property
25
- { type: 'html', subdir: 'report-html' },
30
+ { type: 'lcov', subdir: 'lcov' },
26
31
  // reporters supporting the `file` property, use `subdir` to directly
27
32
  // output them in the `dir` directory
28
- { type: 'cobertura', subdir: '.', file: 'cobertura.txt' },
33
+ { type: 'cobertura', subdir: '.', file: 'cobertura.xml' },
29
34
  { type: 'text', subdir: '.', file: 'text.txt' },
30
35
  { type: 'text-summary', subdir: '.', file: 'text-summary.txt' },
31
36
  ]
@@ -33,19 +38,9 @@ module.exports = function(config) {
33
38
 
34
39
  ngHtml2JsPreprocessor: {
35
40
  // strip this from the file path
36
- stripPrefix: 'lib/puppet-herald/public/',
41
+ stripPrefix: project.publicDir + '/',
37
42
  },
38
43
 
39
- files: [
40
- 'node_modules/angular/angular.js',
41
- 'node_modules/angular-loader/angular-loader.js',
42
- 'node_modules/angular-mocks/angular-mocks.js',
43
- 'node_modules/angular-route/angular-route.js',
44
- 'node_modules/moment/moment.js',
45
- 'node_modules/angular-moment/angular-moment.js',
46
- 'lib/puppet-herald/public/**/*.js',
47
- 'lib/puppet-herald/public/**/*.html',
48
- 'test/javascript/src/**/*.js'
49
- ]
44
+ files: files
50
45
  });
51
46
  };
@@ -13,78 +13,27 @@ describe('herald module', function() {
13
13
  }));
14
14
 
15
15
  it('should have a `null` as page set by default', function() {
16
- expect(controller.page).toEqual(null);
16
+ expect(scope.page).toEqual(null);
17
17
  });
18
18
 
19
- it('should have a ("Nodes", null) as page set, if Page.title("Nodes") was called before', function() {
19
+ it('should have ("Nodes", null), after Page.title("Nodes") call', function() {
20
20
  Page.title('Nodes');
21
- expect(controller.page).toEqual("Nodes");
22
- expect(controller.target).toEqual(undefined);
21
+ expect(scope.page).toEqual("Nodes");
22
+ expect(scope.target).toEqual(undefined);
23
23
  });
24
24
 
25
- it('should have a ("Report", 1234567) as page set, if Page.title("Report", 1234567) was called before', function() {
25
+ it('should have ("Report", 1234567), after Page.title("Report", 1234567) call', function() {
26
26
  Page.title('Report', 1234567);
27
- expect(controller.page).toEqual("Report");
28
- expect(controller.target).toEqual(1234567);
27
+ expect(scope.page).toEqual("Report");
28
+ expect(scope.target).toEqual(1234567);
29
29
  });
30
30
 
31
- it('should have a ("Node", "master") as page set, if Page.title("Node", "master", " - ") was called before', function() {
31
+ it('should have ("Node", "master"), after Page.title("Node", "master", " - ") call', function() {
32
32
  Page.title('Node', "master", ' - ');
33
- expect(controller.page).toEqual("Node");
34
- expect(controller.target).toEqual('master');
33
+ expect(scope.page).toEqual("Node");
34
+ expect(scope.target).toEqual('master');
35
35
  });
36
36
 
37
37
  });
38
38
 
39
- describe('routes mapping', function() {
40
-
41
- var $route, $location, $rootScope, navigateTo;
42
- beforeEach(module('nodes/nodes.html'));
43
- beforeEach(module('node/node.html'));
44
- beforeEach(module('report/report.html'));
45
- beforeEach(inject(function(_$route_, _$location_, _$rootScope_) {
46
- $route = _$route_;
47
- $location = _$location_;
48
- $rootScope = _$rootScope_;
49
- navigateTo = function(address) {
50
- expect($route.current).toBeUndefined();
51
- $location.path(address);
52
- $rootScope.$digest();
53
- };
54
- }));
55
-
56
- it('should map NodesController for unknown address', function() {
57
- expect($route.routes[null].redirectTo).toEqual('/nodes');
58
- });
59
- it('should map NodesController if given "/nodes"', function() {
60
- expect($route.routes['/nodes'].controller).toBe('NodesController');
61
- });
62
-
63
- it('should navigate to "/nodes" if given "/" a address', function() {
64
- navigateTo('/');
65
- expect($route.current.controller).toBe('NodesController');
66
- expect($route.current.originalPath).toBe('/nodes');
67
- });
68
-
69
- it('should navigate to "/nodes" if given "/non-existing-link-0" a address', function() {
70
- navigateTo('/non-existing-link-0');
71
- expect($route.current.controller).toBe('NodesController');
72
- expect($route.current.originalPath).toBe('/nodes');
73
- });
74
-
75
- it('should navigate to "/node/1" if given "/node/1" a address', function() {
76
- navigateTo('/node/1');
77
- expect($route.current.controller).toBe('NodeController');
78
- expect($route.current.originalPath).toBe('/node/:nodeId');
79
- expect($route.current.pathParams.nodeId).toBe('1');
80
- });
81
-
82
- it('should navigate to "/report/1" if given "/report/1" a address', function() {
83
- navigateTo('/report/1');
84
- expect($route.current.controller).toBe('ReportController');
85
- expect($route.current.originalPath).toBe('/report/:reportId');
86
- expect($route.current.pathParams.reportId).toBe('1');
87
- });
88
-
89
- });
90
39
  });