my_dashboard 0.4.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (148) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +13 -0
  3. data/.travis.yml +9 -0
  4. data/CHANGELOG.md +23 -0
  5. data/Gemfile +20 -0
  6. data/MIT-LICENSE +20 -0
  7. data/README.md +223 -0
  8. data/Rakefile +7 -0
  9. data/app/assets/javascripts/my_dashboard/application.js +17 -0
  10. data/app/assets/javascripts/my_dashboard/my_dashboard.coffee +0 -0
  11. data/app/assets/stylesheets/my_dashboard/application.css +13 -0
  12. data/app/controllers/my_dashboard/application_controller.rb +23 -0
  13. data/app/controllers/my_dashboard/dashboards_controller.rb +31 -0
  14. data/app/controllers/my_dashboard/events_controller.rb +28 -0
  15. data/app/controllers/my_dashboard/widgets_controller.rb +45 -0
  16. data/app/helpers/my_dashboard/application_helper.rb +4 -0
  17. data/app/views/layouts/my_dashboard/dashboard.html.erb +30 -0
  18. data/app/views/my_dashboard/widgets/clock.html +2 -0
  19. data/app/views/my_dashboard/widgets/comments.html +7 -0
  20. data/app/views/my_dashboard/widgets/graph.html +5 -0
  21. data/app/views/my_dashboard/widgets/iframe.html +1 -0
  22. data/app/views/my_dashboard/widgets/image.html +1 -0
  23. data/app/views/my_dashboard/widgets/list.html +18 -0
  24. data/app/views/my_dashboard/widgets/meter.html +7 -0
  25. data/app/views/my_dashboard/widgets/number.html +11 -0
  26. data/app/views/my_dashboard/widgets/text.html +7 -0
  27. data/bin/rails +8 -0
  28. data/config/routes.rb +15 -0
  29. data/lib/assets/javascripts/my_dashboard.gridster.coffee +0 -0
  30. data/lib/generators/my_dashboard/install_generator.rb +36 -0
  31. data/lib/generators/my_dashboard/job_generator.rb +15 -0
  32. data/lib/generators/my_dashboard/widget_generator.rb +17 -0
  33. data/lib/generators/templates/dashboards/sample.html.erb +28 -0
  34. data/lib/generators/templates/initializer.rb +58 -0
  35. data/lib/generators/templates/jobs/new.rb +3 -0
  36. data/lib/generators/templates/jobs/sample.rb +9 -0
  37. data/lib/generators/templates/layouts/dashboard.html.erb +30 -0
  38. data/lib/generators/templates/widgets/index.css +12 -0
  39. data/lib/generators/templates/widgets/index.js +13 -0
  40. data/lib/generators/templates/widgets/new.coffee +9 -0
  41. data/lib/generators/templates/widgets/new.html +1 -0
  42. data/lib/generators/templates/widgets/new.scss +10 -0
  43. data/lib/my_dashboard.rb +50 -0
  44. data/lib/my_dashboard/configuration.rb +63 -0
  45. data/lib/my_dashboard/engine.rb +7 -0
  46. data/lib/my_dashboard/railtie.rb +31 -0
  47. data/lib/my_dashboard/version.rb +3 -0
  48. data/lib/tasks/my_dashboard_tasks.rake +4 -0
  49. data/my_dashboard.gemspec +31 -0
  50. data/spec/controllers/my_dashboard/application_controller_spec.rb +21 -0
  51. data/spec/controllers/my_dashboard/dashboards_controller_spec.rb +46 -0
  52. data/spec/controllers/my_dashboard/events_controller_spec.rb +11 -0
  53. data/spec/controllers/my_dashboard/widgets_controller_spec.rb +72 -0
  54. data/spec/dummy/README.rdoc +28 -0
  55. data/spec/dummy/Rakefile +6 -0
  56. data/spec/dummy/app/assets/images/.keep +0 -0
  57. data/spec/dummy/app/assets/javascripts/application.js +13 -0
  58. data/spec/dummy/app/assets/javascripts/my_dashboard/widgets/foo.coffee +0 -0
  59. data/spec/dummy/app/assets/javascripts/my_dashboard/widgets/index.js +13 -0
  60. data/spec/dummy/app/assets/stylesheets/application.css +13 -0
  61. data/spec/dummy/app/assets/stylesheets/my_dashboard/widgets/foo.scss +0 -0
  62. data/spec/dummy/app/assets/stylesheets/my_dashboard/widgets/index.css +12 -0
  63. data/spec/dummy/app/controllers/application_controller.rb +5 -0
  64. data/spec/dummy/app/controllers/concerns/.keep +0 -0
  65. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  66. data/spec/dummy/app/jobs/sample.rb +9 -0
  67. data/spec/dummy/app/mailers/.keep +0 -0
  68. data/spec/dummy/app/models/.keep +0 -0
  69. data/spec/dummy/app/models/concerns/.keep +0 -0
  70. data/spec/dummy/app/views/layouts/application.html.erb +14 -0
  71. data/spec/dummy/app/views/layouts/my_dashboard/dashboard.html.erb +30 -0
  72. data/spec/dummy/app/views/my_dashboard/dashboards/foo.erb +0 -0
  73. data/spec/dummy/app/views/my_dashboard/dashboards/sample.html.erb +28 -0
  74. data/spec/dummy/app/views/my_dashboard/widgets/foo.html +0 -0
  75. data/spec/dummy/bin/bundle +3 -0
  76. data/spec/dummy/bin/rails +4 -0
  77. data/spec/dummy/bin/rake +4 -0
  78. data/spec/dummy/config.ru +4 -0
  79. data/spec/dummy/config/application.rb +23 -0
  80. data/spec/dummy/config/boot.rb +5 -0
  81. data/spec/dummy/config/database.yml +25 -0
  82. data/spec/dummy/config/environment.rb +5 -0
  83. data/spec/dummy/config/environments/development.rb +29 -0
  84. data/spec/dummy/config/environments/production.rb +80 -0
  85. data/spec/dummy/config/environments/test.rb +36 -0
  86. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  87. data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  88. data/spec/dummy/config/initializers/inflections.rb +16 -0
  89. data/spec/dummy/config/initializers/mime_types.rb +5 -0
  90. data/spec/dummy/config/initializers/my_dashboard.rb +58 -0
  91. data/spec/dummy/config/initializers/secret_token.rb +12 -0
  92. data/spec/dummy/config/initializers/session_store.rb +3 -0
  93. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
  94. data/spec/dummy/config/locales/en.yml +23 -0
  95. data/spec/dummy/config/routes.rb +3 -0
  96. data/spec/dummy/lib/assets/.keep +0 -0
  97. data/spec/dummy/log/.keep +0 -0
  98. data/spec/dummy/public/404.html +58 -0
  99. data/spec/dummy/public/422.html +58 -0
  100. data/spec/dummy/public/500.html +57 -0
  101. data/spec/dummy/public/favicon.ico +0 -0
  102. data/spec/lib/generators/widget_generator_spec.rb +26 -0
  103. data/spec/lib/my_dashboard/configuration_spec.rb +66 -0
  104. data/spec/lib/my_dashboard_spec.rb +55 -0
  105. data/spec/spec_helper.rb +52 -0
  106. data/spec/support/controller_spec_helpers.rb +9 -0
  107. data/vendor/assets/fonts/my_dashboard/fontawesome-webfont.eot +0 -0
  108. data/vendor/assets/fonts/my_dashboard/fontawesome-webfont.svg +414 -0
  109. data/vendor/assets/fonts/my_dashboard/fontawesome-webfont.ttf +0 -0
  110. data/vendor/assets/fonts/my_dashboard/fontawesome-webfont.woff +0 -0
  111. data/vendor/assets/javascripts/my_dashboard/batman.jquery.js +163 -0
  112. data/vendor/assets/javascripts/my_dashboard/batman.js +13680 -0
  113. data/vendor/assets/javascripts/my_dashboard/d3-3.2.8.min.js +5 -0
  114. data/vendor/assets/javascripts/my_dashboard/default_widgets/clock.coffee +18 -0
  115. data/vendor/assets/javascripts/my_dashboard/default_widgets/comments.coffee +24 -0
  116. data/vendor/assets/javascripts/my_dashboard/default_widgets/graph.coffee +37 -0
  117. data/vendor/assets/javascripts/my_dashboard/default_widgets/iframe.coffee +9 -0
  118. data/vendor/assets/javascripts/my_dashboard/default_widgets/image.coffee +9 -0
  119. data/vendor/assets/javascripts/my_dashboard/default_widgets/index.js +13 -0
  120. data/vendor/assets/javascripts/my_dashboard/default_widgets/list.coffee +6 -0
  121. data/vendor/assets/javascripts/my_dashboard/default_widgets/meter.coffee +14 -0
  122. data/vendor/assets/javascripts/my_dashboard/default_widgets/number.coffee +25 -0
  123. data/vendor/assets/javascripts/my_dashboard/default_widgets/text.coffee +1 -0
  124. data/vendor/assets/javascripts/my_dashboard/es5-shim.js +1021 -0
  125. data/vendor/assets/javascripts/my_dashboard/index.js +21 -0
  126. data/vendor/assets/javascripts/my_dashboard/jquery.gridster.js +3987 -0
  127. data/vendor/assets/javascripts/my_dashboard/jquery.js +4 -0
  128. data/vendor/assets/javascripts/my_dashboard/jquery.knob.js +646 -0
  129. data/vendor/assets/javascripts/my_dashboard/jquery.leanModal.min.js +5 -0
  130. data/vendor/assets/javascripts/my_dashboard/jquery.timeago.js +184 -0
  131. data/vendor/assets/javascripts/my_dashboard/moment.min.js +6 -0
  132. data/vendor/assets/javascripts/my_dashboard/my_dashboard.coffee +0 -0
  133. data/vendor/assets/javascripts/my_dashboard/rickshaw-1.5.1.min.js +3 -0
  134. data/vendor/assets/stylesheets/my_dashboard/font-awesome.scss +1338 -0
  135. data/vendor/assets/stylesheets/my_dashboard/index.css +15 -0
  136. data/vendor/assets/stylesheets/my_dashboard/jquery.gridster.css +121 -0
  137. data/vendor/assets/stylesheets/my_dashboard/my_dashboard.scss +302 -0
  138. data/vendor/assets/stylesheets/my_dashboard/widgets/clock.scss +13 -0
  139. data/vendor/assets/stylesheets/my_dashboard/widgets/comments.scss +33 -0
  140. data/vendor/assets/stylesheets/my_dashboard/widgets/graph.scss +65 -0
  141. data/vendor/assets/stylesheets/my_dashboard/widgets/iframe.scss +8 -0
  142. data/vendor/assets/stylesheets/my_dashboard/widgets/image.scss +13 -0
  143. data/vendor/assets/stylesheets/my_dashboard/widgets/index.css +12 -0
  144. data/vendor/assets/stylesheets/my_dashboard/widgets/list.scss +60 -0
  145. data/vendor/assets/stylesheets/my_dashboard/widgets/meter.scss +35 -0
  146. data/vendor/assets/stylesheets/my_dashboard/widgets/number.scss +39 -0
  147. data/vendor/assets/stylesheets/my_dashboard/widgets/text.scss +32 -0
  148. metadata +373 -0
