Commit ce91235817b5566f7843115a50ac196f83b979e4

Authored by Diego Camarinha
Committed by Rafael Manzo
1 parent 3137a0c8

Renamed Configuration to MezuroConfiguration.

Signed-off-by: Renan Fichberg <rfichberg@gmail.com>
app/controllers/concerns/ownership_authentication.rb
... ... @@ -25,8 +25,8 @@ module OwnershipAuthentication
25 25 check_reading_group_ownership(params[:reading_group_id])
26 26 end
27 27  
28   - def configuration_owner?
29   - check_configuration_ownership(params[:configuration_id])
  28 + def mezuro_configuration_owner?
  29 + check_mezuro_configuration_ownership(params[:configuration_id])
30 30 end
31 31  
32 32 private
... ... @@ -49,10 +49,10 @@ module OwnershipAuthentication
49 49 end
50 50 end
51 51  
52   - def check_configuration_ownership(id)
53   - if current_user.configuration_ownerships.find_by_configuration_id(id).nil?
  52 + def check_mezuro_configuration_ownership(id)
  53 + if current_user.mezuro_configuration_ownerships.find_by_mezuro_configuration_id(id).nil?
54 54 respond_to do |format|
55   - format.html { redirect_to configuration_url(id), notice: "You're not allowed to do this operation" }
  55 + format.html { redirect_to mezuro_configuration_url(id), notice: "You're not allowed to do this operation" }
56 56 format.json { head :no_content }
57 57 end
58 58 end
... ...
config/routes.rb
1 1 Mezuro::Application.routes.draw do
2   - #resources :repositories
3   -
4 2 devise_for :users
5 3 get 'users/:user_id/projects' => 'users#projects', as: :user_projects
6 4  
... ...
spec/factories/configuration_ownerships.rb
... ... @@ -1,8 +0,0 @@
1   -# Read about factories at https://github.com/thoughtbot/factory_girl
2   -
3   -FactoryGirl.define do
4   - factory :configuration_ownership do
5   - user_id 1
6   - configuration_id 1
7   - end
8   -end
spec/factories/mezuro_configuration_ownerships.rb 0 → 100644
... ... @@ -0,0 +1,8 @@
  1 +# Read about factories at https://github.com/thoughtbot/factory_girl
  2 +
  3 +FactoryGirl.define do
  4 + factory :mezuro_configuration_ownership do
  5 + user_id 1
  6 + configuration_id 1
  7 + end
  8 +end
... ...
spec/factories/mezuro_configurations.rb
1   -FactoryGirl.define do
  1 + FactoryGirl.define do
2 2 factory :mezuro_configuration, class: MezuroConfiguration do
3 3 id 1
4 4 name "Java"
... ... @@ -10,4 +10,4 @@ FactoryGirl.define do
10 10 name "Perl"
11 11 description "Code metrics for Perl."
12 12 end
13   -end
14 13 \ No newline at end of file
  14 +end
... ...
spec/models/configuration_spec.rb
... ... @@ -1,62 +0,0 @@
1   -require 'spec_helper'
2   -
3   -describe MezuroConfiguration do
4   - subject { FactoryGirl.build(:mezuro_configuration) }
5   - describe 'methods' do
6   - describe 'persisted?' do
7   - before :each do
8   - MezuroConfiguration.expects(:exists?).with(subject.id).returns(false)
9   - end
10   -
11   - it 'should return false' do
12   - subject.persisted?.should eq(false)
13   - end
14   - end
15   -
16   - describe 'update' do
17   - before :each do
18   - @subject_params = Hash[FactoryGirl.attributes_for(:mezuro_configuration).map { |k,v| [k.to_s, v.to_s] }] #FIXME: Mocha is creating the expectations with strings, but FactoryGirl returns everything with sybols and integers
19   - end
20   -
21   - context 'with valid attributes' do
22   - before :each do
23   - subject.expects(:save).returns(true)
24   - end
25   -
26   - it 'should return true' do
27   - subject.update(@subject_params).should eq(true)
28   - end
29   - end
30   -
31   - context 'with invalid attributes' do
32   - before :each do
33   - subject.expects(:save).returns(false)
34   - end
35   -
36   - it 'should return false' do
37   - subject.update(@subject_params).should eq(false)
38   - end
39   - end
40   - end
41   - end
42   -
43   - describe 'validations' do
44   - context 'active model validations' do
45   - before :each do
46   - MezuroConfiguration.expects(:all).at_least_once.returns([])
47   - end
48   - it { should validate_presence_of(:name) }
49   - end
50   -
51   - context 'kalibro validations' do
52   - before :each do
53   - MezuroConfiguration.expects(:request).returns(42)
54   - end
55   -
56   - it 'should validate uniqueness' do
57   - KalibroUniquenessValidator.any_instance.expects(:validate_each).with(subject, :name, subject.name)
58   - subject.save
59   - end
60   - end
61   - end
62   -end
spec/models/mezuro_configuration_spec.rb 0 → 100644
... ... @@ -0,0 +1,62 @@
  1 +require 'spec_helper'
  2 +
  3 +describe MezuroConfiguration do
  4 + subject { FactoryGirl.build(:mezuro_configuration) }
  5 + describe 'methods' do
  6 + describe 'persisted?' do
  7 + before :each do
  8 + MezuroConfiguration.expects(:exists?).with(subject.id).returns(false)
  9 + end
  10 +
  11 + it 'should return false' do
  12 + subject.persisted?.should eq(false)
  13 + end
  14 + end
  15 +
  16 + describe 'update' do
  17 + before :each do
  18 + @subject_params = Hash[FactoryGirl.attributes_for(:mezuro_configuration).map { |k,v| [k.to_s, v.to_s] }] #FIXME: Mocha is creating the expectations with strings, but FactoryGirl returns everything with sybols and integers
  19 + end
  20 +
  21 + context 'with valid attributes' do
  22 + before :each do
  23 + subject.expects(:save).returns(true)
  24 + end
  25 +
  26 + it 'should return true' do
  27 + subject.update(@subject_params).should eq(true)
  28 + end
  29 + end
  30 +
  31 + context 'with invalid attributes' do
  32 + before :each do
  33 + subject.expects(:save).returns(false)
  34 + end
  35 +
  36 + it 'should return false' do
  37 + subject.update(@subject_params).should eq(false)
  38 + end
  39 + end
  40 + end
  41 + end
  42 +
  43 + describe 'validations' do
  44 + context 'active model validations' do
  45 + before :each do
  46 + MezuroConfiguration.expects(:all).at_least_once.returns([])
  47 + end
  48 + it { should validate_presence_of(:name) }
  49 + end
  50 +
  51 + context 'kalibro validations' do
  52 + before :each do
  53 + MezuroConfiguration.expects(:request).returns(42)
  54 + end
  55 +
  56 + it 'should validate uniqueness' do
  57 + KalibroUniquenessValidator.any_instance.expects(:validate_each).with(subject, :name, subject.name)
  58 + subject.save
  59 + end
  60 + end
  61 + end
  62 +end
... ...
spec/routing/mezuro_configuration_routing_spec.rb
... ... @@ -23,4 +23,4 @@ describe MezuroConfigurationsController do
23 23 it { should route(:delete, '/mezuro_configurations/1').
24 24 to(controller: :mezuro_configurations, action: :destroy, id: "1") }
25 25 end
26   -end
27 26 \ No newline at end of file
  27 +end
... ...