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 | 3 | class KalibroConfigurationsController < ApplicationController |
4 | 4 | before_action :authenticate_user!, except: [:index, :show] |
5 | 5 | before_action :kalibro_configuration_owner?, only: [:edit, :update, :destroy] |
6 | + before_action :set_kalibro_configuration, only: [:show, :edit, :update, :destroy] | |
6 | 7 | |
7 | 8 | # GET /kalibro_configurations/new |
8 | 9 | def new |
... | ... | @@ -27,7 +28,6 @@ class KalibroConfigurationsController < ApplicationController |
27 | 28 | # GET /kalibro_configurations/1 |
28 | 29 | # GET /kalibro_configurations/1.json |
29 | 30 | def show |
30 | - set_kalibro_configuration | |
31 | 31 | Rails.cache.fetch("#{@kalibro_configuration.id}_metric_configurations") do |
32 | 32 | @kalibro_configuration.metric_configurations |
33 | 33 | end |
... | ... | @@ -35,15 +35,10 @@ class KalibroConfigurationsController < ApplicationController |
35 | 35 | |
36 | 36 | # GET /kalibro_configurations/1/edit |
37 | 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 | 40 | def update |
44 | - set_kalibro_configuration | |
45 | 41 | if @kalibro_configuration.update(kalibro_configuration_params) |
46 | - @kalibro_configuration.attributes.update(public: attributes_params) | |
47 | 42 | redirect_to(kalibro_configuration_path(@kalibro_configuration.id)) |
48 | 43 | else |
49 | 44 | render "edit" |
... | ... | @@ -53,8 +48,6 @@ class KalibroConfigurationsController < ApplicationController |
53 | 48 | # DELETE /kalibro_configurations/1 |
54 | 49 | # DELETE /kalibro_configurations/1.json |
55 | 50 | def destroy |
56 | - set_kalibro_configuration | |
57 | - | |
58 | 51 | @kalibro_configuration.destroy |
59 | 52 | |
60 | 53 | respond_to do |format| |
... | ... | @@ -77,14 +70,10 @@ class KalibroConfigurationsController < ApplicationController |
77 | 70 | params[:kalibro_configuration] |
78 | 71 | end |
79 | 72 | |
80 | - def attributes_params | |
81 | - params[:attributes][:public] == "1" | |
82 | - end | |
83 | - | |
84 | 73 | # Extracted code from create action |
85 | 74 | def create_and_redir(format) |
86 | 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 | 78 | format.html { redirect_to kalibro_configuration_path(@kalibro_configuration.id), notice: t('successfully_created', :record => @kalibro_configuration.model_name.human) } |
90 | 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 | 8 | # GET /reading_groups/new |
9 | 9 | def new |
10 | 10 | @reading_group = ReadingGroup.new |
11 | - @attributes = @reading_group.attributes | |
12 | 11 | end |
13 | 12 | |
14 | 13 | # GET /reading_groups |
... | ... | @@ -32,13 +31,10 @@ class ReadingGroupsController < ApplicationController |
32 | 31 | |
33 | 32 | # GET /reading_groups/1/edit |
34 | 33 | # GET /reading_groups/1/edit.json |
35 | - def edit | |
36 | - @attributes = @reading_group.attributes | |
37 | - end | |
34 | + def edit; end | |
38 | 35 | |
39 | 36 | def update |
40 | 37 | if @reading_group.update(reading_group_params) |
41 | - @reading_group.attributes.update(public: attributes_params) | |
42 | 38 | redirect_to(reading_group_path(@reading_group.id)) |
43 | 39 | else |
44 | 40 | render "edit" |
... | ... | @@ -67,15 +63,11 @@ class ReadingGroupsController < ApplicationController |
67 | 63 | params[:reading_group][:name].strip! |
68 | 64 | params[:reading_group] |
69 | 65 | end |
70 | - | |
71 | - def attributes_params | |
72 | - params[:attributes][:public] == "1" | |
73 | - end | |
74 | 66 | |
75 | 67 | # Extracted code from create action |
76 | 68 | def create_and_redir(format) |
77 | 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 | 72 | format.html { redirect_to reading_group_path(@reading_group.id), notice: t('successfully_created', :record => t(@reading_group.class)) } |
81 | 73 | format.json { render action: 'show', status: :created, location: @reading_group } | ... | ... |
app/views/kalibro_configurations/_form.html.erb
... | ... | @@ -17,14 +17,6 @@ |
17 | 17 | <%= f.text_area :description, class: 'text-area form-control' %> |
18 | 18 | </div> |
19 | 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 | 20 | </div> |
29 | 21 | </div> |
30 | 22 | ... | ... |
app/views/reading_groups/_form.html.erb
... | ... | @@ -16,13 +16,6 @@ |
16 | 16 | <%= f.text_area :description, class: 'text-area form-control' %> |
17 | 17 | </div> |
18 | 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 | 19 | </div> |
27 | 20 | </div> |
28 | 21 | ... | ... |
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/controllers/kalibro_configurations_controller_spec.rb
... | ... | @@ -216,7 +216,6 @@ describe KalibroConfigurationsController, :type => :controller do |
216 | 216 | before :each do |
217 | 217 | KalibroConfiguration.expects(:find).with(kalibro_configuration.id).returns(kalibro_configuration) |
218 | 218 | KalibroConfiguration.any_instance.expects(:update).with(kalibro_configuration_params).returns(true) |
219 | - kalibro_configuration.expects(:attributes).returns(kalibro_configuration_attribute) | |
220 | 219 | end |
221 | 220 | |
222 | 221 | context 'rendering the show' do | ... | ... |
spec/controllers/reading_groups_controller_spec.rb
... | ... | @@ -209,7 +209,6 @@ describe ReadingGroupsController, :type => :controller do |
209 | 209 | |
210 | 210 | context 'with valid fields' do |
211 | 211 | before :each do |
212 | - @subject.expects(:attributes).returns(@ownership) | |
213 | 212 | ReadingGroup.expects(:find).with(@subject.id).returns(@subject) |
214 | 213 | ReadingGroup.any_instance.expects(:update).with(@subject_params).returns(true) |
215 | 214 | end | ... | ... |