Commit cebea5f125ebbd199a5596ac6173e99e80939641

Authored by Diego Camarinha
Committed by Rafael Manzo
1 parent f253a4f1

Renamed mezuro_configuration to kalibro_configuration

features/kalibro_configuration/create.feature 0 → 100644
@@ -0,0 +1,41 @@ @@ -0,0 +1,41 @@
  1 +Feature: Configuration Creation
  2 + In order to register my configurations
  3 + As a regular user
  4 + I should be able to create configurations
  5 +
  6 + @kalibro_configuration_restart
  7 + Scenario: Should not create configuration without login
  8 + Given I am at the All Configurations page
  9 + Then I should not see "New Configuration"
  10 +
  11 + @kalibro_configuration_restart
  12 + Scenario: configuration creation
  13 + Given I am a regular user
  14 + And I am signed in
  15 + And I am at the New Configuration page
  16 + And I fill the Name field with "Kalibro"
  17 + And I fill the Description field with "Web Service to collect metrics"
  18 + When I press the Save button
  19 + Then I should see "Kalibro"
  20 + And I should see "Web Service to collect metrics"
  21 +
  22 + @kalibro_configuration_restart
  23 + Scenario: configuration creation with already taken name
  24 + Given I am a regular user
  25 + And I am signed in
  26 + And I have a configuration named "Kalibro"
  27 + And I am at the New Configuration page
  28 + And I fill the Name field with "Kalibro"
  29 + And I fill the Description field with "Web Service to collect metrics"
  30 + When I press the Save button
  31 + Then I should see "Name There is already a KalibroConfiguration with name Kalibro!"
  32 +
  33 + @kalibro_configuration_restart
  34 + Scenario: configuration creation with blank name
  35 + Given I am a regular user
  36 + And I am signed in
  37 + And I am at the New Configuration page
  38 + And I fill the Name field with " "
  39 + And I fill the Description field with "Web Service to collect metrics"
  40 + When I press the Save button
  41 + Then I should see "Name can't be blank"
features/kalibro_configuration/deletion.feature 0 → 100644
@@ -0,0 +1,28 @@ @@ -0,0 +1,28 @@
  1 +Feature: Configuration Deletion
  2 + In order to be able to remove configurations
  3 + As a regular user
  4 + The system should have an interface to it
  5 +
  6 + @kalibro_configuration_restart
  7 + Scenario: Should not delete a configuration without user authentication
  8 + Given I have a sample configuration
  9 + When I am at the Sample Configuration page
  10 + Then I should not see "Destroy"
  11 +
  12 + @kalibro_configuration_restart
  13 + Scenario: Should not delete a configuration that doesn't belongs to user
  14 + Given I am a regular user
  15 + And I am signed in
  16 + And I have a sample configuration
  17 + When I am at the Sample Configuration page
  18 + Then I should not see "Destroy"
  19 +
  20 + @kalibro_configuration_restart
  21 + Scenario: Should delete a configuration that I own
  22 + Given I am a regular user
  23 + And I am signed in
  24 + And I own a sample configuration
  25 + And I am at the Sample Configuration page
  26 + When I click the Destroy Configuration link
  27 + Then I should be in the All configurations page
  28 + And the sample configuration should not be there
