From 8cb72082fe34bce112dcfef4c38ae43556d0b1d9 Mon Sep 17 00:00:00 2001 From: Bruno Castro Date: Thu, 23 Aug 2018 10:30:20 -0300 Subject: [PATCH] feat: Add field velocity_strategy to projects --- CHANGELOG.md | 1 + app/api/entities/project.rb | 1 + app/controllers/projects_controller.rb | 2 +- app/helpers/projects_helper.rb | 8 ++++++++ app/views/projects/_form.html.erb | 11 ++++++++++- config/locales/en.yml | 5 +++++ config/locales/pt-BR.yml | 5 +++++ ...180823124914_add_velocity_strategy_to_projects.rb | 5 +++++ db/schema.rb | 3 ++- spec/api/entities/project_spec.rb | 6 ++++++ spec/helpers/projects_helper_spec.rb | 12 ++++++++++++ 11 files changed, 56 insertions(+), 3 deletions(-) create mode 100644 db/migrate/20180823124914_add_velocity_strategy_to_projects.rb diff --git a/CHANGELOG.md b/CHANGELOG.md index 7adad7f68..f5178278d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ ### Added - Option to archive teams - Added pusher-fake to the project +- Field velocity_strategy to projects ### Fixed - Fixed locale change when accessing user edit page diff --git a/app/api/entities/project.rb b/app/api/entities/project.rb index 9a2132510..242e5a53e 100644 --- a/app/api/entities/project.rb +++ b/app/api/entities/project.rb @@ -6,6 +6,7 @@ class Entities::Project < Entities::BaseEntity expose :iteration_start_day expose :iteration_length expose :default_velocity + expose :velocity_strategy expose :velocity, if: { type: :full } expose :volatility, if: { type: :full } expose :teams, using: Entities::Team diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index ebdaa1b88..74587da30 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -237,7 +237,7 @@ def allowed_params .fetch(:project) .permit(:name, :point_scale, :default_velocity, :tag_group_id, :start_date, :iteration_start_day, :iteration_length, :import, :archived, - :disallow_join, :mail_reports) + :disallow_join, :mail_reports, :velocity_strategy) end def fluid_layout diff --git a/app/helpers/projects_helper.rb b/app/helpers/projects_helper.rb index 7ff086e64..347d3c37e 100644 --- a/app/helpers/projects_helper.rb +++ b/app/helpers/projects_helper.rb @@ -107,4 +107,12 @@ def formatted_standard_deviation(standard_deviation) def inverse_story_flow 'pressed' if @story_flow[:current].eql?(@story_flow[:default]) end + + # Returns an array of valid velocity strategy options suitable for use in + # a select helper. + def velocity_strategy_options + (1..4).collect do |iterations| + [I18n.t('n velocity strategy', count: iterations), iterations] + end + end end diff --git a/app/views/projects/_form.html.erb b/app/views/projects/_form.html.erb index 2152735a5..350da6ebc 100644 --- a/app/views/projects/_form.html.erb +++ b/app/views/projects/_form.html.erb @@ -16,6 +16,15 @@ <%= f.text_field :default_velocity, length: 2, size: 3, class: 'form-control auth-form-control' %> +
+ <%= f.label :velocity_strategy %> + <%= f.select :velocity_strategy, + velocity_strategy_options, + {}, + { class:'form-control auth-form-control' } + %> +
+
<%= f.label :start_date, class: 'control-label' %>
<%= f.date_select :start_date, {}, { class: 'form-control auth-form-control' } %> @@ -52,7 +61,7 @@ <%= f.label :mail_reports, class: 'control-label' %> <%= f.check_box :mail_reports %>
- +
<%= f.submit nil, class: 'btn btn-primary btn-form' %> diff --git a/config/locales/en.yml b/config/locales/en.yml index ed9d88e1a..db48892c6 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -136,6 +136,10 @@ en: one: '1 week' other: '%{count} weeks' + n velocity strategy: + one: 'Average of 1 iteration' + other: 'Average of %{count} iterations' + keycuts: keyboard_shortcuts: Keyboard shortcuts help: Help (this) @@ -178,6 +182,7 @@ en: default_velocity: 'Default velocity' archived: 'Archived' mail_reports: 'Send reports via mail' + velocity_strategy: 'Velocity strategy' story: title: 'Title' description: 'Description' diff --git a/config/locales/pt-BR.yml b/config/locales/pt-BR.yml index d737c2332..22c02df25 100644 --- a/config/locales/pt-BR.yml +++ b/config/locales/pt-BR.yml @@ -133,6 +133,10 @@ pt-BR: one: '1 semana' other: '%{count} semanas' + n velocity strategy: + one: 'Média de 1 iteração' + other: 'Média de %{count} iterações' + keycuts: keyboard_shortcuts: Atalhos de teclado help: Ajuda (this) @@ -175,6 +179,7 @@ pt-BR: default_velocity: 'Velocidade padrão' archived: 'Arquivado' mail_reports: 'Enviar relatórios por email' + velocity_strategy: 'Estratégia de velocidade' story: title: 'Título' description: 'Descrição' diff --git a/db/migrate/20180823124914_add_velocity_strategy_to_projects.rb b/db/migrate/20180823124914_add_velocity_strategy_to_projects.rb new file mode 100644 index 000000000..8069266cf --- /dev/null +++ b/db/migrate/20180823124914_add_velocity_strategy_to_projects.rb @@ -0,0 +1,5 @@ +class AddVelocityStrategyToProjects < ActiveRecord::Migration + def change + add_column :projects, :velocity_strategy, :integer, default: 3 + end +end diff --git a/db/schema.rb b/db/schema.rb index 7c37b5a4c..49afd6051 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20170914172941) do +ActiveRecord::Schema.define(version: 20180823124914) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -170,6 +170,7 @@ t.boolean "disallow_join", default: true, null: false t.integer "tag_group_id" t.boolean "mail_reports", default: true + t.integer "velocity_strategy", default: 3 end add_index "projects", ["slug"], name: "index_projects_on_slug", unique: true, using: :btree diff --git a/spec/api/entities/project_spec.rb b/spec/api/entities/project_spec.rb index 13ad759a5..9de50e524 100644 --- a/spec/api/entities/project_spec.rb +++ b/spec/api/entities/project_spec.rb @@ -16,6 +16,12 @@ it { expect(subject[:volatility]).to be_nil } it { expect(subject[:mail_reports]).to be_truthy } + it do + expect( + subject[:velocity_strategy] + ).to eq(project.velocity_strategy) + end + context 'when call it with full type' do subject { described_class.represent(project, type: :full).as_json } diff --git a/spec/helpers/projects_helper_spec.rb b/spec/helpers/projects_helper_spec.rb index 5a6cc05b7..38a5205c6 100644 --- a/spec/helpers/projects_helper_spec.rb +++ b/spec/helpers/projects_helper_spec.rb @@ -30,4 +30,16 @@ end end end + + describe '#velocity_strategy_options' do + subject(:options) { helper.velocity_strategy_options } + + it 'returns an array containing translated options to use in a select' do + (1..4).each do |iteration| + expect(options).to include( + [I18n.t('n velocity strategy', count: iteration), iteration] + ) + end + end + end end