Commit ce91235817b5566f7843115a50ac196f83b979e4
Committed by
Rafael Manzo
1 parent
3137a0c8
Exists in
colab
and in
4 other branches
Renamed Configuration to MezuroConfiguration.
Signed-off-by: Renan Fichberg <rfichberg@gmail.com>
Showing
8 changed files
with
78 additions
and
80 deletions
Show diff stats
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
spec/factories/configuration_ownerships.rb
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 |
... | ... | @@ -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