features/kalibro_configuration/edition.feature 0 → 100644
@@ -0,0 +1,83 @@ @@ -0,0 +1,83 @@
  1 +Feature: Configuration
  2 + In Order to be able to update my configurations info
  3 + As a regular user
  4 + I should be able to edit my configurations
  5 +
  6 + @kalibro_configuration_restart
  7 + Scenario: Should go to the edit page from a configuration that I own
  8 + Given I am a regular user
  9 + And I am signed in
  10 + And I own a sample configuration
  11 + And I am at the All Configurations page
  12 + When I click the Edit link
  13 + Then I should be in the Edit Configuration page
  14 +
  15 + @kalibro_configuration_restart
  16 + Scenario: Should not show edit links from configurations that doesn't belongs to me
  17 + Given I am a regular user
  18 + And I am signed in
  19 + And I have a sample configuration
  20 + And I am at the All Configurations page
  21 + Then I should not see Edit within table
  22 +
  23 + @kalibro_configuration_restart
  24 + Scenario: Should not render the edit page if the configuration doesn't belongs to the current user
  25 + Given I am a regular user
  26 + And I am signed in
  27 + And I have a sample configuration
  28 + And I am at the All Projects page
  29 + When I visit the sample configuration edit page
  30 + Then I should see "You're not allowed to do this operation"
  31 +
  32 + @kalibro_configuration_restart
  33 + Scenario: Filling up the form
  34 + Given I am a regular user
  35 + And I am signed in
  36 + And I own a sample configuration
  37 + And I am at the All Configurations page
  38 + When I click the Edit link
  39 + Then The field "kalibro_configuration[name]" should be filled with the sample configuration "name"
  40 + And The field "kalibro_configuration[description]" should be filled with the sample configuration "description"
  41 +
  42 + @kalibro_configuration_restart
  43 + Scenario: With valid attributes
  44 + Given I am a regular user
  45 + And I am signed in
  46 + And I own a sample configuration
  47 + And I am at the sample configuration edit page
  48 + And I fill the Name field with "Kalibro"
  49 + And I fill the Description field with "Web Service to collect metrics"
  50 + When I press the Save button
  51 + Then I should see "Kalibro"
  52 + And I should see "Web Service to collect metrics"
  53 +
  54 + @kalibro_configuration_restart
  55 + Scenario: With configuration name already taken
  56 + Given I am a regular user
  57 + And I am signed in
  58 + And I have a configuration named "Qt-Calculator"
  59 + And I own a configuration named "Kalibro"
  60 + And I am at the sample configuration edit page
  61 + And I fill the Name field with "Qt-Calculator"
  62 + When I press the Save button
  63 + Then I should see "Name There is already a KalibroConfiguration with name Qt-Calculator!"
  64 +
  65 + @kalibro_configuration_restart
  66 + Scenario: Editing just the description
  67 + Given I am a regular user
  68 + And I am signed in
  69 + And I own a sample configuration
  70 + And I am at the sample configuration edit page
  71 + And I fill the Description field with "Web Service to collect metrics"
  72 + When I press the Save button
  73 + And I should see "Web Service to collect metrics"
  74 +
  75 + @kalibro_configuration_restart
  76 + Scenario: With blank configuration name
  77 + Given I am a regular user
  78 + And I am signed in
  79 + And I own a sample configuration
  80 + And I am at the sample configuration edit page
  81 + And I fill the Name field with " "
  82 + When I press the Save button
  83 + Then I should see "Name can't be blank"
features/kalibro_configuration/listing.feature 0 → 100644
@@ -0,0 +1,30 @@ @@ -0,0 +1,30 @@
  1 +Feature: Configuration listing
  2 + In order to interact with other configurations
  3 + As a regular user
  4 + I should have various listings
  5 +
  6 + Scenario: Listing configurations
  7 + Given I am at the homepage
  8 + When I click the Configuration link
  9 + Then I should see "Configurations"
  10 + And I should see "Name"
  11 + And I should see "Description"
  12 + And I should see "You must be logged in to create new Configurations."
  13 +
  14 + @kalibro_configuration_restart
  15 + Scenario: Should list the existing configurations
  16 + Given I am a regular user
  17 + And I am signed in
  18 + And I have a sample configuration
  19 + And I am at the All Configurations page
  20 + Then the sample configuration should be there
  21 + And I should not see "You must be logged in to create new Configurations."
  22 +
  23 + @kalibro_configuration_restart
  24 + Scenario: Should show the existing configuration
  25 + Given I am a regular user
  26 + And I am signed in
  27 + And I have a sample configuration
  28 + And I am at the All Configurations page
  29 + When I click the Show link
  30 + Then the sample configuration should be there
0 \ No newline at end of file 31 \ No newline at end of file
features/kalibro_configuration/show.feature 0 → 100644
@@ -0,0 +1,10 @@ @@ -0,0 +1,10 @@
  1 +Feature: Show Configuration
  2 + In order to know all the contents of a given configuration
  3 + As a regular user
  4 + I should be able to see each of them
  5 +
  6 +@kalibro_configuration_restart
  7 +Scenario: Checking configuration contents
  8 + Given I have a sample configuration
  9 + When I am at the Sample Configuration page
  10 + Then the sample configuration should be there
