Commit 57b1db470ad66a3724e9adb3507748ec8d4e249a
Exists in
colab
and in
4 other branches
Merge pull request #237 from mezuro/attributes_validations
Added validations for both Project and KalibroConfiguration Attributes
Showing
9 changed files
with
26 additions
and
8 deletions
Show diff stats
app/models/kalibro_configuration_attributes.rb
app/models/project_attributes.rb
features/project/show.feature
| ... | ... | @@ -27,14 +27,16 @@ Scenario: Should show the create repository link the project owner |
| 27 | 27 | |
| 28 | 28 | @kalibro_processor_restart |
| 29 | 29 | Scenario: Considering the project has no repositories |
| 30 | - Given I have a sample project | |
| 30 | + Given I am a regular user | |
| 31 | + And I have a sample project | |
| 31 | 32 | And I have sample project_attributes |
| 32 | 33 | When I am at the Sample Project page |
| 33 | 34 | Then I should see "There are no Repositories yet!" |
| 34 | 35 | |
| 35 | 36 | @kalibro_configuration_restart @kalibro_processor_restart |
| 36 | 37 | Scenario: Considering the project has repositories |
| 37 | - Given I have a sample project | |
| 38 | + Given I am a regular user | |
| 39 | + And I have a sample project | |
| 38 | 40 | And I have a sample configuration with native metrics |
| 39 | 41 | And I have a sample repository within the sample project |
| 40 | 42 | When I am at the Sample Project page |
| ... | ... | @@ -42,7 +44,8 @@ Scenario: Considering the project has repositories |
| 42 | 44 | |
| 43 | 45 | @kalibro_processor_restart |
| 44 | 46 | Scenario: Checking project contents |
| 45 | - Given I have a sample project | |
| 47 | + Given I am a regular user | |
| 48 | + And I have a sample project | |
| 46 | 49 | And I have sample project_attributes |
| 47 | 50 | When I am at the Sample Project page |
| 48 | 51 | Then the sample project should be there | ... | ... |
features/repository/show/date_select.feature
| ... | ... | @@ -5,7 +5,8 @@ Feature: Date Select |
| 5 | 5 | |
| 6 | 6 | @kalibro_configuration_restart @kalibro_processor_restart @javascript |
| 7 | 7 | Scenario: With a specific date selected |
| 8 | - Given I have a sample project | |
| 8 | + Given I am a regular user | |
| 9 | + And I have a sample project | |
| 9 | 10 | And I have a sample configuration with native metrics |
| 10 | 11 | And I have a sample repository within the sample project |
| 11 | 12 | And I start to process that repository | ... | ... |
features/repository/show/repository_info.feature
| ... | ... | @@ -5,7 +5,8 @@ Feature: Show Repository |
| 5 | 5 | |
| 6 | 6 | @kalibro_configuration_restart @kalibro_processor_restart @javascript |
| 7 | 7 | Scenario: Testing the repository values |
| 8 | - Given I have a sample project | |
| 8 | + Given I am a regular user | |
| 9 | + And I have a sample project | |
| 9 | 10 | And I have a sample configuration with native metrics |
| 10 | 11 | And I have a sample repository within the sample project |
| 11 | 12 | And I start to process that repository | ... | ... |
features/step_definitions/project_steps.rb
| ... | ... | @@ -9,7 +9,7 @@ Given(/^I have a sample project$/) do |
| 9 | 9 | end |
| 10 | 10 | |
| 11 | 11 | Given(/^I have sample project_attributes$/) do |
| 12 | - @project_attributes = FactoryGirl.create(:project_attributes, {id: nil}) | |
| 12 | + @project_attributes = FactoryGirl.create(:project_attributes, {id: nil, user_id: @user.id}) | |
| 13 | 13 | end |
| 14 | 14 | |
| 15 | 15 | Given(/^I have a project named "(.*?)"$/) do |name| | ... | ... |
features/step_definitions/repository_steps.rb
| ... | ... | @@ -13,7 +13,7 @@ Given(/^I have a sample configuration with native metrics$/) do |
| 13 | 13 | reading = FactoryGirl.create(:reading, {reading_group_id: reading_group.id}) |
| 14 | 14 | |
| 15 | 15 | @kalibro_configuration = FactoryGirl.create(:kalibro_configuration) |
| 16 | - FactoryGirl.create(:kalibro_configuration_attributes, {id: nil, user_id: nil, kalibro_configuration_id: @kalibro_configuration.id}) | |
| 16 | + FactoryGirl.create(:kalibro_configuration_attributes, {id: nil, user_id: @user.id, kalibro_configuration_id: @kalibro_configuration.id}) | |
| 17 | 17 | |
| 18 | 18 | metric_configuration = FactoryGirl.create(:metric_configuration, |
| 19 | 19 | {metric: FactoryGirl.build(:loc), | ... | ... |
spec/models/kalibro_configuration_attributes_spec.rb
| 1 | 1 | require 'rails_helper' |
| 2 | 2 | |
| 3 | 3 | describe KalibroConfigurationAttributes, :type => :model do |
| 4 | + describe 'validations' do | |
| 5 | + it { is_expected.to validate_presence_of(:kalibro_configuration_id) } | |
| 6 | + it { is_expected.to validate_presence_of(:user) } | |
| 7 | + end | |
| 8 | + | |
| 4 | 9 | describe 'associations' do |
| 5 | 10 | it { is_expected.to belong_to(:user) } |
| 6 | 11 | end | ... | ... |
spec/models/project_attributes_spec.rb
| ... | ... | @@ -5,6 +5,11 @@ RSpec.describe ProjectAttributes, type: :model do |
| 5 | 5 | it { is_expected.to belong_to(:user) } |
| 6 | 6 | end |
| 7 | 7 | |
| 8 | + describe 'validations' do | |
| 9 | + it { is_expected.to validate_presence_of(:project_id) } | |
| 10 | + it { is_expected.to validate_presence_of(:user) } | |
| 11 | + end | |
| 12 | + | |
| 8 | 13 | describe 'methods' do |
| 9 | 14 | describe 'project' do |
| 10 | 15 | subject { FactoryGirl.build(:project_attributes) } | ... | ... |