barras_rails 1.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) hide show
  1. checksums.yaml +7 -0
  2. data/Rakefile +22 -0
  3. data/app/assets/images/barras_rails/logo_uff_branco.svg +3 -0
  4. data/app/assets/javascripts/barras_rails/barras_rails.js +352 -0
  5. data/app/assets/stylesheets/barras_rails/barra_de_aplicacoes.css +143 -0
  6. data/app/assets/stylesheets/barras_rails/barra_do_governo.css +140 -0
  7. data/app/helpers/barras_rails/application_helper.rb +106 -0
  8. data/app/models/barra_aplicacoes.rb +31 -0
  9. data/app/models/url_api_nao_definida_error.rb +6 -0
  10. data/app/views/layouts/application.html.erb +14 -0
  11. data/app/views/layouts/barras_rails/_barra_aplicacoes.html.erb +27 -0
  12. data/app/views/layouts/barras_rails/_barra_governo.html.erb +18 -0
  13. data/config/routes.rb +2 -0
  14. data/lib/barras_rails/configuracao.rb +16 -0
  15. data/lib/barras_rails/engine.rb +12 -0
  16. data/lib/barras_rails/utilidades.rb +41 -0
  17. data/lib/barras_rails/version.rb +4 -0
  18. data/lib/barras_rails.rb +19 -0
  19. data/lib/generators/barras_rails/install_generator.rb +56 -0
  20. data/lib/generators/barras_rails/templates/barras_rails.rb +52 -0
  21. data/lib/generators/barras_rails/templates/logo_uff_branco.svg +3 -0
  22. data/lib/tasks/barras_tasks.rake +4 -0
  23. data/spec/dummy/README.rdoc +28 -0
  24. data/spec/dummy/Rakefile +6 -0
  25. data/spec/dummy/app/assets/javascripts/application.js +2 -0
  26. data/spec/dummy/app/assets/javascripts/jquery-2.1.4.min.js +4 -0
  27. data/spec/dummy/app/assets/stylesheets/application.css +5 -0
  28. data/spec/dummy/app/assets/stylesheets/reset.css +423 -0
  29. data/spec/dummy/app/controllers/application_controller.rb +11 -0
  30. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  31. data/spec/dummy/app/views/application/index.html.erb +1 -0
  32. data/spec/dummy/app/views/layouts/application.html.erb +19 -0
  33. data/spec/dummy/bin/bundle +3 -0
  34. data/spec/dummy/bin/rails +4 -0
  35. data/spec/dummy/bin/rake +4 -0
  36. data/spec/dummy/config/application.rb +34 -0
  37. data/spec/dummy/config/boot.rb +5 -0
  38. data/spec/dummy/config/database.yml +25 -0
  39. data/spec/dummy/config/environment.rb +5 -0
  40. data/spec/dummy/config/environments/development.rb +37 -0
  41. data/spec/dummy/config/environments/production.rb +78 -0
  42. data/spec/dummy/config/environments/test.rb +39 -0
  43. data/spec/dummy/config/initializers/assets.rb +8 -0
  44. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  45. data/spec/dummy/config/initializers/barras_uff.rb +31 -0
  46. data/spec/dummy/config/initializers/cookies_serializer.rb +3 -0
  47. data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  48. data/spec/dummy/config/initializers/inflections.rb +16 -0
  49. data/spec/dummy/config/initializers/mime_types.rb +4 -0
  50. data/spec/dummy/config/initializers/session_store.rb +3 -0
  51. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
  52. data/spec/dummy/config/locales/en.yml +23 -0
  53. data/spec/dummy/config/routes.rb +5 -0
  54. data/spec/dummy/config/secrets.yml +22 -0
  55. data/spec/dummy/config.ru +4 -0
  56. data/spec/dummy/db/development.sqlite3 +0 -0
  57. data/spec/dummy/db/schema.rb +2596 -0
  58. data/spec/dummy/db/test.sqlite3 +0 -0
  59. data/spec/dummy/public/404.html +67 -0
  60. data/spec/dummy/public/422.html +67 -0
  61. data/spec/dummy/public/500.html +66 -0
  62. data/spec/dummy/public/favicon.ico +0 -0
  63. data/spec/helpers/application_helper_spec.rb +178 -0
  64. data/spec/lib/configuracao_spec.rb +21 -0
  65. data/spec/models/barra_aplicacoes_spec.rb +0 -0
  66. data/spec/rails_helper.rb +55 -0
  67. data/spec/spec_helper.rb +31 -0
  68. metadata +281 -0