0 \ No newline at end of file 11 \ No newline at end of file
features/mezuro_configuration/create.feature
@@ -1,41 +0,0 @@ @@ -1,41 +0,0 @@
1 -Feature: Configuration Creation  
2 - In order to register my configurations  
3 - As a regular user  
4 - I should be able to create configurations  
5 -  
6 - @kalibro_configuration_restart  
7 - Scenario: Should not create configuration without login  
8 - Given I am at the All Configurations page  
9 - Then I should not see "New Configuration"  
10 -  
11 - @kalibro_configuration_restart  
12 - Scenario: configuration creation  
13 - Given I am a regular user  
14 - And I am signed in  
15 - And I am at the New Configuration page  
16 - And I fill the Name field with "Kalibro"  
17 - And I fill the Description field with "Web Service to collect metrics"  
18 - When I press the Save button  
19 - Then I should see "Kalibro"  
20 - And I should see "Web Service to collect metrics"  
21 -  
22 - @kalibro_configuration_restart  
23 - Scenario: configuration creation with already taken name  
24 - Given I am a regular user  
25 - And I am signed in  
26 - And I have a configuration named "Kalibro"  
27 - And I am at the New Configuration page  
28 - And I fill the Name field with "Kalibro"  
29 - And I fill the Description field with "Web Service to collect metrics"  
30 - When I press the Save button  
31 - Then I should see "Name There is already a KalibroConfiguration with name Kalibro!"  
32 -  
33 - @kalibro_configuration_restart  
34 - Scenario: configuration creation with blank name  
35 - Given I am a regular user  
36 - And I am signed in  
37 - And I am at the New Configuration page  
38 - And I fill the Name field with " "  
39 - And I fill the Description field with "Web Service to collect metrics"  
40 - When I press the Save button  
41 - Then I should see "Name can't be blank"  
features/mezuro_configuration/deletion.feature
@@ -1,28 +0,0 @@ @@ -1,28 +0,0 @@
1 -Feature: Configuration Deletion  
2 - In order to be able to remove configurations  
3 - As a regular user  
4 - The system should have an interface to it  
5 -  
6 - @kalibro_configuration_restart  
7 - Scenario: Should not delete a configuration without user authentication  
8 - Given I have a sample configuration  
9 - When I am at the Sample Configuration page  
10 - Then I should not see "Destroy"  
11 -  
12 - @kalibro_configuration_restart  
13 - Scenario: Should not delete a configuration that doesn't belongs to user  
14 - Given I am a regular user  
15 - And I am signed in  
16 - And I have a sample configuration  
17 - When I am at the Sample Configuration page  
18 - Then I should not see "Destroy"  
19 -  
20 - @kalibro_configuration_restart  
21 - Scenario: Should delete a configuration that I own  
22 - Given I am a regular user  
23 - And I am signed in  
24 - And I own a sample configuration  
25 - And I am at the Sample Configuration page  
26 - When I click the Destroy Configuration link  
27 - Then I should be in the All configurations page  
28 - And the sample configuration should not be there  
features/mezuro_configuration/edition.feature
@@ -1,83 +0,0 @@ @@ -1,83 +0,0 @@
1 -Feature: Configuration  
2 - In Order to be able to update my configurations info  
3 - As a regular user  
4 - I should be able to edit my configurations  
5 -  
6 - @kalibro_configuration_restart  
7 - Scenario: Should go to the edit page from a configuration that I own  
8 - Given I am a regular user  
9 - And I am signed in  
10 - And I own a sample configuration  
11 - And I am at the All Configurations page  
12 - When I click the Edit link  
13 - Then I should be in the Edit Configuration page  
14 -  
15 - @kalibro_configuration_restart  
16 - Scenario: Should not show edit links from configurations that doesn't belongs to me  
17 - Given I am a regular user  
18 - And I am signed in  
19 - And I have a sample configuration  
20 - And I am at the All Configurations page  
21 - Then I should not see Edit within table  
22 -  
23 - @kalibro_configuration_restart  
24 - Scenario: Should not render the edit page if the configuration doesn't belongs to the current user  
25 - Given I am a regular user  
26 - And I am signed in  
27 - And I have a sample configuration  
28 - And I am at the All Projects page  
29 - When I visit the sample configuration edit page  
30 - Then I should see "You're not allowed to do this operation"  
31 -  
32 - @kalibro_configuration_restart  
33 - Scenario: Filling up the form  
34 - Given I am a regular user  
35 - And I am signed in  
36 - And I own a sample configuration  
37 - And I am at the All Configurations page  
38 - When I click the Edit link  
39 - Then The field "kalibro_configuration[name]" should be filled with the sample configuration "name"  
40 - And The field "kalibro_configuration[description]" should be filled with the sample configuration "description"  
41 -  
42 - @kalibro_configuration_restart  
43 - Scenario: With valid attributes  
44 - Given I am a regular user  
45 - And I am signed in  
46 - And I own a sample configuration  
47 - And I am at the sample configuration edit page  
48 - And I fill the Name field with "Kalibro"  
49 - And I fill the Description field with "Web Service to collect metrics"  
50 - When I press the Save button  
51 - Then I should see "Kalibro"  
52 - And I should see "Web Service to collect metrics"  
53 -  
54 - @kalibro_configuration_restart  
55 - Scenario: With configuration name already taken  
56 - Given I am a regular user  
57 - And I am signed in  
58 - And I have a configuration named "Qt-Calculator"  
59 - And I own a configuration named "Kalibro"  
60 - And I am at the sample configuration edit page  
61 - And I fill the Name field with "Qt-Calculator"  
62 - When I press the Save button  
63 - Then I should see "Name There is already a KalibroConfiguration with name Qt-Calculator!"  
64 -  
65 - @kalibro_configuration_restart  
66 - Scenario: Editing just the description  
67 - Given I am a regular user  
68 - And I am signed in  
69 - And I own a sample configuration  
70 - And I am at the sample configuration edit page  
71 - And I fill the Description field with "Web Service to collect metrics"  
72 - When I press the Save button  
73 - And I should see "Web Service to collect metrics"  
74 -  
75 - @kalibro_configuration_restart  
76 - Scenario: With blank configuration name  
77 - Given I am a regular user  
78 - And I am signed in  
79 - And I own a sample configuration  
80 - And I am at the sample configuration edit page  
81 - And I fill the Name field with " "  
82 - When I press the Save button  
83 - Then I should see "Name can't be blank"  
features/mezuro_configuration/listing.feature
@@ -1,30 +0,0 @@ @@ -1,30 +0,0 @@
1 -Feature: Configuration listing  
2 - In order to interact with other configurations  
3 - As a regular user  
4 - I should have various listings  
5 -  
6 - Scenario: Listing configurations  
7 - Given I am at the homepage  
8 - When I click the Configuration link  
9 - Then I should see "Configurations"  
10 - And I should see "Name"  
11 - And I should see "Description"  
12 - And I should see "You must be logged in to create new Configurations."  
13 -  
14 - @kalibro_configuration_restart  
15 - Scenario: Should list the existing configurations  
16 - Given I am a regular user  
17 - And I am signed in  
18 - And I have a sample configuration  
19 - And I am at the All Configurations page  
20 - Then the sample configuration should be there  
21 - And I should not see "You must be logged in to create new Configurations."  
22 -  
23 - @kalibro_configuration_restart  
24 - Scenario: Should show the existing configuration  
25 - Given I am a regular user  
26 - And I am signed in  
27 - And I have a sample configuration  
28 - And I am at the All Configurations page  
29 - When I click the Show link  
30 - Then the sample configuration should be there  
31 \ No newline at end of file 0 \ No newline at end of file
features/mezuro_configuration/show.feature
@@ -1,10 +0,0 @@ @@ -1,10 +0,0 @@
1 -Feature: Show Configuration  
2 - In order to know all the contents of a given configuration  
3 - As a regular user  
4 - I should be able to see each of them  
5 -  
6 -@kalibro_configuration_restart  
7 -Scenario: Checking configuration contents  
8 - Given I have a sample configuration  
9 - When I am at the Sample Configuration page  
10 - Then the sample configuration should be there  
11 \ No newline at end of file 0 \ No newline at end of file
features/step_definitions/configuration_steps.rb
@@ -1,58 +0,0 @@ @@ -1,58 +0,0 @@
1 -Given(/^I am at the All Configurations page$/) do  
2 - visit kalibro_configurations_path  
3 -end  
4 -  
5 -Given(/^I am at the New Configuration page$/) do  
6 - visit new_kalibro_configuration_path  
7 -end  
8 -  
9 -Given(/^I have a configuration named "(.*?)"$/) do |name|  
10 - @kalibro_configuration = FactoryGirl.create(:kalibro_configuration, {name: name})  
11 -end  
12 -  
13 -Given(/^I have a sample configuration$/) do  
14 - @kalibro_configuration = FactoryGirl.create(:kalibro_configuration)  
15 -end  
16 -  
17 -Given(/^I own a sample configuration$/) do  
18 - @kalibro_configuration = FactoryGirl.create(:kalibro_configuration)  
19 - FactoryGirl.create(:kalibro_configuration_ownership, {id: nil, user_id: @user.id, kalibro_configuration_id: @kalibro_configuration.id})  
20 -end  
21 -  
22 -Given(/^I am at the Sample Configuration page$/) do  
23 - visit kalibro_configuration_path(@kalibro_configuration.id)  
24 -end  
25 -  
26 -Given(/^I am at the sample configuration edit page$/) do  
27 - visit edit_kalibro_configuration_path(@kalibro_configuration.id)  
28 -end  
29 -  
30 -Given(/^I own a configuration named "(.*?)"$/) do |name|  
31 - @kalibro_configuration = FactoryGirl.create(:kalibro_configuration, {name: name})  
32 - FactoryGirl.create(:kalibro_configuration_ownership, {id: nil, user_id: @user.id, kalibro_configuration_id: @kalibro_configuration.id})  
33 -end  
34 -  
35 -When(/^I visit the sample configuration edit page$/) do  
36 - visit edit_kalibro_configuration_path(@kalibro_configuration.id)  
37 -end  
38 -  
39 -Then(/^I should be in the Edit Configuration page$/) do  
40 - expect(page).to have_content("Edit Configuration")  
41 -end  
42 -  
43 -Then(/^The field "(.*?)" should be filled with the sample configuration "(.*?)"$/) do |field, value|  
44 - expect(page.find_field(field).value).to eq(@kalibro_configuration.send(value))  
45 -end  
46 -  
47 -Then(/^I should be in the All configurations page$/) do  
48 - expect(page).to have_content("Configurations")  
49 -end  
50 -  
51 -Then(/^the sample configuration should not be there$/) do  
52 - expect { KalibroConfiguration.find(@kalibro_configuration.id) }.to raise_error  
53 -end  
54 -  
55 -Then(/^the sample configuration should be there$/) do  
56 - expect(page).to have_content(@kalibro_configuration.name)  
57 - expect(page).to have_content(@kalibro_configuration.description)  
58 -end  
59 \ No newline at end of file 0 \ No newline at end of file
features/step_definitions/kalibro_configuration_steps.rb 0 → 100644
@@ -0,0 +1,58 @@ @@ -0,0 +1,58 @@
  1 +Given(/^I am at the All Configurations page$/) do
  2 + visit kalibro_configurations_path
  3 +end
  4 +
  5 +Given(/^I am at the New Configuration page$/) do
  6 + visit new_kalibro_configuration_path
  7 +end
  8 +
  9 +Given(/^I have a configuration named "(.*?)"$/) do |name|
  10 + @kalibro_configuration = FactoryGirl.create(:kalibro_configuration, {name: name})
  11 +end
  12 +
  13 +Given(/^I have a sample configuration$/) do
  14 + @kalibro_configuration = FactoryGirl.create(:kalibro_configuration)
  15 +end
  16 +
  17 +Given(/^I own a sample configuration$/) do
  18 + @kalibro_configuration = FactoryGirl.create(:kalibro_configuration)
  19 + FactoryGirl.create(:kalibro_configuration_ownership, {id: nil, user_id: @user.id, kalibro_configuration_id: @kalibro_configuration.id})
  20 +end
  21 +
  22 +Given(/^I am at the Sample Configuration page$/) do
  23 + visit kalibro_configuration_path(@kalibro_configuration.id)
  24 +end
  25 +
  26 +Given(/^I am at the sample configuration edit page$/) do
  27 + visit edit_kalibro_configuration_path(@kalibro_configuration.id)
  28 +end
  29 +
  30 +Given(/^I own a configuration named "(.*?)"$/) do |name|
  31 + @kalibro_configuration = FactoryGirl.create(:kalibro_configuration, {name: name})
  32 + FactoryGirl.create(:kalibro_configuration_ownership, {id: nil, user_id: @user.id, kalibro_configuration_id: @kalibro_configuration.id})
  33 +end
  34 +
  35 +When(/^I visit the sample configuration edit page$/) do
  36 + visit edit_kalibro_configuration_path(@kalibro_configuration.id)
  37 +end
  38 +
  39 +Then(/^I should be in the Edit Configuration page$/) do
  40 + expect(page).to have_content("Edit Configuration")
  41 +end
  42 +
  43 +Then(/^The field "(.*?)" should be filled with the sample configuration "(.*?)"$/) do |field, value|
  44 + expect(page.find_field(field).value).to eq(@kalibro_configuration.send(value))
  45 +end
  46 +
  47 +Then(/^I should be in the All configurations page$/) do
  48 + expect(page).to have_content("Configurations")
  49 +end
  50 +
  51 +Then(/^the sample configuration should not be there$/) do
  52 + expect { KalibroConfiguration.find(@kalibro_configuration.id) }.to raise_error
  53 +end
  54 +
  55 +Then(/^the sample configuration should be there$/) do
  56 + expect(page).to have_content(@kalibro_configuration.name)
  57 + expect(page).to have_content(@kalibro_configuration.description)
  58 +end
