Commit 04c3f27d13f6503529ef5861708a44a0c97e4445
1 parent
83b1c12f
Exists in
colab
and in
4 other branches
Regular users sould not be able to make a configuration or a reading
group private. Signed off by: Heitor Reis <marcheing@gmail.com>
Showing
8 changed files
with
5 additions
and
43 deletions
Show diff stats
app/controllers/kalibro_configurations_controller.rb
@@ -3,6 +3,7 @@ include OwnershipAuthentication | @@ -3,6 +3,7 @@ include OwnershipAuthentication | ||
3 | class KalibroConfigurationsController < ApplicationController | 3 | class KalibroConfigurationsController < ApplicationController |
4 | before_action :authenticate_user!, except: [:index, :show] | 4 | before_action :authenticate_user!, except: [:index, :show] |
5 | before_action :kalibro_configuration_owner?, only: [:edit, :update, :destroy] | 5 | before_action :kalibro_configuration_owner?, only: [:edit, :update, :destroy] |
6 | + before_action :set_kalibro_configuration, only: [:show, :edit, :update, :destroy] | ||
6 | 7 | ||
7 | # GET /kalibro_configurations/new | 8 | # GET /kalibro_configurations/new |
8 | def new | 9 | def new |
@@ -27,7 +28,6 @@ class KalibroConfigurationsController < ApplicationController | @@ -27,7 +28,6 @@ class KalibroConfigurationsController < ApplicationController | ||
27 | # GET /kalibro_configurations/1 | 28 | # GET /kalibro_configurations/1 |
28 | # GET /kalibro_configurations/1.json | 29 | # GET /kalibro_configurations/1.json |
29 | def show | 30 | def show |
30 | - set_kalibro_configuration | ||
31 | Rails.cache.fetch("#{@kalibro_configuration.id}_metric_configurations") do | 31 | Rails.cache.fetch("#{@kalibro_configuration.id}_metric_configurations") do |
32 | @kalibro_configuration.metric_configurations | 32 | @kalibro_configuration.metric_configurations |
33 | end | 33 | end |
@@ -35,15 +35,10 @@ class KalibroConfigurationsController < ApplicationController | @@ -35,15 +35,10 @@ class KalibroConfigurationsController < ApplicationController | ||
35 | 35 | ||
36 | # GET /kalibro_configurations/1/edit | 36 | # GET /kalibro_configurations/1/edit |
37 | # GET /kalibro_configurations/1/edit.json | 37 | # GET /kalibro_configurations/1/edit.json |
38 | - def edit | ||
39 | - set_kalibro_configuration | ||
40 | - @attributes = @kalibro_configuration.attributes | ||
41 | - end | 38 | + def edit; end |
42 | 39 | ||
43 | def update | 40 | def update |
44 | - set_kalibro_configuration | ||
45 | if @kalibro_configuration.update(kalibro_configuration_params) | 41 | if @kalibro_configuration.update(kalibro_configuration_params) |
46 | - @kalibro_configuration.attributes.update(public: attributes_params) | ||
47 | redirect_to(kalibro_configuration_path(@kalibro_configuration.id)) | 42 | redirect_to(kalibro_configuration_path(@kalibro_configuration.id)) |
48 | else | 43 | else |
49 | render "edit" | 44 | render "edit" |
@@ -53,8 +48,6 @@ class KalibroConfigurationsController < ApplicationController | @@ -53,8 +48,6 @@ class KalibroConfigurationsController < ApplicationController | ||
53 | # DELETE /kalibro_configurations/1 | 48 | # DELETE /kalibro_configurations/1 |
54 | # DELETE /kalibro_configurations/1.json | 49 | # DELETE /kalibro_configurations/1.json |
55 | def destroy | 50 | def destroy |
56 | - set_kalibro_configuration | ||
57 | - | ||
58 | @kalibro_configuration.destroy | 51 | @kalibro_configuration.destroy |
59 | 52 | ||
60 | respond_to do |format| | 53 | respond_to do |format| |
@@ -77,14 +70,10 @@ class KalibroConfigurationsController < ApplicationController | @@ -77,14 +70,10 @@ class KalibroConfigurationsController < ApplicationController | ||
77 | params[:kalibro_configuration] | 70 | params[:kalibro_configuration] |
78 | end | 71 | end |
79 | 72 | ||
80 | - def attributes_params | ||
81 | - params[:attributes][:public] == "1" | ||
82 | - end | ||
83 | - | ||
84 | # Extracted code from create action | 73 | # Extracted code from create action |
85 | def create_and_redir(format) | 74 | def create_and_redir(format) |
86 | if @kalibro_configuration.save | 75 | if @kalibro_configuration.save |
87 | - current_user.kalibro_configuration_attributes.create(kalibro_configuration_id: @kalibro_configuration.id, public: attributes_params) | 76 | + current_user.kalibro_configuration_attributes.create(kalibro_configuration_id: @kalibro_configuration.id) |
88 | 77 | ||
89 | format.html { redirect_to kalibro_configuration_path(@kalibro_configuration.id), notice: t('successfully_created', :record => @kalibro_configuration.model_name.human) } | 78 | format.html { redirect_to kalibro_configuration_path(@kalibro_configuration.id), notice: t('successfully_created', :record => @kalibro_configuration.model_name.human) } |
90 | format.json { render action: 'show', status: :created, location: @kalibro_configuration } | 79 | format.json { render action: 'show', status: :created, location: @kalibro_configuration } |
app/controllers/reading_groups_controller.rb
@@ -8,7 +8,6 @@ class ReadingGroupsController < ApplicationController | @@ -8,7 +8,6 @@ class ReadingGroupsController < ApplicationController | ||
8 | # GET /reading_groups/new | 8 | # GET /reading_groups/new |
9 | def new | 9 | def new |
10 | @reading_group = ReadingGroup.new | 10 | @reading_group = ReadingGroup.new |
11 | - @attributes = @reading_group.attributes | ||
12 | end | 11 | end |
13 | 12 | ||
14 | # GET /reading_groups | 13 | # GET /reading_groups |
@@ -32,13 +31,10 @@ class ReadingGroupsController < ApplicationController | @@ -32,13 +31,10 @@ class ReadingGroupsController < ApplicationController | ||
32 | 31 | ||
33 | # GET /reading_groups/1/edit | 32 | # GET /reading_groups/1/edit |
34 | # GET /reading_groups/1/edit.json | 33 | # GET /reading_groups/1/edit.json |
35 | - def edit | ||
36 | - @attributes = @reading_group.attributes | ||
37 | - end | 34 | + def edit; end |
38 | 35 | ||
39 | def update | 36 | def update |
40 | if @reading_group.update(reading_group_params) | 37 | if @reading_group.update(reading_group_params) |
41 | - @reading_group.attributes.update(public: attributes_params) | ||
42 | redirect_to(reading_group_path(@reading_group.id)) | 38 | redirect_to(reading_group_path(@reading_group.id)) |
43 | else | 39 | else |
44 | render "edit" | 40 | render "edit" |
@@ -67,15 +63,11 @@ class ReadingGroupsController < ApplicationController | @@ -67,15 +63,11 @@ class ReadingGroupsController < ApplicationController | ||
67 | params[:reading_group][:name].strip! | 63 | params[:reading_group][:name].strip! |
68 | params[:reading_group] | 64 | params[:reading_group] |
69 | end | 65 | end |
70 | - | ||
71 | - def attributes_params | ||
72 | - params[:attributes][:public] == "1" | ||
73 | - end | ||
74 | 66 | ||
75 | # Extracted code from create action | 67 | # Extracted code from create action |
76 | def create_and_redir(format) | 68 | def create_and_redir(format) |
77 | if @reading_group.save | 69 | if @reading_group.save |
78 | - current_user.reading_group_attributes.create(reading_group_id: @reading_group.id, public: attributes_params) | 70 | + current_user.reading_group_attributes.create(reading_group_id: @reading_group.id) |
79 | 71 | ||
80 | format.html { redirect_to reading_group_path(@reading_group.id), notice: t('successfully_created', :record => t(@reading_group.class)) } | 72 | format.html { redirect_to reading_group_path(@reading_group.id), notice: t('successfully_created', :record => t(@reading_group.class)) } |
81 | format.json { render action: 'show', status: :created, location: @reading_group } | 73 | format.json { render action: 'show', status: :created, location: @reading_group } |
app/views/kalibro_configurations/_form.html.erb
@@ -17,14 +17,6 @@ | @@ -17,14 +17,6 @@ | ||
17 | <%= f.text_area :description, class: 'text-area form-control' %> | 17 | <%= f.text_area :description, class: 'text-area form-control' %> |
18 | </div> | 18 | </div> |
19 | </div> | 19 | </div> |
20 | - | ||
21 | - <div class="form-row"> | ||
22 | - <div class="field-container checkbox"> | ||
23 | - <label> | ||
24 | - <%= check_box :attributes, :public %> <%= t('should_be_public') %> | ||
25 | - </label> | ||
26 | - </div> | ||
27 | - </div> | ||
28 | </div> | 20 | </div> |
29 | </div> | 21 | </div> |
30 | 22 |
app/views/reading_groups/_form.html.erb
@@ -16,13 +16,6 @@ | @@ -16,13 +16,6 @@ | ||
16 | <%= f.text_area :description, class: 'text-area form-control' %> | 16 | <%= f.text_area :description, class: 'text-area form-control' %> |
17 | </div> | 17 | </div> |
18 | </div> | 18 | </div> |
19 | - <div class="form-row"> | ||
20 | - <div class="field-container checkbox"> | ||
21 | - <label> | ||
22 | - <%= check_box :attributes, :public %> <%= t('should_be_public') %> | ||
23 | - </label> | ||
24 | - </div> | ||
25 | - </div> | ||
26 | </div> | 19 | </div> |
27 | </div> | 20 | </div> |
28 | 21 |
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/controllers/kalibro_configurations_controller_spec.rb
@@ -216,7 +216,6 @@ describe KalibroConfigurationsController, :type => :controller do | @@ -216,7 +216,6 @@ describe KalibroConfigurationsController, :type => :controller do | ||
216 | before :each do | 216 | before :each do |
217 | KalibroConfiguration.expects(:find).with(kalibro_configuration.id).returns(kalibro_configuration) | 217 | KalibroConfiguration.expects(:find).with(kalibro_configuration.id).returns(kalibro_configuration) |
218 | KalibroConfiguration.any_instance.expects(:update).with(kalibro_configuration_params).returns(true) | 218 | KalibroConfiguration.any_instance.expects(:update).with(kalibro_configuration_params).returns(true) |
219 | - kalibro_configuration.expects(:attributes).returns(kalibro_configuration_attribute) | ||
220 | end | 219 | end |
221 | 220 | ||
222 | context 'rendering the show' do | 221 | context 'rendering the show' do |
spec/controllers/reading_groups_controller_spec.rb
@@ -209,7 +209,6 @@ describe ReadingGroupsController, :type => :controller do | @@ -209,7 +209,6 @@ describe ReadingGroupsController, :type => :controller do | ||
209 | 209 | ||
210 | context 'with valid fields' do | 210 | context 'with valid fields' do |
211 | before :each do | 211 | before :each do |
212 | - @subject.expects(:attributes).returns(@ownership) | ||
213 | ReadingGroup.expects(:find).with(@subject.id).returns(@subject) | 212 | ReadingGroup.expects(:find).with(@subject.id).returns(@subject) |
214 | ReadingGroup.any_instance.expects(:update).with(@subject_params).returns(true) | 213 | ReadingGroup.any_instance.expects(:update).with(@subject_params).returns(true) |
215 | end | 214 | end |