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 | 9 | end |
| 10 | 10 | |
| 11 | 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 | 17 | }.compact |
| 14 | 18 | end |
| 15 | 19 | |
| ... | ... | @@ -20,4 +24,10 @@ class KalibroConfiguration < KalibroClient::Entities::Configurations::KalibroCon |
| 20 | 24 | def attributes |
| 21 | 25 | KalibroConfigurationAttributes.find_by(kalibro_configuration_id: self.id) |
| 22 | 26 | end |
| 27 | + | |
| 28 | + def destroy | |
| 29 | + attrs = attributes | |
| 30 | + attrs.destroy unless attrs.nil? | |
| 31 | + super | |
| 32 | + end | |
| 23 | 33 | end | ... | ... |
app/models/reading_group.rb
| ... | ... | @@ -8,8 +8,12 @@ class ReadingGroup < KalibroClient::Entities::Configurations::ReadingGroup |
| 8 | 8 | ReadingGroupAttributes.where(public: true) |
| 9 | 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 | 17 | }.compact |
| 14 | 18 | end |
| 15 | 19 | ... | ... |
app/views/kalibro_configurations/_form.html.erb
| ... | ... | @@ -21,7 +21,7 @@ |
| 21 | 21 | <div class="form-row"> |
| 22 | 22 | <div class="field-container checkbox"> |
| 23 | 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 | 25 | </label> |
| 26 | 26 | </div> |
| 27 | 27 | </div> | ... | ... |
app/views/reading_groups/_form.html.erb
| ... | ... | @@ -19,7 +19,7 @@ |
| 19 | 19 | <div class="form-row"> |
| 20 | 20 | <div class="field-container checkbox"> |
| 21 | 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 | 23 | </label> |
| 24 | 24 | </div> |
| 25 | 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 | 1 | en: |
| 2 | 2 | about_mezuro: "About Mezuro" |
| 3 | 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 | 1 | pt: |
| 2 | 2 | about_mezuro: "Sobre Mezuro" |
| 3 | 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 | 2 | |
| 3 | 3 | describe KalibroConfiguration, :type => :model do |
| 4 | 4 | describe 'methods' do |
| 5 | - | |
| 6 | 5 | describe 'class methods' do |
| 7 | 6 | describe 'public_or_owned_by_user' do |
| 8 | 7 | def build_attrs(kc_iter, *traits, **params) |
| ... | ... | @@ -57,5 +56,21 @@ describe KalibroConfiguration, :type => :model do |
| 57 | 56 | end |
| 58 | 57 | end |
| 59 | 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 | 75 | end |
| 61 | 76 | end | ... | ... |