0 \ No newline at end of file 59 \ No newline at end of file
spec/helpers/kalibro_configurations_helper_spec.rb 0 → 100644
@@ -0,0 +1,76 @@ @@ -0,0 +1,76 @@
  1 +require 'rails_helper'
  2 +
  3 +describe KalibroConfigurationsHelper, :type => :helper do
  4 + describe 'kalibro_configuration_owner?' do
  5 + before :each do
  6 + @subject = FactoryGirl.build(:kalibro_configuration_with_id)
  7 + end
  8 +
  9 + context 'returns false if not logged in' do
  10 + before :each do
  11 + helper.expects(:user_signed_in?).returns(false)
  12 + end
  13 + it { expect(helper.kalibro_configuration_owner?(@subject.id)).to be_falsey }
  14 + end
  15 +
  16 + context 'returns false if is not the owner' do
  17 + before :each do
  18 + helper.expects(:user_signed_in?).returns(true)
  19 + helper.expects(:current_user).returns(FactoryGirl.build(:user))
  20 +
  21 + @ownerships = []
  22 + @ownerships.expects(:find_by_kalibro_configuration_id).with(@subject.id).returns(nil)
  23 +
  24 + User.any_instance.expects(:kalibro_configuration_ownerships).returns(@ownerships)
  25 + end
  26 +
  27 + it { expect(helper.kalibro_configuration_owner?(@subject.id)).to be_falsey }
  28 + end
  29 +
  30 + context 'returns true if user is the kalibro_configuration owner' do
  31 + before :each do
  32 + helper.expects(:user_signed_in?).returns(true)
  33 + helper.expects(:current_user).returns(FactoryGirl.build(:user))
  34 +
  35 + @ownership = FactoryGirl.build(:kalibro_configuration_ownership)
  36 + @ownerships = []
  37 + @ownerships.expects(:find_by_kalibro_configuration_id).with(@subject.id).returns(@ownership)
  38 + User.any_instance.expects(:kalibro_configuration_ownerships).returns(@ownerships)
  39 + end
  40 +
  41 + it { expect(helper.kalibro_configuration_owner?(@subject.id)).to be_truthy }
  42 + end
  43 + end
  44 +
  45 + describe 'link to edit form' do
  46 + context 'when the metric is native' do
  47 + let(:metric_configuration) { FactoryGirl.build(:metric_configuration_with_id) }
  48 + let(:response_link) {"<a class=\"btn btn-info\" href=\"/kalibro_configurations/#{metric_configuration.kalibro_configuration_id}/metric_configurations/#{metric_configuration.id}/edit\">Edit</a>"}
  49 +
  50 + it { expect(helper.link_to_edit_form(metric_configuration, metric_configuration.kalibro_configuration_id)).to eq(response_link) }
  51 + end
  52 +
  53 + context 'when the metric is compound' do
  54 + let(:compound_metric_configuration) { FactoryGirl.build(:compound_metric_configuration_with_id) }
  55 + let(:response_link) {"<a class=\"btn btn-info\" href=\"/kalibro_configurations/#{compound_metric_configuration.kalibro_configuration_id}/compound_metric_configurations/#{compound_metric_configuration.id}/edit\">Edit</a>"}
  56 +
  57 + it { expect(helper.link_to_edit_form(compound_metric_configuration, compound_metric_configuration.kalibro_configuration_id)).to eq(response_link) }
  58 + end
  59 + end
  60 +
  61 + describe 'link to show page' do
  62 + context 'when the metric is native' do
  63 + let(:metric_configuration) { FactoryGirl.build(:metric_configuration_with_id) }
  64 + let(:response_link) {"<a class=\"btn btn-info\" href=\"/kalibro_configurations/#{metric_configuration.kalibro_configuration_id}/metric_configurations/#{metric_configuration.id}\">Show</a>"}
  65 +
  66 + it { expect(helper.link_to_show_page(metric_configuration, metric_configuration.kalibro_configuration_id)).to eq(response_link) }
  67 + end
  68 +
  69 + context 'when the metric is compound' do
  70 + let(:compound_metric_configuration) { FactoryGirl.build(:compound_metric_configuration_with_id) }
  71 + let(:response_link) {"<a class=\"btn btn-info\" href=\"/kalibro_configurations/#{compound_metric_configuration.kalibro_configuration_id}/compound_metric_configurations/#{compound_metric_configuration.id}\">Show</a>"}
  72 +
  73 + it { expect(helper.link_to_show_page(compound_metric_configuration, compound_metric_configuration.kalibro_configuration_id)).to eq(response_link) }
  74 + end
  75 + end
  76 +end