@@ -0,0 +1,12 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Your secret key is used for verifying the integrity of signed cookies.
4
+ # If you change this key, all old signed cookies will become invalid!
5
+
6
+ # Make sure the secret is at least 30 characters and all random,
7
+ # no regular words or you'll be exposed to dictionary attacks.
8
+ # You can use `rake secret` to generate a secure secret key.
9
+
10
+ # Make sure your secret_key_base is kept private
11
+ # if you're sharing your code publicly.
12
+ Dummy::Application.config.secret_key_base = '845898d4e55cb9827dc3e2c2635be79027bbaee5e4a8bd478a4730e724f8b679fc1c110f4708c9cccfee0b6707fa5b7225630b649bfd75649577c08761335a29'
@@ -0,0 +1,3 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ Dummy::Application.config.session_store :cookie_store, key: '_dummy_session'
@@ -0,0 +1,14 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # This file contains settings for ActionController::ParamsWrapper which
4
+ # is enabled by default.
5
+
6
+ # Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
7
+ ActiveSupport.on_load(:action_controller) do
8
+ wrap_parameters format: [:json] if respond_to?(:wrap_parameters)
9
+ end
10
+
11
+ # To enable root element in JSON for ActiveRecord objects.
12
+ # ActiveSupport.on_load(:active_record) do
13
+ # self.include_root_in_json = true
14
+ # end
@@ -0,0 +1,23 @@
1
+ # Files in the config/locales directory are used for internationalization
2
+ # and are automatically loaded by Rails. If you want to use locales other
3
+ # than English, add the necessary files in this directory.
4
+ #
5
+ # To use the locales, use `I18n.t`:
6
+ #
7
+ # I18n.t 'hello'
8
+ #
9
+ # In views, this is aliased to just `t`:
10
+ #
11
+ # <%= t('hello') %>
12
+ #
13
+ # To use a different locale, set it with `I18n.locale`:
14
+ #
15
+ # I18n.locale = :es
16
+ #
17
+ # This would use the information in config/locales/es.yml.
18
+ #
19
+ # To learn more, please read the Rails Internationalization guide
20
+ # available at http://guides.rubyonrails.org/i18n.html.
21
+
22
+ en:
23
+ hello: "Hello world"
@@ -0,0 +1,3 @@
1
+ Rails.application.routes.draw do
2
+ mount MyDashboard::Engine, at: MyDashboard.config.engine_path
3
+ end
File without changes
File without changes
@@ -0,0 +1,58 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>The page you were looking for doesn't exist (404)</title>
5
+ <style>
6
+ body {
7
+ background-color: #EFEFEF;
8
+ color: #2E2F30;
9
+ text-align: center;
10
+ font-family: arial, sans-serif;
11
+ }
12
+
13
+ div.dialog {
14
+ width: 25em;
15
+ margin: 4em auto 0 auto;
16
+ border: 1px solid #CCC;
17
+ border-right-color: #999;
18
+ border-left-color: #999;
19
+ border-bottom-color: #BBB;
20
+ border-top: #B00100 solid 4px;
21
+ border-top-left-radius: 9px;
22
+ border-top-right-radius: 9px;
23
+ background-color: white;
24
+ padding: 7px 4em 0 4em;
25
+ }
26
+
27
+ h1 {
28
+ font-size: 100%;
29
+ color: #730E15;
30
+ line-height: 1.5em;
31
+ }
32
+
33
+ body > p {
34
+ width: 33em;
35
+ margin: 0 auto 1em;
36
+ padding: 1em 0;
37
+ background-color: #F7F7F7;
38
+ border: 1px solid #CCC;
39
+ border-right-color: #999;
40
+ border-bottom-color: #999;
41
+ border-bottom-left-radius: 4px;
42
+ border-bottom-right-radius: 4px;
43
+ border-top-color: #DADADA;
44
+ color: #666;
45
+ box-shadow:0 3px 8px rgba(50, 50, 50, 0.17);
46
+ }
47
+ </style>
48
+ </head>
49
+
50
+ <body>
51
+ <!-- This file lives in public/404.html -->
52
+ <div class="dialog">
53
+ <h1>The page you were looking for doesn't exist.</h1>
54
+ <p>You may have mistyped the address or the page may have moved.</p>
55
+ </div>
56
+ <p>If you are the application owner check the logs for more information.</p>
57
+ </body>
58
+ </html>
@@ -0,0 +1,58 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>The change you wanted was rejected (422)</title>
5
+ <style>
6
+ body {
7
+ background-color: #EFEFEF;
8
+ color: #2E2F30;
9
+ text-align: center;
10
+ font-family: arial, sans-serif;
11
+ }
12
+
13
+ div.dialog {
14
+ width: 25em;
15
+ margin: 4em auto 0 auto;
16
+ border: 1px solid #CCC;
17
+ border-right-color: #999;
18
+ border-left-color: #999;
19
+ border-bottom-color: #BBB;
20
+ border-top: #B00100 solid 4px;
21
+ border-top-left-radius: 9px;
22
+ border-top-right-radius: 9px;
23
+ background-color: white;
24
+ padding: 7px 4em 0 4em;
25
+ }
26
+
27
+ h1 {
28
+ font-size: 100%;
29
+ color: #730E15;
30
+ line-height: 1.5em;
31
+ }
32
+
33
+ body > p {
34
+ width: 33em;
35
+ margin: 0 auto 1em;
36
+ padding: 1em 0;
37
+ background-color: #F7F7F7;
38
+ border: 1px solid #CCC;
39
+ border-right-color: #999;
40
+ border-bottom-color: #999;
41
+ border-bottom-left-radius: 4px;
42
+ border-bottom-right-radius: 4px;
43
+ border-top-color: #DADADA;
44
+ color: #666;
45
+ box-shadow:0 3px 8px rgba(50, 50, 50, 0.17);
46
+ }
47
+ </style>
48
+ </head>
49
+
50
+ <body>
51
+ <!-- This file lives in public/422.html -->
52
+ <div class="dialog">
53
+ <h1>The change you wanted was rejected.</h1>
54
+ <p>Maybe you tried to change something you didn't have access to.</p>
55
+ </div>
56
+ <p>If you are the application owner check the logs for more information.</p>
57
+ </body>
58
+ </html>
@@ -0,0 +1,57 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>We're sorry, but something went wrong (500)</title>
5
+ <style>
6
+ body {
7
+ background-color: #EFEFEF;
8
+ color: #2E2F30;
9
+ text-align: center;
10
+ font-family: arial, sans-serif;
11
+ }
12
+
13
+ div.dialog {
14
+ width: 25em;
15
+ margin: 4em auto 0 auto;
16
+ border: 1px solid #CCC;
17
+ border-right-color: #999;
18
+ border-left-color: #999;
19
+ border-bottom-color: #BBB;
20
+ border-top: #B00100 solid 4px;
21
+ border-top-left-radius: 9px;
22
+ border-top-right-radius: 9px;
23
+ background-color: white;
24
+ padding: 7px 4em 0 4em;
25
+ }
26
+
27
+ h1 {
28
+ font-size: 100%;
29
+ color: #730E15;
30
+ line-height: 1.5em;
31
+ }
32
+
33
+ body > p {
34
+ width: 33em;
35
+ margin: 0 auto 1em;
36
+ padding: 1em 0;
37
+ background-color: #F7F7F7;
38
+ border: 1px solid #CCC;
39
+ border-right-color: #999;
40
+ border-bottom-color: #999;
41
+ border-bottom-left-radius: 4px;
42
+ border-bottom-right-radius: 4px;
43
+ border-top-color: #DADADA;
44
+ color: #666;
45
+ box-shadow:0 3px 8px rgba(50, 50, 50, 0.17);
46
+ }
47
+ </style>
48
+ </head>
49
+
50
+ <body>
51
+ <!-- This file lives in public/500.html -->
52
+ <div class="dialog">
53
+ <h1>We're sorry, but something went wrong.</h1>
54
+ </div>
55
+ <p>If you are the application owner check the logs for more information.</p>
56
+ </body>
57
+ </html>
File without changes
@@ -0,0 +1,26 @@
1
+ require 'spec_helper'
2
+ require 'generator_spec'
3
+ require 'generators/my_dashboard/widget_generator'
4
+ require 'codeclimate-test-reporter'
5
+ require 'coveralls'
6
+ CodeClimate::TestReporter.start
7
+ Coveralls.wear!
8
+
9
+ describe MyDashboard::Generators::WidgetGenerator do
10
+
11
+ arguments %w(test_widget)
12
+
13
+ before do
14
+ run_generator
15
+ end
16
+
17
+ after do
18
+ `find #{Rails.root.join('app')} -name "test_widget.*" -delete`
19
+ end
20
+
21
+ it 'creates widget files' do
22
+ assert_file Rails.root.join 'app/views/my_dashboard/widgets/test_widget.html'
23
+ assert_file Rails.root.join 'app/assets/javascripts/my_dashboard/widgets/test_widget.coffee'
24
+ assert_file Rails.root.join 'app/assets/stylesheets/my_dashboard/widgets/test_widget.scss'
25
+ end
26
+ end
@@ -0,0 +1,66 @@
1
+ require 'spec_helper'
2
+ require 'codeclimate-test-reporter'
3
+ require 'coveralls'
4
+ CodeClimate::TestReporter.start
5
+ Coveralls.wear!
6
+
7
+ describe MyDashboard::Configuration do
8
+
9
+ let(:instance) { MyDashboard::Configuration.new }
10
+
11
+ it { expect(instance.engine_path).to eq('/my_dashboard') }
12
+ # it { expect(instance.scheduler).to be_a(::Rufus::Scheduler.new) }
13
+ it { expect(instance.redis).to be_a(::Redis) }
14
+
15
+ # Redis
16
+ it { expect(instance.redis_host).to eq('127.0.0.1') }
17
+ it { expect(instance.redis_port).to eq('6379') }
18
+ it { expect(instance.redis_password).to be_nil }
19
+ it { expect(instance.redis_timeout).to eq(3) }
20
+ it { expect(instance.redis_namespace).to eq('my_dashboard_events') }
21
+
22
+ # Authorization
23
+ it { expect(instance.auth_token).to be_nil }
24
+ it { expect(instance.devise_allowed_models).to be_empty }
25
+
26
+ # Jobs
27
+ it { expect(instance.jobs_path.to_s).to include('app/jobs') }
28
+
29
+ # Dashboards
30
+ it { expect(instance.default_dashboard).to be_nil }
31
+ it { expect(instance.dashboards_views_path.to_s).to include('app/views/my_dashboard/dashboards') }
32
+ it { expect(instance.dashboard_layout_path).to eq('my_dashboard/dashboard') }
33
+
34
+ # Widgets
35
+ it { expect(instance.widgets_views_path.to_s).to include('app/views/my_dashboard/widgets') }
36
+ it { expect(instance.widgets_js_path.to_s).to include('app/assets/javascripts/my_dashboard') }
37
+ it { expect(instance.widgets_css_path.to_s).to include('app/assets/stylesheets/my_dashboard') }
38
+
39
+ describe '#request_thread_count' do
40
+
41
+ context 'when puma respond to cli_config' do
42
+
43
+ let(:value) { 2 }
44
+
45
+ before do
46
+ Object.const_set('Puma', Class.new)
47
+ ::Puma.stub_chain(:cli_config, :options).and_return(max_threads: value)
48
+ end
49
+
50
+ after do
51
+ Object.send(:remove_const, 'Puma') if defined?(Puma)
52
+ end
53
+
54
+ it { expect(instance.send(:request_thread_count)).to eq(value) }
55
+
56
+ end
57
+
58
+ context 'by default' do
59
+
60
+ it { expect(instance.send(:request_thread_count)).to eq(5) }
61
+
62
+ end
63
+
64
+ end
65
+
66
+ end
@@ -0,0 +1,55 @@
1
+ require 'spec_helper'
2
+ require 'codeclimate-test-reporter'
3
+ require 'coveralls'
4
+ CodeClimate::TestReporter.start
5
+ Coveralls.wear!
6
+
7
+ describe MyDashboard do
8
+
9
+ it { expect(MyDashboard).to respond_to :configuration }
10
+
11
+ describe '.config' do
12
+
13
+ it { expect(MyDashboard.config).to be_a(MyDashboard::Configuration) }
14
+
15
+ end
16
+
17
+ describe '.configure' do
18
+
19
+ let(:configuration) { MyDashboard::Configuration.new }
20
+
21
+ before do
22
+ allow(MyDashboard).to receive(:config).and_return(:configuration)
23
+ end
24
+
25
+ context 'when block given' do
26
+
27
+ it 'yields configuration' do
28
+ expect(MyDashboard).to receive(:configure).and_yield(configuration)
29
+ MyDashboard.configure {|config|}
30
+ end
31
+
32
+ end
33
+
34
+ context 'when no block given' do
35
+
36
+ it { expect(MyDashboard.configure).to be_nil }
37
+
38
+ end
39
+
40
+ end
41
+
42
+ describe '.first_dashboard' do
43
+
44
+ let(:dir) { 'foo' }
45
+ let(:dirs) { [dir] }
46
+
47
+ before do
48
+ allow(Dir).to receive(:[]).and_return(dirs)
49
+ end
50
+
51
+ it { expect(MyDashboard.first_dashboard).to eq(dir) }
52
+
53
+ end
54
+
55
+ end
@@ -0,0 +1,52 @@
1
+ require 'simplecov'
2
+ require 'codeclimate-test-reporter'
3
+ require 'coveralls'
4
+ CodeClimate::TestReporter.start
5
+ Coveralls.wear!
6
+
7
+ # This file is copied to spec/ when you run 'rails generate rspec:install'
8
+ ENV['RAILS_ENV'] ||= 'test'
9
+ ENGINE_RAILS_ROOT = File.join(File.dirname(__FILE__), '../')
10
+
11
+ require File.expand_path(ENGINE_RAILS_ROOT + 'spec/dummy/config/environment', __FILE__)
12
+ require 'rspec/rails'
13
+ require 'rspec/autorun'
14
+
15
+ # Requires supporting ruby files with custom matchers and macros, etc,
16
+ # in spec/support/ and its subdirectories.
17
+ Dir[File.join(File.dirname(__FILE__), '../', 'spec/support/**/*.rb')].each { |f| require f }
18
+
19
+ # Checks for pending migrations before tests are run.
20
+ # If you are not using ActiveRecord, you can remove this line.
21
+ # ActiveRecord::Migration.check_pending! if defined?(ActiveRecord::Migration)
22
+
23
+ RSpec.configure do |config|
24
+ config.include ControllerSpecHelpers, type: :controller
25
+
26
+ # ## Mock Framework
27
+ #
28
+ # If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
29
+ #
30
+ # config.mock_with :mocha
31
+ # config.mock_with :flexmock
32
+ # config.mock_with :rr
33
+
34
+ # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
35
+ # config.fixture_path = "#{::Rails.root}/spec/fixtures"
36
+
37
+ # If you're not using ActiveRecord, or you'd prefer not to run each of your
38
+ # examples within a transaction, remove the following line or assign false
39
+ # instead of true.
40
+ # config.use_transactional_fixtures = true
41
+
42
+ # If true, the base class of anonymous controllers will be inferred
43
+ # automatically. This will be the default behavior in future versions of
44
+ # rspec-rails.
45
+ config.infer_base_class_for_anonymous_controllers = true
46
+
47
+ # Run specs in random order to surface order dependencies. If you find an
48
+ # order dependency and want to debug it, you can fix the order by providing
49
+ # the seed, which is printed after each run.
50
+ # --seed 1234
51
+ config.order = 'random'
52
+ end