Binary file
@@ -0,0 +1,67 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>The page you were looking for doesn't exist (404)</title>
5
+ <meta name="viewport" content="width=device-width,initial-scale=1">
6
+ <style>
7
+ body {
8
+ background-color: #EFEFEF;
9
+ color: #2E2F30;
10
+ text-align: center;
11
+ font-family: arial, sans-serif;
12
+ margin: 0;
13
+ }
14
+
15
+ div.dialog {
16
+ width: 95%;
17
+ max-width: 33em;
18
+ margin: 4em auto 0;
19
+ }
20
+
21
+ div.dialog > div {
22
+ border: 1px solid #CCC;
23
+ border-right-color: #999;
24
+ border-left-color: #999;
25
+ border-bottom-color: #BBB;
26
+ border-top: #B00100 solid 4px;
27
+ border-top-left-radius: 9px;
28
+ border-top-right-radius: 9px;
29
+ background-color: white;
30
+ padding: 7px 12% 0;
31
+ box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
32
+ }
33
+
34
+ h1 {
35
+ font-size: 100%;
36
+ color: #730E15;
37
+ line-height: 1.5em;
38
+ }
39
+
40
+ div.dialog > p {
41
+ margin: 0 0 1em;
42
+ padding: 1em;
43
+ background-color: #F7F7F7;
44
+ border: 1px solid #CCC;
45
+ border-right-color: #999;
46
+ border-left-color: #999;
47
+ border-bottom-color: #999;
48
+ border-bottom-left-radius: 4px;
49
+ border-bottom-right-radius: 4px;
50
+ border-top-color: #DADADA;
51
+ color: #666;
52
+ box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
53
+ }
54
+ </style>
55
+ </head>
56
+
57
+ <body>
58
+ <!-- This file lives in public/404.html -->
59
+ <div class="dialog">
60
+ <div>
61
+ <h1>The page you were looking for doesn't exist.</h1>
62
+ <p>You may have mistyped the address or the page may have moved.</p>
63
+ </div>
64
+ <p>If you are the application owner check the logs for more information.</p>
65
+ </div>
66
+ </body>
67
+ </html>
@@ -0,0 +1,67 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>The change you wanted was rejected (422)</title>
5
+ <meta name="viewport" content="width=device-width,initial-scale=1">
6
+ <style>
7
+ body {
8
+ background-color: #EFEFEF;
9
+ color: #2E2F30;
10
+ text-align: center;
11
+ font-family: arial, sans-serif;
12
+ margin: 0;
13
+ }
14
+
15
+ div.dialog {
16
+ width: 95%;
17
+ max-width: 33em;
18
+ margin: 4em auto 0;
19
+ }
20
+
21
+ div.dialog > div {
22
+ border: 1px solid #CCC;
23
+ border-right-color: #999;
24
+ border-left-color: #999;
25
+ border-bottom-color: #BBB;
26
+ border-top: #B00100 solid 4px;
27
+ border-top-left-radius: 9px;
28
+ border-top-right-radius: 9px;
29
+ background-color: white;
30
+ padding: 7px 12% 0;
31
+ box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
32
+ }
33
+
34
+ h1 {
35
+ font-size: 100%;
36
+ color: #730E15;
37
+ line-height: 1.5em;
38
+ }
39
+
40
+ div.dialog > p {
41
+ margin: 0 0 1em;
42
+ padding: 1em;
43
+ background-color: #F7F7F7;
44
+ border: 1px solid #CCC;
45
+ border-right-color: #999;
46
+ border-left-color: #999;
47
+ border-bottom-color: #999;
48
+ border-bottom-left-radius: 4px;
49
+ border-bottom-right-radius: 4px;
50
+ border-top-color: #DADADA;
51
+ color: #666;
52
+ box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
53
+ }
54
+ </style>
55
+ </head>
56
+
57
+ <body>
58
+ <!-- This file lives in public/422.html -->
59
+ <div class="dialog">
60
+ <div>
61
+ <h1>The change you wanted was rejected.</h1>
62
+ <p>Maybe you tried to change something you didn't have access to.</p>
63
+ </div>
64
+ <p>If you are the application owner check the logs for more information.</p>
65
+ </div>
66
+ </body>
67
+ </html>
@@ -0,0 +1,66 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>We're sorry, but something went wrong (500)</title>
5
+ <meta name="viewport" content="width=device-width,initial-scale=1">
6
+ <style>
7
+ body {
8
+ background-color: #EFEFEF;
9
+ color: #2E2F30;
10
+ text-align: center;
11
+ font-family: arial, sans-serif;
12
+ margin: 0;
13
+ }
14
+
15
+ div.dialog {
16
+ width: 95%;
17
+ max-width: 33em;
18
+ margin: 4em auto 0;
19
+ }
20
+
21
+ div.dialog > div {
22
+ border: 1px solid #CCC;
23
+ border-right-color: #999;
24
+ border-left-color: #999;
25
+ border-bottom-color: #BBB;
26
+ border-top: #B00100 solid 4px;
27
+ border-top-left-radius: 9px;
28
+ border-top-right-radius: 9px;
29
+ background-color: white;
30
+ padding: 7px 12% 0;
31
+ box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
32
+ }
33
+
34
+ h1 {
35
+ font-size: 100%;
36
+ color: #730E15;
37
+ line-height: 1.5em;
38
+ }
39
+
40
+ div.dialog > p {
41
+ margin: 0 0 1em;
42
+ padding: 1em;
43
+ background-color: #F7F7F7;
44
+ border: 1px solid #CCC;
45
+ border-right-color: #999;
46
+ border-left-color: #999;
47
+ border-bottom-color: #999;
48
+ border-bottom-left-radius: 4px;
49
+ border-bottom-right-radius: 4px;
50
+ border-top-color: #DADADA;
51
+ color: #666;
52
+ box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
53
+ }
54
+ </style>
55
+ </head>
56
+
57
+ <body>
58
+ <!-- This file lives in public/500.html -->
59
+ <div class="dialog">
60
+ <div>
61
+ <h1>We're sorry, but something went wrong.</h1>
62
+ </div>
63
+ <p>If you are the application owner check the logs for more information.</p>
64
+ </div>
65
+ </body>
66
+ </html>
File without changes
@@ -0,0 +1,178 @@
1
+ require 'spec_helper'
2
+
3
+ RSpec.describe ApplicationHelper, type: :helper do
4
+ describe 'Métodos' do
5
+ describe '#barra_governo' do
6
+ it 'deve renderizar o partial da barra do governo' do
7
+ template = { partial: 'layouts/barras_rails/barra_governo' }
8
+ allow(helper).to receive(:render)
9
+ helper.barra_governo
10
+ expect(helper).to have_received(:render).with(template)
11
+ end
12
+ end
13
+
14
+ describe '#barra_aplicacoes' do
15
+ it 'deve renderizar o partial da barra de aplicações' do
16
+ allow(helper).to receive(:get_aplicacoes).and_return([])
17
+ template = { partial: 'layouts/barras_rails/barra_aplicacoes' }
18
+ allow(helper).to receive(:render)
19
+ helper.barra_aplicacoes(:aluno)
20
+ expect(helper).to have_received(:render).with(template)
21
+ end
22
+
23
+ it 'deve setar o hash de dados da barra' do
24
+ allow(helper).to receive(:get_aplicacoes).and_return([])
25
+ helper.barra_aplicacoes(:aluno)
26
+ var_barra = helper.instance_variable_get(:@barra)
27
+ expect(var_barra).to be_a(Hash)
28
+ end
29
+
30
+ it 'deve setar as aplicações no hash de dados' do
31
+ expect(helper).to receive(:get_aplicacoes).and_return([])
32
+ helper.barra_aplicacoes(:aluno)
33
+ aplicacoes = helper.instance_variable_get(:@barra)[:aplicacoes]
34
+ expect(aplicacoes).to eq([])
35
+ end
36
+
37
+ it 'deve setar o limite de links no hash de dados' do
38
+ expect(BarrasRails.configuracao).to receive(:limite_links_visiveis)
39
+ .and_return(7)
40
+ allow(helper).to receive(:get_aplicacoes).and_return([])
41
+ helper.barra_aplicacoes(:aluno)
42
+ limite_links = helper.instance_variable_get(:@barra)[:limite_links]
43
+ expect(limite_links).to eq(7)
44
+ end
45
+ end
46
+
47
+ describe '#barras_governo_e_aplicacoes' do
48
+ before :each do
49
+ allow(helper).to receive(:get_aplicacoes).and_return([])
50
+ end
51
+
52
+ context 'deve chamar os métodos' do
53
+ it '#barra_governo e #barra_aplicacoes' do
54
+ expect(helper).to receive(:barra_governo).and_return('')
55
+ expect(helper).to receive(:barra_aplicacoes).and_return('')
56
+ helper.barras_governo_e_aplicacoes(:aluno)
57
+ end
58
+ end
59
+
60
+ context 'deve retornar html' do
61
+ it 'contendo a barra do governo' do
62
+ barras = helper.barras_governo_e_aplicacoes(:aluno)
63
+ expect(barras).to include('div id="barra-brasil"')
64
+ end
65
+
66
+ it 'contendo a barra de aplicacoes' do
67
+ barras = helper.barras_governo_e_aplicacoes(:aluno)
68
+ expect(barras).to include('div id="barra-aplicacoes"')
69
+ end
70
+ end
71
+ end
72
+
73
+ describe '#item_barra_aplicacoes' do
74
+ before :each do
75
+ @path = '/minha_app'
76
+ @label = 'Minha App'
77
+ end
78
+
79
+ it 'deve retornar uma string' do
80
+ expect(helper.item_barra_aplicacoes(@path, @label)).to be_a(String)
81
+ end
82
+
83
+ it 'deve retornar uma string contendo uma tag <li></li>' do
84
+ item = helper.item_barra_aplicacoes(@path, @label)
85
+ expect(item).to include('<li')
86
+ expect(item).to include('</li>')
87
+ end
88
+
89
+ it 'deve retornar uma string contendo o path' do
90
+ item = helper.item_barra_aplicacoes(@path, @label)
91
+ expect(item).to include(@path)
92
+ end
93
+
94
+ it 'deve retornar uma string contendo a label' do
95
+ item = helper.item_barra_aplicacoes(@path, @label)
96
+ expect(item).to include(@label)
97
+ end
98
+ end
99
+
100
+ describe '#deve_incluir_link_login' do
101
+ context 'Quando o usuário está logado' do
102
+ before :each do
103
+ session[:usuario] = 'iduff_de_alguem'
104
+ end
105
+
106
+ it 'deve exibir o link de deslogar se a config for true' do
107
+ expect(BarrasRails.configuracao).to receive(:incluir_link_de_deslogar)
108
+ .and_return(true)
109
+ expect(helper.deve_incluir_link_login).to be_truthy
110
+ end
111
+
112
+ it 'não deve exibir o link de deslogar se a config for false' do
113
+ expect(BarrasRails.configuracao).to receive(:incluir_link_de_deslogar)
114
+ .and_return(false)
115
+ expect(helper.deve_incluir_link_login).to be_falsey
116
+ end
117
+ end
118
+
119
+ context 'Quando o usuário não está logado' do
120
+ it 'deve exibir o link de logar se a config for true' do
121
+ expect(BarrasRails.configuracao).to receive(:incluir_link_de_login)
122
+ .and_return(true)
123
+ expect(helper.deve_incluir_link_login).to be_truthy
124
+ end
125
+
126
+ it 'não deve exibir o link de logar se a config for false' do
127
+ expect(BarrasRails.configuracao).to receive(:incluir_link_de_login)
128
+ .and_return(false)
129
+ expect(helper.deve_incluir_link_login).to be_falsey
130
+ end
131
+ end
132
+ end
133
+
134
+ describe '#link_de_login_ou_logout' do
135
+ context 'Quando o usuário está logado' do
136
+ before :each do
137
+ session[:usuario] = 'iduff_de_alguem'
138
+ end
139
+
140
+ it 'deve exibir o link de deslogar se a config for true' do
141
+ expect(BarrasRails.configuracao).to receive(:incluir_link_de_deslogar)
142
+ .and_return(true)
143
+ expect(helper).to receive(:link_de_deslogar)
144
+ helper.link_de_login_ou_logout
145
+ end
146
+
147
+ it 'não deve exibir o link de deslogar se a config for false' do
148
+ expect(BarrasRails.configuracao).to receive(:incluir_link_de_deslogar)
149
+ .and_return(false)
150
+ expect(helper).not_to receive(:link_de_deslogar)
151
+ helper.link_de_login_ou_logout
152
+ end
153
+ end
154
+
155
+ context 'Quando o usuário não está logado' do
156
+ it 'deve exibir o link de logar se a config for true' do
157
+ expect(BarrasRails.configuracao).to receive(:incluir_link_de_login)
158
+ .and_return(true)
159
+ expect(helper).to receive(:link_de_logar)
160
+ helper.link_de_login_ou_logout
161
+ end
162
+
163
+ it 'não deve exibir o link de logar se a config for false' do
164
+ expect(BarrasRails.configuracao).to receive(:incluir_link_de_login)
165
+ .and_return(false)
166
+ expect(helper).not_to receive(:link_de_logar)
167
+ helper.link_de_login_ou_logout
168
+ end
169
+ end
170
+ end
171
+
172
+ describe '#link_de_logar' do
173
+ it 'TODO', skip: 'Definir como o método vai se comportar' do
174
+
175
+ end
176
+ end
177
+ end
178
+ end
@@ -0,0 +1,21 @@
1
+ require 'spec_helper'
2
+
3
+ RSpec.describe BarrasRails::Configuracao do
4
+ before :each do
5
+ BarrasRails.configurar do |config|
6
+ config.limite_links_visiveis = 5
7
+ config.incluir_link_de_deslogar = true
8
+ end
9
+ end
10
+
11
+ it 'config de limite de links visíveis deve existir e ser um fixnum' do
12
+ expect(BarrasRails.configuracao.limite_links_visiveis).not_to be_nil
13
+ expect(BarrasRails.configuracao.limite_links_visiveis).to be_a(Fixnum)
14
+ end
15
+
16
+ it 'config de incluir_deslogar deve existir e ser um boolean' do
17
+ incluir_deslogar = BarrasUff.configuracao.incluir_link_de_deslogar
18
+ expect(incluir_deslogar).not_to be_nil
19
+ expect(!!incluir_deslogar).to eq(incluir_deslogar)
20
+ end
21
+ end
File without changes
@@ -0,0 +1,55 @@
1
+ # This file is copied to spec/ when you run 'rails generate rspec:install'
2
+ ENV['RAILS_ENV'] ||= 'test'
3
+
4
+ require File.expand_path('../dummy/config/environment.rb', __FILE__)
5
+
6
+ # Prevent database truncation if the environment is production
7
+
8
+ if Rails.env.production?
9
+ abort('The Rails environment is running in production mode!')
10
+ end
11
+
12
+ require 'rspec/rails'
13
+
14
+ # Add additional requires below this line. Rails is not loaded until this point!
15
+
16
+ # Requires supporting ruby files with custom matchers and macros, etc, in
17
+ # spec/support/ and its subdirectories. Files matching `spec/**/*_spec.rb` are
18
+ # run as spec files by default. This means that files in spec/support that end
19
+ # in _spec.rb will both be required and run as specs, causing the specs to be
20
+ # run twice. It is recommended that you do not name files matching this glob to
21
+ # end with _spec.rb. You can configure this pattern with the --pattern
22
+ # option on the command line or in ~/.rspec, .rspec or `.rspec-local`.
23
+ #
24
+ # The following line is provided for convenience purposes. It has the downside
25
+ # of increasing the boot-up time by auto-requiring all files in the support
26
+ # directory. Alternatively, in the individual `*_spec.rb` files, manually
27
+ # require only the support files necessary.
28
+ #
29
+ # Dir[Rails.root.join('spec/support/**/*.rb')].each { |f| require f }
30
+
31
+ # Checks for pending migrations before tests are run.
32
+ # If you are not using ActiveRecord, you can remove this line.
33
+ ActiveRecord::Migration.maintain_test_schema!
34
+
35
+ RSpec.configure do |config|
36
+ # If you're not using ActiveRecord, or you'd prefer not to run each of your
37
+ # examples within a transaction, remove the following line or assign false
38
+ # instead of true.
39
+ config.use_transactional_fixtures = true
40
+
41
+ # RSpec Rails can automatically mix in different behaviours to your tests
42
+ # based on their file location, for example enabling you to call `get` and
43
+ # `post` in specs under `spec/controllers`.
44
+ #
45
+ # You can disable this behaviour by removing the line below, and instead
46
+ # explicitly tag your specs with their type, e.g.:
47
+ #
48
+ # RSpec.describe UsersController, :type => :controller do
49
+ # # ...
50
+ # end
51
+ #
52
+ # The different available types are documented in the features, such as in
53
+ # https://relishapp.com/rspec/rspec-rails/docs
54
+ config.infer_spec_type_from_file_location!
55
+ end
@@ -0,0 +1,31 @@
1
+ ENV['RAILS_ENV'] ||= 'test'
2
+
3
+ require File.expand_path('../dummy/config/environment.rb', __FILE__)
4
+
5
+ require 'rspec/rails'
6
+ require 'pry'
7
+ require 'barras_rails'
8
+
9
+ Rails.backtrace_cleaner.remove_silencers!
10
+
11
+ # Load support files
12
+ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
13
+
14
+ RSpec.configure do |config|
15
+ config.use_transactional_fixtures = true
16
+ config.infer_base_class_for_anonymous_controllers = false
17
+ config.order = 'random'
18
+
19
+ # Habilita a sintaxe antiga
20
+ config.mock_with :rspec do |c|
21
+ c.syntax = [:should, :expect]
22
+ end
23
+ # Habilita a sintaxe antiga
24
+ config.expect_with :rspec do |c|
25
+ c.syntax = [:should, :expect]
26
+ end
27
+
28
+ config.formatter = 'documentation'
29
+
30
+ config.infer_spec_type_from_file_location!
31
+ end