spec/helpers/mezuro_configurations_helper_spec.rb
@@ -1,76 +0,0 @@ @@ -1,76 +0,0 @@
1 -require 'rails_helper'  
2 -  
3 -describe KalibroConfigurationsHelper, :type => :helper do  
4 - describe 'kalibro_configuration_owner?' do  
5 - before :each do  
6 - @subject = FactoryGirl.build(:kalibro_configuration_with_id)  
7 - end  
8 -  
9 - context 'returns false if not logged in' do  
10 - before :each do  
11 - helper.expects(:user_signed_in?).returns(false)  
12 - end  
13 - it { expect(helper.kalibro_configuration_owner?(@subject.id)).to be_falsey }  
14 - end  
15 -  
16 - context 'returns false if is not the owner' do  
17 - before :each do  
18 - helper.expects(:user_signed_in?).returns(true)  
19 - helper.expects(:current_user).returns(FactoryGirl.build(:user))  
20 -  
21 - @ownerships = []  
22 - @ownerships.expects(:find_by_kalibro_configuration_id).with(@subject.id).returns(nil)  
23 -  
24 - User.any_instance.expects(:kalibro_configuration_ownerships).returns(@ownerships)  
25 - end  
26 -  
27 - it { expect(helper.kalibro_configuration_owner?(@subject.id)).to be_falsey }  
28 - end  
29 -  
30 - context 'returns true if user is the kalibro_configuration owner' do  
31 - before :each do  
32 - helper.expects(:user_signed_in?).returns(true)  
33 - helper.expects(:current_user).returns(FactoryGirl.build(:user))  
34 -  
35 - @ownership = FactoryGirl.build(:kalibro_configuration_ownership)  
36 - @ownerships = []  
37 - @ownerships.expects(:find_by_kalibro_configuration_id).with(@subject.id).returns(@ownership)  
38 - User.any_instance.expects(:kalibro_configuration_ownerships).returns(@ownerships)  
39 - end  
40 -  
41 - it { expect(helper.kalibro_configuration_owner?(@subject.id)).to be_truthy }  
42 - end  
43 - end  
44 -  
45 - describe 'link to edit form' do  
46 - context 'when the metric is native' do  
47 - let(:metric_configuration) { FactoryGirl.build(:metric_configuration_with_id) }  
48 - let(:response_link) {"<a class=\"btn btn-info\" href=\"/kalibro_configurations/#{metric_configuration.kalibro_configuration_id}/metric_configurations/#{metric_configuration.id}/edit\">Edit</a>"}  
49 -  
50 - it { expect(helper.link_to_edit_form(metric_configuration, metric_configuration.kalibro_configuration_id)).to eq(response_link) }  
51 - end  
52 -  
53 - context 'when the metric is compound' do  
54 - let(:compound_metric_configuration) { FactoryGirl.build(:compound_metric_configuration_with_id) }  
55 - let(:response_link) {"<a class=\"btn btn-info\" href=\"/kalibro_configurations/#{compound_metric_configuration.kalibro_configuration_id}/compound_metric_configurations/#{compound_metric_configuration.id}/edit\">Edit</a>"}  
56 -  
57 - it { expect(helper.link_to_edit_form(compound_metric_configuration, compound_metric_configuration.kalibro_configuration_id)).to eq(response_link) }  
58 - end  
59 - end  
60 -  
61 - describe 'link to show page' do  
62 - context 'when the metric is native' do  
63 - let(:metric_configuration) { FactoryGirl.build(:metric_configuration_with_id) }  
64 - let(:response_link) {"<a class=\"btn btn-info\" href=\"/kalibro_configurations/#{metric_configuration.kalibro_configuration_id}/metric_configurations/#{metric_configuration.id}\">Show</a>"}  
65 -  
66 - it { expect(helper.link_to_show_page(metric_configuration, metric_configuration.kalibro_configuration_id)).to eq(response_link) }  
67 - end  
68 -  
69 - context 'when the metric is compound' do  
70 - let(:compound_metric_configuration) { FactoryGirl.build(:compound_metric_configuration_with_id) }  
71 - let(:response_link) {"<a class=\"btn btn-info\" href=\"/kalibro_configurations/#{compound_metric_configuration.kalibro_configuration_id}/compound_metric_configurations/#{compound_metric_configuration.id}\">Show</a>"}  
72 -  
73 - it { expect(helper.link_to_show_page(compound_metric_configuration, compound_metric_configuration.kalibro_configuration_id)).to eq(response_link) }  
74 - end  
75 - end  
76 -end  
spec/routing/kalibro_configuration_routing_spec.rb 0 → 100644
@@ -0,0 +1,20 @@ @@ -0,0 +1,20 @@
  1 +require "rails_helper"
  2 +
  3 +describe KalibroConfigurationsController, :type => :routing do
  4 + describe "routing" do
  5 + it { is_expected.to route(:get, '/kalibro_configurations/new').
  6 + to(controller: :kalibro_configurations, action: :new) }
  7 + it { is_expected.to route(:get, '/kalibro_configurations').
  8 + to(controller: :kalibro_configurations, action: :index) }
  9 + it { is_expected.to route(:post, '/kalibro_configurations').
  10 + to(controller: :kalibro_configurations, action: :create) }
  11 + it { is_expected.to route(:get, '/kalibro_configurations/1').
  12 + to(controller: :kalibro_configurations, action: :show, id: "1") }
  13 + it { is_expected.to route(:get, '/kalibro_configurations/1/edit').
  14 + to(controller: :kalibro_configurations, action: :edit, id: "1") }
  15 + it { is_expected.to route(:put, '/kalibro_configurations/1').
  16 + to(controller: :kalibro_configurations, action: :update, id: "1") }
  17 + it { is_expected.to route(:delete, '/kalibro_configurations/1').
  18 + to(controller: :kalibro_configurations, action: :destroy, id: "1") }
  19 + end
  20 +end
