Commit 8eb8f115f287a8bfe06f5553e8dc1fa4712bea45
Committed by
Diego Camarinha
1 parent
03ae4c72
Exists in
colab
and in
4 other branches
Bulk find-replace for configuration visibility model changes [no-ci]
Showing
18 changed files
with
63 additions
and
61 deletions
Show diff stats
app/controllers/concerns/ownership_authentication.rb
| @@ -63,7 +63,7 @@ module OwnershipAuthentication | @@ -63,7 +63,7 @@ module OwnershipAuthentication | ||
| 63 | end | 63 | end |
| 64 | 64 | ||
| 65 | def check_reading_group_ownership(id) | 65 | def check_reading_group_ownership(id) |
| 66 | - if current_user.reading_group_ownerships.find_by_reading_group_id(id).nil? | 66 | + if current_user.reading_group_attributes.find_by_reading_group_id(id).nil? |
| 67 | respond_to do |format| | 67 | respond_to do |format| |
| 68 | format.html { redirect_to reading_group_url(id: id), notice: t('not_allowed') } | 68 | format.html { redirect_to reading_group_url(id: id), notice: t('not_allowed') } |
| 69 | format.json { head :no_content } | 69 | format.json { head :no_content } |
| @@ -74,7 +74,7 @@ module OwnershipAuthentication | @@ -74,7 +74,7 @@ module OwnershipAuthentication | ||
| 74 | end | 74 | end |
| 75 | 75 | ||
| 76 | def check_kalibro_configuration_ownership(id) | 76 | def check_kalibro_configuration_ownership(id) |
| 77 | - if current_user.kalibro_configuration_ownerships.find_by_kalibro_configuration_id(id).nil? | 77 | + if current_user.kalibro_configuration_attributes.find_by_kalibro_configuration_id(id).nil? |
| 78 | respond_to do |format| | 78 | respond_to do |format| |
| 79 | format.html { redirect_to kalibro_configurations_url(id: id), notice: t('not_allowed') } | 79 | format.html { redirect_to kalibro_configurations_url(id: id), notice: t('not_allowed') } |
| 80 | format.json { head :no_content } | 80 | format.json { head :no_content } |
app/controllers/kalibro_configurations_controller.rb
| @@ -12,7 +12,9 @@ class KalibroConfigurationsController < ApplicationController | @@ -12,7 +12,9 @@ class KalibroConfigurationsController < ApplicationController | ||
| 12 | # GET /kalibro_configurations | 12 | # GET /kalibro_configurations |
| 13 | # GET /kalibro_configurations.json | 13 | # GET /kalibro_configurations.json |
| 14 | def index | 14 | def index |
| 15 | - @kalibro_configurations = KalibroConfiguration.all | 15 | + @kalibro_configurations = KalibroConfigurationAttributes.where(hidden: false).map { |cfg_attr| |
| 16 | + KalibroConfiguration.find(cfg_attr.kalibro_configuration_id) | ||
| 17 | + }.compact | ||
| 16 | end | 18 | end |
| 17 | 19 | ||
| 18 | # POST /kalibro_configurations | 20 | # POST /kalibro_configurations |
| @@ -53,7 +55,7 @@ class KalibroConfigurationsController < ApplicationController | @@ -53,7 +55,7 @@ class KalibroConfigurationsController < ApplicationController | ||
| 53 | # DELETE /kalibro_configurations/1.json | 55 | # DELETE /kalibro_configurations/1.json |
| 54 | def destroy | 56 | def destroy |
| 55 | set_kalibro_configuration | 57 | set_kalibro_configuration |
| 56 | - current_user.kalibro_configuration_ownerships.find_by_kalibro_configuration_id!(@kalibro_configuration.id).destroy | 58 | + current_user.kalibro_configuration_attributes.find_by_kalibro_configuration_id!(@kalibro_configuration.id).destroy |
| 57 | @kalibro_configuration.destroy | 59 | @kalibro_configuration.destroy |
| 58 | respond_to do |format| | 60 | respond_to do |format| |
| 59 | format.html { redirect_to kalibro_configurations_url } | 61 | format.html { redirect_to kalibro_configurations_url } |
| @@ -77,7 +79,7 @@ class KalibroConfigurationsController < ApplicationController | @@ -77,7 +79,7 @@ class KalibroConfigurationsController < ApplicationController | ||
| 77 | # Extracted code from create action | 79 | # Extracted code from create action |
| 78 | def create_and_redir(format) | 80 | def create_and_redir(format) |
| 79 | if @kalibro_configuration.save | 81 | if @kalibro_configuration.save |
| 80 | - current_user.kalibro_configuration_ownerships.create kalibro_configuration_id: @kalibro_configuration.id | 82 | + current_user.kalibro_configuration_attributes.create kalibro_configuration_id: @kalibro_configuration.id |
| 81 | 83 | ||
| 82 | format.html { redirect_to kalibro_configuration_path(@kalibro_configuration.id), notice: t('successfully_created', :record => @kalibro_configuration.model_name.human) } | 84 | format.html { redirect_to kalibro_configuration_path(@kalibro_configuration.id), notice: t('successfully_created', :record => @kalibro_configuration.model_name.human) } |
| 83 | format.json { render action: 'show', status: :created, location: @kalibro_configuration } | 85 | format.json { render action: 'show', status: :created, location: @kalibro_configuration } |
app/controllers/reading_groups_controller.rb
| @@ -13,7 +13,7 @@ class ReadingGroupsController < ApplicationController | @@ -13,7 +13,7 @@ class ReadingGroupsController < ApplicationController | ||
| 13 | # GET /reading_groups | 13 | # GET /reading_groups |
| 14 | # GET /reading_groups.json | 14 | # GET /reading_groups.json |
| 15 | def index | 15 | def index |
| 16 | - @reading_groups = ReadingGroup.all | 16 | + @reading_groups = ReadingGroup.visible |
| 17 | end | 17 | end |
| 18 | 18 | ||
| 19 | # POST /reading_groups | 19 | # POST /reading_groups |
| @@ -44,7 +44,7 @@ class ReadingGroupsController < ApplicationController | @@ -44,7 +44,7 @@ class ReadingGroupsController < ApplicationController | ||
| 44 | # DELETE /reading_group/1 | 44 | # DELETE /reading_group/1 |
| 45 | # DELETE /reading_group/1.json | 45 | # DELETE /reading_group/1.json |
| 46 | def destroy | 46 | def destroy |
| 47 | - current_user.reading_group_ownerships.find_by_reading_group_id!(@reading_group.id).destroy | 47 | + current_user.reading_group_attributess.find_by_reading_group_id!(@reading_group.id).destroy |
| 48 | @reading_group.destroy | 48 | @reading_group.destroy |
| 49 | respond_to do |format| | 49 | respond_to do |format| |
| 50 | format.html { redirect_to reading_groups_url } | 50 | format.html { redirect_to reading_groups_url } |
| @@ -68,7 +68,7 @@ class ReadingGroupsController < ApplicationController | @@ -68,7 +68,7 @@ class ReadingGroupsController < ApplicationController | ||
| 68 | # Extracted code from create action | 68 | # Extracted code from create action |
| 69 | def create_and_redir(format) | 69 | def create_and_redir(format) |
| 70 | if @reading_group.save | 70 | if @reading_group.save |
| 71 | - current_user.reading_group_ownerships.create reading_group_id: @reading_group.id | 71 | + current_user.reading_group_attributess.create reading_group_id: @reading_group.id |
| 72 | 72 | ||
| 73 | format.html { redirect_to reading_group_path(@reading_group.id), notice: t('successfully_created', :record => t(@reading_group.class)) } | 73 | format.html { redirect_to reading_group_path(@reading_group.id), notice: t('successfully_created', :record => t(@reading_group.class)) } |
| 74 | format.json { render action: 'show', status: :created, location: @reading_group } | 74 | format.json { render action: 'show', status: :created, location: @reading_group } |
app/helpers/kalibro_configurations_helper.rb
| 1 | module KalibroConfigurationsHelper | 1 | module KalibroConfigurationsHelper |
| 2 | def kalibro_configuration_owner?(kalibro_configuration_id) | 2 | def kalibro_configuration_owner?(kalibro_configuration_id) |
| 3 | - user_signed_in? && !current_user.kalibro_configuration_ownerships.find_by_kalibro_configuration_id(kalibro_configuration_id).nil? | 3 | + user_signed_in? && !current_user.kalibro_configuration_attributes.find_by_kalibro_configuration_id(kalibro_configuration_id).nil? |
| 4 | end | 4 | end |
| 5 | 5 | ||
| 6 | def link_to_edit_form(metric_configuration, kalibro_configuration_id) | 6 | def link_to_edit_form(metric_configuration, kalibro_configuration_id) |
app/helpers/reading_groups_helper.rb
| 1 | module ReadingGroupsHelper | 1 | module ReadingGroupsHelper |
| 2 | def reading_groups_owner? reading_group_id | 2 | def reading_groups_owner? reading_group_id |
| 3 | - user_signed_in? && !current_user.reading_group_ownerships.find_by_reading_group_id(reading_group_id).nil? | 3 | + user_signed_in? && !current_user.reading_group_attributess.find_by_reading_group_id(reading_group_id).nil? |
| 4 | end | 4 | end |
| 5 | end | 5 | end |
| 6 | \ No newline at end of file | 6 | \ No newline at end of file |
spec/controllers/base_metric_configurations_controller_spec.rb
| @@ -41,7 +41,7 @@ end | @@ -41,7 +41,7 @@ end | ||
| 41 | 41 | ||
| 42 | 42 | ||
| 43 | describe InheritsFromBaseMetricConfigurationsController, :type => :controller do | 43 | describe InheritsFromBaseMetricConfigurationsController, :type => :controller do |
| 44 | - let(:kalibro_configuration) { FactoryGirl.build(:kalibro_configuration_with_id) } | 44 | + let(:kalibro_configuration) { FactoryGirl.build(:kalibro_configuration, :with_id) } |
| 45 | 45 | ||
| 46 | before do | 46 | before do |
| 47 | Rails.application.routes.draw do | 47 | Rails.application.routes.draw do |
| @@ -111,7 +111,7 @@ describe InheritsFromBaseMetricConfigurationsController, :type => :controller do | @@ -111,7 +111,7 @@ describe InheritsFromBaseMetricConfigurationsController, :type => :controller do | ||
| 111 | 111 | ||
| 112 | describe 'show' do | 112 | describe 'show' do |
| 113 | let(:metric_configuration) { FactoryGirl.build(:metric_configuration_with_id) } | 113 | let(:metric_configuration) { FactoryGirl.build(:metric_configuration_with_id) } |
| 114 | - let(:reading_group) { FactoryGirl.build(:reading_group_with_id) } | 114 | + let(:reading_group) { FactoryGirl.build(:reading_group, :with_id) } |
| 115 | let(:kalibro_range) { FactoryGirl.build(:kalibro_range) } | 115 | let(:kalibro_range) { FactoryGirl.build(:kalibro_range) } |
| 116 | 116 | ||
| 117 | context 'with a valid metric_configuration' do | 117 | context 'with a valid metric_configuration' do |
spec/controllers/compound_metric_configurations_controller_spec.rb
| 1 | require 'rails_helper' | 1 | require 'rails_helper' |
| 2 | 2 | ||
| 3 | describe CompoundMetricConfigurationsController, :type => :controller do | 3 | describe CompoundMetricConfigurationsController, :type => :controller do |
| 4 | - let(:kalibro_configuration) { FactoryGirl.build(:kalibro_configuration_with_id) } | 4 | + let(:kalibro_configuration) { FactoryGirl.build(:kalibro_configuration, :with_id) } |
| 5 | 5 | ||
| 6 | describe 'new' do | 6 | describe 'new' do |
| 7 | before :each do | 7 | before :each do |
| @@ -69,7 +69,7 @@ describe CompoundMetricConfigurationsController, :type => :controller do | @@ -69,7 +69,7 @@ describe CompoundMetricConfigurationsController, :type => :controller do | ||
| 69 | 69 | ||
| 70 | describe 'show' do | 70 | describe 'show' do |
| 71 | let(:compound_metric_configuration) { FactoryGirl.build(:compound_metric_configuration_with_id) } | 71 | let(:compound_metric_configuration) { FactoryGirl.build(:compound_metric_configuration_with_id) } |
| 72 | - let(:reading_group) { FactoryGirl.build(:reading_group_with_id) } | 72 | + let(:reading_group) { FactoryGirl.build(:reading_group, :with_id) } |
| 73 | let(:kalibro_range) { FactoryGirl.build(:kalibro_range) } | 73 | let(:kalibro_range) { FactoryGirl.build(:kalibro_range) } |
| 74 | 74 | ||
| 75 | before :each do | 75 | before :each do |
spec/controllers/concerns/ownership_authentication_spec.rb
| @@ -4,7 +4,7 @@ describe OwnershipAuthentication, type: :controller do | @@ -4,7 +4,7 @@ describe OwnershipAuthentication, type: :controller do | ||
| 4 | #TODO: test other methods | 4 | #TODO: test other methods |
| 5 | 5 | ||
| 6 | describe 'reading_group_owner?' do | 6 | describe 'reading_group_owner?' do |
| 7 | - let(:reading_group) { FactoryGirl.build(:reading_group_with_id) } | 7 | + let(:reading_group) { FactoryGirl.build(:reading_group, :with_id) } |
| 8 | 8 | ||
| 9 | context 'Not ReadingGroupsController nor ReadingsController' do | 9 | context 'Not ReadingGroupsController nor ReadingsController' do |
| 10 | let!(:projects_controller) { ProjectsController.new } | 10 | let!(:projects_controller) { ProjectsController.new } |
| @@ -34,12 +34,12 @@ describe OwnershipAuthentication, type: :controller do | @@ -34,12 +34,12 @@ describe OwnershipAuthentication, type: :controller do | ||
| 34 | end | 34 | end |
| 35 | 35 | ||
| 36 | context 'when the user owns the ReadingGroup' do | 36 | context 'when the user owns the ReadingGroup' do |
| 37 | - let!(:reading_group_ownership) { FactoryGirl.build(:reading_group_ownership, {user_id: current_user.id, reading_group_id: reading_group.id}) } | 37 | + let!(:reading_group_attributes) { FactoryGirl.build(:reading_group_attributes, {user_id: current_user.id, reading_group_id: reading_group.id}) } |
| 38 | 38 | ||
| 39 | before do | 39 | before do |
| 40 | - reading_group_ownerships = Object.new | ||
| 41 | - reading_group_ownerships.expects(:find_by_reading_group_id).with(reading_group.id).returns(reading_group_ownership) | ||
| 42 | - current_user.expects(:reading_group_ownerships).returns(reading_group_ownerships) | 40 | + reading_group_attributess = Object.new |
| 41 | + reading_group_attributess.expects(:find_by_reading_group_id).with(reading_group.id).returns(reading_group_attributes) | ||
| 42 | + current_user.expects(:reading_group_attributess).returns(reading_group_attributess) | ||
| 43 | end | 43 | end |
| 44 | 44 | ||
| 45 | it 'should return true' do | 45 | it 'should return true' do |
| @@ -49,9 +49,9 @@ describe OwnershipAuthentication, type: :controller do | @@ -49,9 +49,9 @@ describe OwnershipAuthentication, type: :controller do | ||
| 49 | 49 | ||
| 50 | context 'when the user does not own the ReadingGroup' do | 50 | context 'when the user does not own the ReadingGroup' do |
| 51 | before do | 51 | before do |
| 52 | - reading_group_ownerships = Object.new | ||
| 53 | - reading_group_ownerships.expects(:find_by_reading_group_id).with(reading_group.id).returns(nil) | ||
| 54 | - current_user.expects(:reading_group_ownerships).returns(reading_group_ownerships) | 52 | + reading_group_attributess = Object.new |
| 53 | + reading_group_attributess.expects(:find_by_reading_group_id).with(reading_group.id).returns(nil) | ||
| 54 | + current_user.expects(:reading_group_attributess).returns(reading_group_attributess) | ||
| 55 | end | 55 | end |
| 56 | 56 | ||
| 57 | it 'should respond' do # FIXME: this is not the best test, but it it's the closest we can do I think | 57 | it 'should respond' do # FIXME: this is not the best test, but it it's the closest we can do I think |
| @@ -65,7 +65,7 @@ describe OwnershipAuthentication, type: :controller do | @@ -65,7 +65,7 @@ describe OwnershipAuthentication, type: :controller do | ||
| 65 | end | 65 | end |
| 66 | 66 | ||
| 67 | describe 'kalibro_configuration_owner?' do | 67 | describe 'kalibro_configuration_owner?' do |
| 68 | - let(:kalibro_configuration) { FactoryGirl.build(:kalibro_configuration_with_id) } | 68 | + let(:kalibro_configuration) { FactoryGirl.build(:kalibro_configuration, :with_id) } |
| 69 | 69 | ||
| 70 | context 'Not KalibroConfigurationsController nor MetricConfigurationsController nor CompoundMetricConfigurationsController' do | 70 | context 'Not KalibroConfigurationsController nor MetricConfigurationsController nor CompoundMetricConfigurationsController' do |
| 71 | let!(:projects_controller) { ProjectsController.new } | 71 | let!(:projects_controller) { ProjectsController.new } |
spec/controllers/kalibro_configurations_controller_spec.rb
| @@ -18,7 +18,7 @@ describe KalibroConfigurationsController, :type => :controller do | @@ -18,7 +18,7 @@ describe KalibroConfigurationsController, :type => :controller do | ||
| 18 | end | 18 | end |
| 19 | 19 | ||
| 20 | context 'with valid fields' do | 20 | context 'with valid fields' do |
| 21 | - let(:kalibro_configuration) { FactoryGirl.build(:kalibro_configuration_with_id) } | 21 | + let(:kalibro_configuration) { FactoryGirl.build(:kalibro_configuration, :with_id) } |
| 22 | let(:subject_params) { kalibro_configuration.to_hash } | 22 | let(:subject_params) { kalibro_configuration.to_hash } |
| 23 | 23 | ||
| 24 | before :each do | 24 | before :each do |
| @@ -46,7 +46,7 @@ describe KalibroConfigurationsController, :type => :controller do | @@ -46,7 +46,7 @@ describe KalibroConfigurationsController, :type => :controller do | ||
| 46 | 46 | ||
| 47 | context 'with an invalid field' do | 47 | context 'with an invalid field' do |
| 48 | before :each do | 48 | before :each do |
| 49 | - @subject = FactoryGirl.build(:kalibro_configuration_with_id) | 49 | + @subject = FactoryGirl.build(:kalibro_configuration, :with_id) |
| 50 | @subject_params = @subject.to_hash | 50 | @subject_params = @subject.to_hash |
| 51 | 51 | ||
| 52 | KalibroConfiguration.expects(:new).at_least_once.with(@subject_params).returns(@subject) | 52 | KalibroConfiguration.expects(:new).at_least_once.with(@subject_params).returns(@subject) |
| @@ -60,7 +60,7 @@ describe KalibroConfigurationsController, :type => :controller do | @@ -60,7 +60,7 @@ describe KalibroConfigurationsController, :type => :controller do | ||
| 60 | end | 60 | end |
| 61 | 61 | ||
| 62 | describe 'show' do | 62 | describe 'show' do |
| 63 | - let(:kalibro_configuration) { FactoryGirl.build(:kalibro_configuration_with_id) } | 63 | + let(:kalibro_configuration) { FactoryGirl.build(:kalibro_configuration, :with_id) } |
| 64 | let(:metric_configuration) { FactoryGirl.build(:metric_configuration_with_id) } | 64 | let(:metric_configuration) { FactoryGirl.build(:metric_configuration_with_id) } |
| 65 | 65 | ||
| 66 | before :each do | 66 | before :each do |
| @@ -79,7 +79,7 @@ describe KalibroConfigurationsController, :type => :controller do | @@ -79,7 +79,7 @@ describe KalibroConfigurationsController, :type => :controller do | ||
| 79 | 79 | ||
| 80 | describe 'destroy' do | 80 | describe 'destroy' do |
| 81 | before do | 81 | before do |
| 82 | - @subject = FactoryGirl.build(:kalibro_configuration_with_id) | 82 | + @subject = FactoryGirl.build(:kalibro_configuration, :with_id) |
| 83 | end | 83 | end |
| 84 | 84 | ||
| 85 | context 'with an User logged in' do | 85 | context 'with an User logged in' do |
| @@ -134,7 +134,7 @@ describe KalibroConfigurationsController, :type => :controller do | @@ -134,7 +134,7 @@ describe KalibroConfigurationsController, :type => :controller do | ||
| 134 | 134 | ||
| 135 | describe 'index' do | 135 | describe 'index' do |
| 136 | before :each do | 136 | before :each do |
| 137 | - @subject = FactoryGirl.build(:kalibro_configuration_with_id) | 137 | + @subject = FactoryGirl.build(:kalibro_configuration, :with_id) |
| 138 | KalibroConfiguration.expects(:all).returns([@subject]) | 138 | KalibroConfiguration.expects(:all).returns([@subject]) |
| 139 | get :index | 139 | get :index |
| 140 | end | 140 | end |
| @@ -144,7 +144,7 @@ describe KalibroConfigurationsController, :type => :controller do | @@ -144,7 +144,7 @@ describe KalibroConfigurationsController, :type => :controller do | ||
| 144 | 144 | ||
| 145 | describe 'edit' do | 145 | describe 'edit' do |
| 146 | before do | 146 | before do |
| 147 | - @subject = FactoryGirl.build(:kalibro_configuration_with_id) | 147 | + @subject = FactoryGirl.build(:kalibro_configuration, :with_id) |
| 148 | end | 148 | end |
| 149 | 149 | ||
| 150 | context 'with an User logged in' do | 150 | context 'with an User logged in' do |
| @@ -175,7 +175,7 @@ describe KalibroConfigurationsController, :type => :controller do | @@ -175,7 +175,7 @@ describe KalibroConfigurationsController, :type => :controller do | ||
| 175 | 175 | ||
| 176 | context 'when the user does not own the kalibro_configuration' do | 176 | context 'when the user does not own the kalibro_configuration' do |
| 177 | before do | 177 | before do |
| 178 | - @subject = FactoryGirl.build(:another_kalibro_configuration_with_id) | 178 | + @subject = FactoryGirl.build(:another_kalibro_configuration, :with_id) |
| 179 | @ownerships.expects(:find_by_kalibro_configuration_id).with("#{@subject.id}").returns(nil) | 179 | @ownerships.expects(:find_by_kalibro_configuration_id).with("#{@subject.id}").returns(nil) |
| 180 | 180 | ||
| 181 | get :edit, :id => @subject.id | 181 | get :edit, :id => @subject.id |
| @@ -196,7 +196,7 @@ describe KalibroConfigurationsController, :type => :controller do | @@ -196,7 +196,7 @@ describe KalibroConfigurationsController, :type => :controller do | ||
| 196 | end | 196 | end |
| 197 | 197 | ||
| 198 | describe 'update' do | 198 | describe 'update' do |
| 199 | - let(:kalibro_configuration) {FactoryGirl.build(:kalibro_configuration_with_id)} | 199 | + let(:kalibro_configuration) {FactoryGirl.build(:kalibro_configuration, :with_id)} |
| 200 | let(:kalibro_configuration_params) { kalibro_configuration.to_hash } | 200 | let(:kalibro_configuration_params) { kalibro_configuration.to_hash } |
| 201 | 201 | ||
| 202 | context 'when the user is logged in' do | 202 | context 'when the user is logged in' do |
spec/controllers/kalibro_ranges_controller_spec.rb
| @@ -5,7 +5,7 @@ describe KalibroRangesController, :type => :controller do | @@ -5,7 +5,7 @@ describe KalibroRangesController, :type => :controller do | ||
| 5 | let(:kalibro_range) { FactoryGirl.build(:kalibro_range_with_id, metric_configuration_id: metric_configuration.id) } | 5 | let(:kalibro_range) { FactoryGirl.build(:kalibro_range_with_id, metric_configuration_id: metric_configuration.id) } |
| 6 | 6 | ||
| 7 | describe 'new' do | 7 | describe 'new' do |
| 8 | - let(:kalibro_configuration) { FactoryGirl.build(:kalibro_configuration_with_id) } | 8 | + let(:kalibro_configuration) { FactoryGirl.build(:kalibro_configuration, :with_id) } |
| 9 | 9 | ||
| 10 | before :each do | 10 | before :each do |
| 11 | sign_in FactoryGirl.create(:user) | 11 | sign_in FactoryGirl.create(:user) |
| @@ -35,7 +35,7 @@ describe KalibroRangesController, :type => :controller do | @@ -35,7 +35,7 @@ describe KalibroRangesController, :type => :controller do | ||
| 35 | 35 | ||
| 36 | describe 'create' do | 36 | describe 'create' do |
| 37 | let(:kalibro_range_params) { kalibro_range.to_hash } | 37 | let(:kalibro_range_params) { kalibro_range.to_hash } |
| 38 | - let(:kalibro_configuration) { FactoryGirl.build(:kalibro_configuration_with_id) } | 38 | + let(:kalibro_configuration) { FactoryGirl.build(:kalibro_configuration, :with_id) } |
| 39 | 39 | ||
| 40 | before do | 40 | before do |
| 41 | sign_in FactoryGirl.create(:user) | 41 | sign_in FactoryGirl.create(:user) |
spec/controllers/metric_configurations_controller_spec.rb
| 1 | require 'rails_helper' | 1 | require 'rails_helper' |
| 2 | 2 | ||
| 3 | describe MetricConfigurationsController, :type => :controller do | 3 | describe MetricConfigurationsController, :type => :controller do |
| 4 | - let(:kalibro_configuration) { FactoryGirl.build(:kalibro_configuration_with_id) } | 4 | + let(:kalibro_configuration) { FactoryGirl.build(:kalibro_configuration, :with_id) } |
| 5 | describe 'choose_metric' do | 5 | describe 'choose_metric' do |
| 6 | let(:metric_collector) { FactoryGirl.build(:metric_collector) } | 6 | let(:metric_collector) { FactoryGirl.build(:metric_collector) } |
| 7 | before :each do | 7 | before :each do |
| @@ -92,7 +92,7 @@ describe MetricConfigurationsController, :type => :controller do | @@ -92,7 +92,7 @@ describe MetricConfigurationsController, :type => :controller do | ||
| 92 | 92 | ||
| 93 | describe 'show' do | 93 | describe 'show' do |
| 94 | let(:metric_configuration) { FactoryGirl.build(:metric_configuration_with_id) } | 94 | let(:metric_configuration) { FactoryGirl.build(:metric_configuration_with_id) } |
| 95 | - let(:reading_group) { FactoryGirl.build(:reading_group_with_id) } | 95 | + let(:reading_group) { FactoryGirl.build(:reading_group, :with_id) } |
| 96 | let(:kalibro_range) { FactoryGirl.build(:kalibro_range) } | 96 | let(:kalibro_range) { FactoryGirl.build(:kalibro_range) } |
| 97 | 97 | ||
| 98 | before :each do | 98 | before :each do |
spec/controllers/reading_groups_controller_spec.rb
| @@ -17,7 +17,7 @@ describe ReadingGroupsController, :type => :controller do | @@ -17,7 +17,7 @@ describe ReadingGroupsController, :type => :controller do | ||
| 17 | end | 17 | end |
| 18 | 18 | ||
| 19 | context 'with valid fields' do | 19 | context 'with valid fields' do |
| 20 | - let(:reading_group) { FactoryGirl.build(:reading_group_with_id) } | 20 | + let(:reading_group) { FactoryGirl.build(:reading_group, :with_id) } |
| 21 | let(:subject_params) { reading_group.to_hash } | 21 | let(:subject_params) { reading_group.to_hash } |
| 22 | 22 | ||
| 23 | before :each do | 23 | before :each do |
| @@ -45,7 +45,7 @@ describe ReadingGroupsController, :type => :controller do | @@ -45,7 +45,7 @@ describe ReadingGroupsController, :type => :controller do | ||
| 45 | 45 | ||
| 46 | context 'with an invalid field' do | 46 | context 'with an invalid field' do |
| 47 | before :each do | 47 | before :each do |
| 48 | - @subject = FactoryGirl.build(:reading_group_with_id) | 48 | + @subject = FactoryGirl.build(:reading_group, :with_id) |
| 49 | @subject_params = @subject.to_hash | 49 | @subject_params = @subject.to_hash |
| 50 | 50 | ||
| 51 | ReadingGroup.expects(:new).at_least_once.with(@subject_params).returns(@subject) | 51 | ReadingGroup.expects(:new).at_least_once.with(@subject_params).returns(@subject) |
| @@ -59,7 +59,7 @@ describe ReadingGroupsController, :type => :controller do | @@ -59,7 +59,7 @@ describe ReadingGroupsController, :type => :controller do | ||
| 59 | end | 59 | end |
| 60 | 60 | ||
| 61 | describe 'show' do | 61 | describe 'show' do |
| 62 | - let!(:reading_group) { FactoryGirl.build(:reading_group_with_id) } | 62 | + let!(:reading_group) { FactoryGirl.build(:reading_group, :with_id) } |
| 63 | let(:reading) { FactoryGirl.build(:reading_with_id) } | 63 | let(:reading) { FactoryGirl.build(:reading_with_id) } |
| 64 | before :each do | 64 | before :each do |
| 65 | ReadingGroup.expects(:find).with(reading_group.id).returns(reading_group) | 65 | ReadingGroup.expects(:find).with(reading_group.id).returns(reading_group) |
| @@ -71,13 +71,13 @@ describe ReadingGroupsController, :type => :controller do | @@ -71,13 +71,13 @@ describe ReadingGroupsController, :type => :controller do | ||
| 71 | 71 | ||
| 72 | describe 'destroy' do | 72 | describe 'destroy' do |
| 73 | before do | 73 | before do |
| 74 | - @subject = FactoryGirl.build(:reading_group_with_id) | 74 | + @subject = FactoryGirl.build(:reading_group, :with_id) |
| 75 | end | 75 | end |
| 76 | 76 | ||
| 77 | context 'with a User logged in' do | 77 | context 'with a User logged in' do |
| 78 | before do | 78 | before do |
| 79 | sign_in FactoryGirl.create(:user) | 79 | sign_in FactoryGirl.create(:user) |
| 80 | - @ownership = FactoryGirl.build(:reading_group_ownership) | 80 | + @ownership = FactoryGirl.build(:reading_group_attributes) |
| 81 | @ownerships = [] | 81 | @ownerships = [] |
| 82 | 82 | ||
| 83 | end | 83 | end |
| @@ -91,7 +91,7 @@ describe ReadingGroupsController, :type => :controller do | @@ -91,7 +91,7 @@ describe ReadingGroupsController, :type => :controller do | ||
| 91 | @ownerships.expects(:find_by_reading_group_id).with("#{@subject.id}").returns(@ownership) | 91 | @ownerships.expects(:find_by_reading_group_id).with("#{@subject.id}").returns(@ownership) |
| 92 | @ownerships.expects(:find_by_reading_group_id!).with(@subject.id).returns(@ownership) | 92 | @ownerships.expects(:find_by_reading_group_id!).with(@subject.id).returns(@ownership) |
| 93 | 93 | ||
| 94 | - User.any_instance.expects(:reading_group_ownerships).at_least_once.returns(@ownerships) | 94 | + User.any_instance.expects(:reading_group_attributess).at_least_once.returns(@ownerships) |
| 95 | 95 | ||
| 96 | ReadingGroup.expects(:find).with(@subject.id).returns(@subject) | 96 | ReadingGroup.expects(:find).with(@subject.id).returns(@subject) |
| 97 | delete :destroy, :id => @subject.id | 97 | delete :destroy, :id => @subject.id |
| @@ -107,7 +107,7 @@ describe ReadingGroupsController, :type => :controller do | @@ -107,7 +107,7 @@ describe ReadingGroupsController, :type => :controller do | ||
| 107 | context "when the user doesn't own the reading group" do | 107 | context "when the user doesn't own the reading group" do |
| 108 | before :each do | 108 | before :each do |
| 109 | @ownerships.expects(:find_by_reading_group_id).with("#{@subject.id}").returns(nil) | 109 | @ownerships.expects(:find_by_reading_group_id).with("#{@subject.id}").returns(nil) |
| 110 | - User.any_instance.expects(:reading_group_ownerships).at_least_once.returns(@ownerships) | 110 | + User.any_instance.expects(:reading_group_attributess).at_least_once.returns(@ownerships) |
| 111 | 111 | ||
| 112 | delete :destroy, :id => @subject.id | 112 | delete :destroy, :id => @subject.id |
| 113 | end | 113 | end |
| @@ -127,7 +127,7 @@ describe ReadingGroupsController, :type => :controller do | @@ -127,7 +127,7 @@ describe ReadingGroupsController, :type => :controller do | ||
| 127 | 127 | ||
| 128 | describe 'index' do | 128 | describe 'index' do |
| 129 | before :each do | 129 | before :each do |
| 130 | - @subject = FactoryGirl.build(:reading_group_with_id) | 130 | + @subject = FactoryGirl.build(:reading_group, :with_id) |
| 131 | ReadingGroup.expects(:all).returns([@subject]) | 131 | ReadingGroup.expects(:all).returns([@subject]) |
| 132 | get :index | 132 | get :index |
| 133 | end | 133 | end |
| @@ -137,16 +137,16 @@ describe ReadingGroupsController, :type => :controller do | @@ -137,16 +137,16 @@ describe ReadingGroupsController, :type => :controller do | ||
| 137 | 137 | ||
| 138 | describe 'edit' do | 138 | describe 'edit' do |
| 139 | before do | 139 | before do |
| 140 | - @subject = FactoryGirl.build(:reading_group_with_id) | 140 | + @subject = FactoryGirl.build(:reading_group, :with_id) |
| 141 | end | 141 | end |
| 142 | 142 | ||
| 143 | context 'with a User logged in' do | 143 | context 'with a User logged in' do |
| 144 | before do | 144 | before do |
| 145 | @user = FactoryGirl.create(:user) | 145 | @user = FactoryGirl.create(:user) |
| 146 | - @ownership = FactoryGirl.build(:reading_group_ownership) | 146 | + @ownership = FactoryGirl.build(:reading_group_attributes) |
| 147 | @ownerships = [] | 147 | @ownerships = [] |
| 148 | 148 | ||
| 149 | - User.any_instance.expects(:reading_group_ownerships).at_least_once.returns(@ownerships) | 149 | + User.any_instance.expects(:reading_group_attributess).at_least_once.returns(@ownerships) |
| 150 | 150 | ||
| 151 | sign_in @user | 151 | sign_in @user |
| 152 | end | 152 | end |
| @@ -168,7 +168,7 @@ describe ReadingGroupsController, :type => :controller do | @@ -168,7 +168,7 @@ describe ReadingGroupsController, :type => :controller do | ||
| 168 | 168 | ||
| 169 | context 'when the user does not own the reading group' do | 169 | context 'when the user does not own the reading group' do |
| 170 | before do | 170 | before do |
| 171 | - @subject = FactoryGirl.build(:another_reading_group_with_id) | 171 | + @subject = FactoryGirl.build(:another_reading_group, :with_id) |
| 172 | @ownerships.expects(:find_by_reading_group_id).with("#{@subject.id}").returns(nil) | 172 | @ownerships.expects(:find_by_reading_group_id).with("#{@subject.id}").returns(nil) |
| 173 | 173 | ||
| 174 | get :edit, :id => @subject.id | 174 | get :edit, :id => @subject.id |
| @@ -190,7 +190,7 @@ describe ReadingGroupsController, :type => :controller do | @@ -190,7 +190,7 @@ describe ReadingGroupsController, :type => :controller do | ||
| 190 | 190 | ||
| 191 | describe 'update' do | 191 | describe 'update' do |
| 192 | before do | 192 | before do |
| 193 | - @subject = FactoryGirl.build(:reading_group_with_id) | 193 | + @subject = FactoryGirl.build(:reading_group, :with_id) |
| 194 | @subject_params = @subject.to_hash | 194 | @subject_params = @subject.to_hash |
| 195 | end | 195 | end |
| 196 | 196 | ||
| @@ -201,11 +201,11 @@ describe ReadingGroupsController, :type => :controller do | @@ -201,11 +201,11 @@ describe ReadingGroupsController, :type => :controller do | ||
| 201 | 201 | ||
| 202 | context 'when user owns the reading group' do | 202 | context 'when user owns the reading group' do |
| 203 | before do | 203 | before do |
| 204 | - @ownership = FactoryGirl.build(:reading_group_ownership) | 204 | + @ownership = FactoryGirl.build(:reading_group_attributes) |
| 205 | @ownerships = [] | 205 | @ownerships = [] |
| 206 | 206 | ||
| 207 | @ownerships.expects(:find_by_reading_group_id).with("#{@subject.id}").returns(@ownership) | 207 | @ownerships.expects(:find_by_reading_group_id).with("#{@subject.id}").returns(@ownership) |
| 208 | - User.any_instance.expects(:reading_group_ownerships).at_least_once.returns(@ownerships) | 208 | + User.any_instance.expects(:reading_group_attributess).at_least_once.returns(@ownerships) |
| 209 | end | 209 | end |
| 210 | 210 | ||
| 211 | context 'with valid fields' do | 211 | context 'with valid fields' do |
spec/controllers/readings_controller_spec.rb
| 1 | require 'rails_helper' | 1 | require 'rails_helper' |
| 2 | 2 | ||
| 3 | describe ReadingsController, :type => :controller do | 3 | describe ReadingsController, :type => :controller do |
| 4 | - let(:reading_group) { FactoryGirl.build(:reading_group_with_id) } | 4 | + let(:reading_group) { FactoryGirl.build(:reading_group, :with_id) } |
| 5 | 5 | ||
| 6 | describe 'new' do | 6 | describe 'new' do |
| 7 | before :each do | 7 | before :each do |
spec/controllers/repositories_controller_spec.rb
| @@ -93,7 +93,7 @@ describe RepositoriesController, :type => :controller do | @@ -93,7 +93,7 @@ describe RepositoriesController, :type => :controller do | ||
| 93 | before :each do | 93 | before :each do |
| 94 | processing = FactoryGirl.build(:processing) | 94 | processing = FactoryGirl.build(:processing) |
| 95 | 95 | ||
| 96 | - KalibroConfiguration.expects(:find).with(repository.id).returns(FactoryGirl.build(:kalibro_configuration_with_id)) | 96 | + KalibroConfiguration.expects(:find).with(repository.id).returns(FactoryGirl.build(:kalibro_configuration, :with_id)) |
| 97 | Repository.expects(:find).with(repository.id).returns(repository) | 97 | Repository.expects(:find).with(repository.id).returns(repository) |
| 98 | 98 | ||
| 99 | get :show, id: repository.id.to_s, project_id: project.id.to_s | 99 | get :show, id: repository.id.to_s, project_id: project.id.to_s |
| @@ -107,7 +107,7 @@ describe RepositoriesController, :type => :controller do | @@ -107,7 +107,7 @@ describe RepositoriesController, :type => :controller do | ||
| 107 | before :each do | 107 | before :each do |
| 108 | processing = FactoryGirl.build(:processing) | 108 | processing = FactoryGirl.build(:processing) |
| 109 | 109 | ||
| 110 | - KalibroConfiguration.expects(:find).with(repository.id).returns(FactoryGirl.build(:kalibro_configuration_with_id)) | 110 | + KalibroConfiguration.expects(:find).with(repository.id).returns(FactoryGirl.build(:kalibro_configuration, :with_id)) |
| 111 | Repository.expects(:find).with(repository.id).returns(repository) | 111 | Repository.expects(:find).with(repository.id).returns(repository) |
| 112 | 112 | ||
| 113 | get :show, id: repository.id.to_s, project_id: project.id.to_s | 113 | get :show, id: repository.id.to_s, project_id: project.id.to_s |
| @@ -333,7 +333,7 @@ describe RepositoriesController, :type => :controller do | @@ -333,7 +333,7 @@ describe RepositoriesController, :type => :controller do | ||
| 333 | subject.expects(:repository_owner?).returns true | 333 | subject.expects(:repository_owner?).returns true |
| 334 | repository.expects(:process) | 334 | repository.expects(:process) |
| 335 | Repository.expects(:find).at_least_once.with(repository.id).returns(repository) | 335 | Repository.expects(:find).at_least_once.with(repository.id).returns(repository) |
| 336 | - KalibroConfiguration.expects(:find).with(repository.id).returns(FactoryGirl.build(:kalibro_configuration_with_id)) | 336 | + KalibroConfiguration.expects(:find).with(repository.id).returns(FactoryGirl.build(:kalibro_configuration, :with_id)) |
| 337 | get :process_repository, project_id: project.id.to_s, id: repository.id | 337 | get :process_repository, project_id: project.id.to_s, id: repository.id |
| 338 | end | 338 | end |
| 339 | it { is_expected.to redirect_to(project_repository_path(repository.project_id, repository.id)) } | 339 | it { is_expected.to redirect_to(project_repository_path(repository.project_id, repository.id)) } |
spec/helpers/kalibro_configurations_helper_spec.rb
| @@ -3,7 +3,7 @@ require 'rails_helper' | @@ -3,7 +3,7 @@ require 'rails_helper' | ||
| 3 | describe KalibroConfigurationsHelper, :type => :helper do | 3 | describe KalibroConfigurationsHelper, :type => :helper do |
| 4 | describe 'kalibro_configuration_owner?' do | 4 | describe 'kalibro_configuration_owner?' do |
| 5 | before :each do | 5 | before :each do |
| 6 | - @subject = FactoryGirl.build(:kalibro_configuration_with_id) | 6 | + @subject = FactoryGirl.build(:kalibro_configuration, :with_id) |
| 7 | end | 7 | end |
| 8 | 8 | ||
| 9 | context 'returns false if not logged in' do | 9 | context 'returns false if not logged in' do |
spec/helpers/metric_configurations_helper_spec.rb
| @@ -9,7 +9,7 @@ describe MetricConfigurationsHelper, :type => :helper do | @@ -9,7 +9,7 @@ describe MetricConfigurationsHelper, :type => :helper do | ||
| 9 | end | 9 | end |
| 10 | 10 | ||
| 11 | describe 'reading_group_options' do | 11 | describe 'reading_group_options' do |
| 12 | - let! (:reading_group) { FactoryGirl.build(:reading_group_with_id) } | 12 | + let! (:reading_group) { FactoryGirl.build(:reading_group, :with_id) } |
| 13 | 13 | ||
| 14 | before :each do | 14 | before :each do |
| 15 | ReadingGroup.expects(:all).returns([reading_group]) | 15 | ReadingGroup.expects(:all).returns([reading_group]) |
spec/helpers/reading_groups_helper_spec.rb
| @@ -4,7 +4,7 @@ describe ReadingGroupsHelper, :type => :helper do | @@ -4,7 +4,7 @@ describe ReadingGroupsHelper, :type => :helper do | ||
| 4 | 4 | ||
| 5 | describe 'reading_group_owner?' do | 5 | describe 'reading_group_owner?' do |
| 6 | before :each do | 6 | before :each do |
| 7 | - @subject = FactoryGirl.build(:reading_group_with_id) | 7 | + @subject = FactoryGirl.build(:reading_group, :with_id) |
| 8 | end | 8 | end |
| 9 | 9 | ||
| 10 | context 'returns false if not logged in' do | 10 | context 'returns false if not logged in' do |
| @@ -22,7 +22,7 @@ describe ReadingGroupsHelper, :type => :helper do | @@ -22,7 +22,7 @@ describe ReadingGroupsHelper, :type => :helper do | ||
| 22 | @ownerships = [] | 22 | @ownerships = [] |
| 23 | @ownerships.expects(:find_by_reading_group_id).with(@subject.id).returns(nil) | 23 | @ownerships.expects(:find_by_reading_group_id).with(@subject.id).returns(nil) |
| 24 | 24 | ||
| 25 | - User.any_instance.expects(:reading_group_ownerships).returns(@ownerships) | 25 | + User.any_instance.expects(:reading_group_attributess).returns(@ownerships) |
| 26 | end | 26 | end |
| 27 | 27 | ||
| 28 | it { expect(helper.reading_groups_owner?(@subject.id)).to be_falsey } | 28 | it { expect(helper.reading_groups_owner?(@subject.id)).to be_falsey } |
| @@ -33,10 +33,10 @@ describe ReadingGroupsHelper, :type => :helper do | @@ -33,10 +33,10 @@ describe ReadingGroupsHelper, :type => :helper do | ||
| 33 | helper.expects(:user_signed_in?).returns(true) | 33 | helper.expects(:user_signed_in?).returns(true) |
| 34 | helper.expects(:current_user).returns(FactoryGirl.build(:user)) | 34 | helper.expects(:current_user).returns(FactoryGirl.build(:user)) |
| 35 | 35 | ||
| 36 | - @ownership = FactoryGirl.build(:reading_group_ownership) | 36 | + @ownership = FactoryGirl.build(:reading_group_attributes) |
| 37 | @ownerships = [] | 37 | @ownerships = [] |
| 38 | @ownerships.expects(:find_by_reading_group_id).with(@subject.id).returns(@ownership) | 38 | @ownerships.expects(:find_by_reading_group_id).with(@subject.id).returns(@ownership) |
| 39 | - User.any_instance.expects(:reading_group_ownerships).returns(@ownerships) | 39 | + User.any_instance.expects(:reading_group_attributess).returns(@ownerships) |
| 40 | end | 40 | end |
| 41 | 41 | ||
| 42 | it { expect(helper.reading_groups_owner?(@subject.id)).to be_truthy } | 42 | it { expect(helper.reading_groups_owner?(@subject.id)).to be_truthy } |
spec/models/user_spec.rb
| @@ -11,7 +11,7 @@ describe User, :type => :model do | @@ -11,7 +11,7 @@ describe User, :type => :model do | ||
| 11 | 11 | ||
| 12 | describe 'associations' do | 12 | describe 'associations' do |
| 13 | it { is_expected.to have_many(:project_attributes) } | 13 | it { is_expected.to have_many(:project_attributes) } |
| 14 | - it { is_expected.to have_many(:reading_group_ownerships) } | 14 | + it { is_expected.to have_many(:reading_group_attributess) } |
| 15 | it { is_expected.to have_many(:kalibro_configuration_ownerships) } | 15 | it { is_expected.to have_many(:kalibro_configuration_ownerships) } |
| 16 | end | 16 | end |
| 17 | 17 |