Commit 92674958b0c890cba78eee9115e00f76bd16223a
Exists in
colab
and in
4 other branches
Merge pull request #178 from mezuro/fixing_forms
Removing whitespaces on the beginning and end of some of the fields befo...
Showing
12 changed files
with
76 additions
and
6 deletions
Show diff stats
app/controllers/kalibro_configurations_controller.rb
... | ... | @@ -71,6 +71,7 @@ class KalibroConfigurationsController < ApplicationController |
71 | 71 | |
72 | 72 | # Never trust parameters from the scary internet, only allow the white list through. |
73 | 73 | def kalibro_configuration_params |
74 | + params[:kalibro_configuration][:name].strip! | |
74 | 75 | params[:kalibro_configuration] |
75 | 76 | end |
76 | 77 | ... | ... |
app/controllers/projects_controller.rb
app/controllers/reading_groups_controller.rb
... | ... | @@ -62,6 +62,7 @@ class ReadingGroupsController < ApplicationController |
62 | 62 | |
63 | 63 | # Never trust parameters from the scary internet, only allow the white list through. |
64 | 64 | def reading_group_params |
65 | + params[:reading_group][:name].strip! | |
65 | 66 | params[:reading_group] |
66 | 67 | end |
67 | 68 | ... | ... |
app/controllers/readings_controller.rb
app/controllers/repositories_controller.rb
config/initializers/devise.rb
... | ... | @@ -45,7 +45,7 @@ Devise.setup do |config| |
45 | 45 | # Configure which authentication keys should have whitespace stripped. |
46 | 46 | # These keys will have whitespace before and after removed upon creating or |
47 | 47 | # modifying a user and when used to authenticate or find a user. Default is :email. |
48 | - config.strip_whitespace_keys = [ :email ] | |
48 | + config.strip_whitespace_keys = [ :email, :name ] | |
49 | 49 | |
50 | 50 | # Tell if authentication through request.params is enabled. True by default. |
51 | 51 | # It can be set to an array that will enable params authentication only for the | ... | ... |
features/kalibro_configuration/create.feature
... | ... | @@ -39,3 +39,13 @@ Feature: Configuration Creation |
39 | 39 | And I fill the Description field with "Web Service to collect metrics" |
40 | 40 | When I press the Save button |
41 | 41 | Then I should see "Name can't be blank" |
42 | + | |
43 | + @kalibro_configuration_restart | |
44 | + Scenario: configuration name with whitespaces | |
45 | + Given I am a regular user | |
46 | + And I am signed in | |
47 | + And I have a configuration named "Kalibro Metrics" | |
48 | + And I am at the New Configuration page | |
49 | + And I fill the Name field with " Kalibro Metrics " | |
50 | + When I press the Save button | |
51 | + Then I should see "Name has already been taken" | ... | ... |
features/project/create.feature
... | ... | @@ -45,3 +45,15 @@ Feature: Project Creation |
45 | 45 | And I click the Your projects link |
46 | 46 | When I click the New Project link |
47 | 47 | Then I should see "New Project" |
48 | + | |
49 | + @kalibro_processor_restart | |
50 | + Scenario: Choosing a name with whitespaces on the beginning and end | |
51 | + Given I am a regular user | |
52 | + And I am signed in | |
53 | + And I have a project named "Kalibro Metrics" | |
54 | + And I am at the New Project page | |
55 | + And I fill the Name field with " Kalibro Metrics " | |
56 | + And I fill the Description field with "Web Service to collect metrics" | |
57 | + When I press the Save button | |
58 | + Then I should see "Name has already been taken" | |
59 | + | ... | ... |
features/reading/new.feature
... | ... | @@ -89,3 +89,18 @@ Feature: New reading |
89 | 89 | When I press the Save button |
90 | 90 | Then I should see "Color must be hexadecimal" |
91 | 91 | And I should be at the New Reading page |
92 | + | |
93 | + @kalibro_configuration_restart | |
94 | + Scenario: Label with whitespaces | |
95 | + Given I am a regular user | |
96 | + And I am signed in | |
97 | + And I own a sample reading group | |
98 | + And I have a sample reading within the sample reading group labeled "My Reading" | |
99 | + And I am at the New Reading page | |
100 | + And I fill the Label field with " My Reading " | |
101 | + And I fill the Grade field with "10" | |
102 | + And I fill the Color field with "ffff00" | |
103 | + When I press the Save button | |
104 | + Then I should see "Label Should be unique within a Reading Group" | |
105 | + And I should be at the New Reading page | |
106 | + | ... | ... |
features/reading_group/create.feature
... | ... | @@ -22,7 +22,7 @@ Scenario: Reading Group creation |
22 | 22 | And I should see "Destroy Reading Group" |
23 | 23 | |
24 | 24 | @kalibro_configuration_restart |
25 | -Scenario: reading group creation with already taken name | |
25 | +Scenario: Reading Group creation with already taken name | |
26 | 26 | Given I am a regular user |
27 | 27 | And I am signed in |
28 | 28 | And I have a reading group named "Group" |
... | ... | @@ -33,7 +33,7 @@ Scenario: reading group creation with already taken name |
33 | 33 | Then I should see "Name has already been taken" |
34 | 34 | |
35 | 35 | @kalibro_configuration_restart |
36 | -Scenario: reading group creation with blank name | |
36 | +Scenario: Reading Group creation with blank name | |
37 | 37 | Given I am a regular user |
38 | 38 | And I am signed in |
39 | 39 | And I am at the New Reading Group page |
... | ... | @@ -41,3 +41,14 @@ Scenario: reading group creation with blank name |
41 | 41 | And I fill the Description field with "Anything" |
42 | 42 | When I press the Save button |
43 | 43 | Then I should see "Name can't be blank" |
44 | + | |
45 | +@kalibro_configuration_restart | |
46 | +Scenario: Reading Group name with whitespaces | |
47 | + Given I am a regular user | |
48 | + And I am signed in | |
49 | + And I have a reading group named "Reading Group" | |
50 | + And I am at the New Reading Group page | |
51 | + And I fill the Name field with " Reading Group " | |
52 | + When I press the Save button | |
53 | + Then I should see "Name has already been taken" | |
54 | + | ... | ... |
features/repository/create.feature
... | ... | @@ -54,3 +54,20 @@ Scenario: repository creation with name already taken |
54 | 54 | And I set the select field "repository_kalibro_configuration_id" as "Java" |
55 | 55 | When I press the Save button |
56 | 56 | Then I should see "Name should be unique within project" |
57 | + | |
58 | +@kalibro_configuration_restart @kalibro_processor_restart @javascript | |
59 | +Scenario: Repository name with whitespaces | |
60 | + Given I am a regular user | |
61 | + And I am signed in | |
62 | + And I own a sample project | |
63 | + And I have a sample configuration with native metrics | |
64 | + And I have a sample repository within the sample project named "Kalibro Entities" | |
65 | + And I am at the New Repository page | |
66 | + And I fill the Name field with " Kalibro Entities " | |
67 | + And I set the select field "License" as "ISC License (ISC)" | |
68 | + And I set the select field "Type" as "GIT" | |
69 | + And I fill the Address field with "https://github.com/mezuro/kalibro_gem.git" | |
70 | + And I set the select field "Process Period" as "1 day" | |
71 | + And I set the select field "repository_kalibro_configuration_id" as "Java" | |
72 | + When I press the Save button | |
73 | + Then I should see "Name should be unique within project" | ... | ... |
spec/controllers/repositories_controller_spec.rb
... | ... | @@ -21,7 +21,7 @@ describe RepositoriesController, :type => :controller do |
21 | 21 | it { is_expected.to render_template(:new) } |
22 | 22 | end |
23 | 23 | |
24 | - context "when the current user doesn't owns the project" do | |
24 | + context "when the current user doesn't own the project" do | |
25 | 25 | before :each do |
26 | 26 | get :new, project_id: project.id.to_s |
27 | 27 | end |
... | ... | @@ -42,7 +42,7 @@ describe RepositoriesController, :type => :controller do |
42 | 42 | |
43 | 43 | describe 'create' do |
44 | 44 | let (:repository) { FactoryGirl.build(:repository, project_id: project.id) } |
45 | - let(:repository_params) { Hash[FactoryGirl.attributes_for(:repository).map { |k,v| [k.to_s, v.to_s] }] } #FIXME: Mocha is creating the expectations with strings, but FactoryGirl returns everything with symbols and integers | |
45 | + let(:repository_params) { FactoryGirl.build(:repository).to_hash } | |
46 | 46 | |
47 | 47 | before do |
48 | 48 | sign_in FactoryGirl.create(:user) |
... | ... | @@ -76,7 +76,7 @@ describe RepositoriesController, :type => :controller do |
76 | 76 | end |
77 | 77 | end |
78 | 78 | |
79 | - context "when the current user doesn't owns the project " do | |
79 | + context "when the current user doesn't own the project " do | |
80 | 80 | before :each do |
81 | 81 | post :create, project_id: project.id, repository: repository_params |
82 | 82 | end | ... | ... |