spec/routing/mezuro_configuration_routing_spec.rb
@@ -1,20 +0,0 @@ @@ -1,20 +0,0 @@
1 -require "rails_helper"  
2 -  
3 -describe KalibroConfigurationsController, :type => :routing do  
4 - describe "routing" do  
5 - it { is_expected.to route(:get, '/kalibro_configurations/new').  
6 - to(controller: :kalibro_configurations, action: :new) }  
7 - it { is_expected.to route(:get, '/kalibro_configurations').  
8 - to(controller: :kalibro_configurations, action: :index) }  
9 - it { is_expected.to route(:post, '/kalibro_configurations').  
10 - to(controller: :kalibro_configurations, action: :create) }  
11 - it { is_expected.to route(:get, '/kalibro_configurations/1').  
12 - to(controller: :kalibro_configurations, action: :show, id: "1") }  
13 - it { is_expected.to route(:get, '/kalibro_configurations/1/edit').  
14 - to(controller: :kalibro_configurations, action: :edit, id: "1") }  
15 - it { is_expected.to route(:put, '/kalibro_configurations/1').  
16 - to(controller: :kalibro_configurations, action: :update, id: "1") }  
17 - it { is_expected.to route(:delete, '/kalibro_configurations/1').  
18 - to(controller: :kalibro_configurations, action: :destroy, id: "1") }  
19 - end  
20 -end