Commit c4dca0da2089751e48e68dd8baa1fc156cf96857
Committed by
Diego Camarinha
1 parent
113e79cb
Exists in
colab
and in
4 other branches
Added translations for public reading groups and configurations
Signed-off-by: Daniel Miranda <danielkza2@gmail.com> Signed off by: Pedro Scocco <pedroscocco@gmail.com>
Showing
9 changed files
with
37 additions
and
20 deletions
Show diff stats
app/models/kalibro_configuration.rb
@@ -9,7 +9,11 @@ class KalibroConfiguration < KalibroClient::Entities::Configurations::KalibroCon | @@ -9,7 +9,11 @@ class KalibroConfiguration < KalibroClient::Entities::Configurations::KalibroCon | ||
9 | end | 9 | end |
10 | 10 | ||
11 | query.map { |cfg_attr| | 11 | query.map { |cfg_attr| |
12 | - self.find(cfg_attr.kalibro_configuration_id) | 12 | + begin |
13 | + self.find(cfg_attr.kalibro_configuration_id) | ||
14 | + rescue KalibroClient::Errors::RecordNotFound | ||
15 | + nil | ||
16 | + end | ||
13 | }.compact | 17 | }.compact |
14 | end | 18 | end |
15 | 19 | ||
@@ -20,4 +24,10 @@ class KalibroConfiguration < KalibroClient::Entities::Configurations::KalibroCon | @@ -20,4 +24,10 @@ class KalibroConfiguration < KalibroClient::Entities::Configurations::KalibroCon | ||
20 | def attributes | 24 | def attributes |
21 | KalibroConfigurationAttributes.find_by(kalibro_configuration_id: self.id) | 25 | KalibroConfigurationAttributes.find_by(kalibro_configuration_id: self.id) |
22 | end | 26 | end |
27 | + | ||
28 | + def destroy | ||
29 | + attrs = attributes | ||
30 | + attrs.destroy unless attrs.nil? | ||
31 | + super | ||
32 | + end | ||
23 | end | 33 | end |
app/models/reading_group.rb
@@ -8,8 +8,12 @@ class ReadingGroup < KalibroClient::Entities::Configurations::ReadingGroup | @@ -8,8 +8,12 @@ class ReadingGroup < KalibroClient::Entities::Configurations::ReadingGroup | ||
8 | ReadingGroupAttributes.where(public: true) | 8 | ReadingGroupAttributes.where(public: true) |
9 | end | 9 | end |
10 | 10 | ||
11 | - query.map { |cfg_attr| | ||
12 | - self.find(cfg_attr.reading_group_id) | 11 | + query.map { |rg_attr| |
12 | + begin | ||
13 | + self.find(rg_attr.reading_group_id) | ||
14 | + rescue KalibroClient::Errors::RecordNotFound | ||
15 | + nil | ||
16 | + end | ||
13 | }.compact | 17 | }.compact |
14 | end | 18 | end |
15 | 19 |
app/views/kalibro_configurations/_form.html.erb
@@ -21,7 +21,7 @@ | @@ -21,7 +21,7 @@ | ||
21 | <div class="form-row"> | 21 | <div class="form-row"> |
22 | <div class="field-container checkbox"> | 22 | <div class="field-container checkbox"> |
23 | <label> | 23 | <label> |
24 | - <%= check_box :attributes, :public %> <%= t('activemodel.attributes.kalibro_configuration_attributes_label.public') %> | 24 | + <%= check_box :attributes, :public %> <%= t('should_be_public') %> |
25 | </label> | 25 | </label> |
26 | </div> | 26 | </div> |
27 | </div> | 27 | </div> |
app/views/reading_groups/_form.html.erb
@@ -19,7 +19,7 @@ | @@ -19,7 +19,7 @@ | ||
19 | <div class="form-row"> | 19 | <div class="form-row"> |
20 | <div class="field-container checkbox"> | 20 | <div class="field-container checkbox"> |
21 | <label> | 21 | <label> |
22 | - <%= check_box :attributes, :public %> <%= t('activemodel.attributes.kalibro_configuration_attributes_label.public') %> | 22 | + <%= check_box :attributes, :public %> <%= t('should_be_public') %> |
23 | </label> | 23 | </label> |
24 | </div> | 24 | </div> |
25 | </div> | 25 | </div> |
config/locales/views/kalibro_configuration_attributes/en.yml
config/locales/views/kalibro_configuration_attributes/pt.yml
config/locales/views/shared/en.yml
1 | en: | 1 | en: |
2 | about_mezuro: "About Mezuro" | 2 | about_mezuro: "About Mezuro" |
3 | about_mezuro_body_html: "The Mezuro project attempts to provide a platform to compare projects and metric techniques, teaching how to use metrics through configurations and code analysis, avoid technical debts and disseminate code metrics usage and understanding.<br>Here you can try the front-end, which we call Prezento. It interacts with the %{href} and %{href2}. It is intended to be a service where you can evaluate your code quality and, if you want, define which set of metrics to use." | 3 | about_mezuro_body_html: "The Mezuro project attempts to provide a platform to compare projects and metric techniques, teaching how to use metrics through configurations and code analysis, avoid technical debts and disseminate code metrics usage and understanding.<br>Here you can try the front-end, which we call Prezento. It interacts with the %{href} and %{href2}. It is intended to be a service where you can evaluate your code quality and, if you want, define which set of metrics to use." |
4 | + should_be_public: "Visible to everyone" |
config/locales/views/shared/pt.yml
1 | pt: | 1 | pt: |
2 | about_mezuro: "Sobre Mezuro" | 2 | about_mezuro: "Sobre Mezuro" |
3 | about_mezuro_body_html: "O projeto Mezuro tenta prover uma plataforma para comparar técnicas de projetos e métricas, ensinando como usar métricas através de configurações e análise de código, evitando débitos técnicos e disseminando o uso e entendimento de métricas de código.<br>Aqui você pode experimentar a interface, que nós chamamos de Prezento. Ela interage com o %{href} e o %{href2}. A ideia é ser um serviço em que vocẽ pode avaliar a qualidade do seu código e, se você quiser, definir um conjunto de métricas a serem usadas." | 3 | about_mezuro_body_html: "O projeto Mezuro tenta prover uma plataforma para comparar técnicas de projetos e métricas, ensinando como usar métricas através de configurações e análise de código, evitando débitos técnicos e disseminando o uso e entendimento de métricas de código.<br>Aqui você pode experimentar a interface, que nós chamamos de Prezento. Ela interage com o %{href} e o %{href2}. A ideia é ser um serviço em que vocẽ pode avaliar a qualidade do seu código e, se você quiser, definir um conjunto de métricas a serem usadas." |
4 | + should_be_public: "Visível para todos" |
spec/models/kalibro_configuration_spec.rb
@@ -2,7 +2,6 @@ require 'rails_helper' | @@ -2,7 +2,6 @@ require 'rails_helper' | ||
2 | 2 | ||
3 | describe KalibroConfiguration, :type => :model do | 3 | describe KalibroConfiguration, :type => :model do |
4 | describe 'methods' do | 4 | describe 'methods' do |
5 | - | ||
6 | describe 'class methods' do | 5 | describe 'class methods' do |
7 | describe 'public_or_owned_by_user' do | 6 | describe 'public_or_owned_by_user' do |
8 | def build_attrs(kc_iter, *traits, **params) | 7 | def build_attrs(kc_iter, *traits, **params) |
@@ -57,5 +56,21 @@ describe KalibroConfiguration, :type => :model do | @@ -57,5 +56,21 @@ describe KalibroConfiguration, :type => :model do | ||
57 | end | 56 | end |
58 | end | 57 | end |
59 | end | 58 | end |
59 | + | ||
60 | + describe 'destroy' do | ||
61 | + context 'when attributes exist' do | ||
62 | + let!(:kalibro_configuration_attributes) { FactoryGirl.build(:kalibro_configuration_attributes) } | ||
63 | + let!(:kalibro_configuration) { kalibro_configuration_attributes.kalibro_configuration } | ||
64 | + before do | ||
65 | + kalibro_configuration.expects(:attributes).returns(kalibro_configuration_attributes) | ||
66 | + end | ||
67 | + | ||
68 | + it 'should be destroyed' do | ||
69 | + kalibro_configuration_attributes.expects(:destroy) | ||
70 | + KalibroClient::Entities::Configurations::KalibroConfiguration.any_instance.expects(:destroy).returns(kalibro_configuration) | ||
71 | + kalibro_configuration.destroy | ||
72 | + end | ||
73 | + end | ||
74 | + end | ||
60 | end | 75 | end |
61 | end | 76 | end |