From 6b4941ae8839a2ded6280649a12f760e22be3851 Mon Sep 17 00:00:00 2001 From: Ivan Date: Thu, 26 Feb 2015 20:32:44 -0800 Subject: [PATCH 1/8] Add validation to Github name validation Remove conditional in the model validation. --- app/models/organization.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/organization.rb b/app/models/organization.rb index 72891fcb..21804109 100644 --- a/app/models/organization.rb +++ b/app/models/organization.rb @@ -13,7 +13,7 @@ class Organization < ActiveRecord::Base attr_accessor :is_public_submission validates_presence_of :name - validates_presence_of :github_org, if: :is_public_submission + validates_presence_of :github_org # Paperclip has_attached_file :logo, styles: { thumb: '100x100>', medium: '250x250>' }, From 0bc48ded3c0e602b12529641a45e8b924a0a3abc Mon Sep 17 00:00:00 2001 From: Ivan Date: Mon, 2 Mar 2015 13:43:11 -0800 Subject: [PATCH 2/8] Modify the organization model and organization rspec test --- app/models/organization.rb | 4 ++-- spec/models/organization_spec.rb | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/models/organization.rb b/app/models/organization.rb index 21804109..0aaf940c 100644 --- a/app/models/organization.rb +++ b/app/models/organization.rb @@ -12,8 +12,8 @@ class Organization < ActiveRecord::Base attr_writer :logo_delete attr_accessor :is_public_submission - validates_presence_of :name - validates_presence_of :github_org + validates :name, presence: true + validates :github_org, presence: true # Paperclip has_attached_file :logo, styles: { thumb: '100x100>', medium: '250x250>' }, diff --git a/spec/models/organization_spec.rb b/spec/models/organization_spec.rb index 82f71a05..1d275ebb 100644 --- a/spec/models/organization_spec.rb +++ b/spec/models/organization_spec.rb @@ -13,11 +13,11 @@ context 'if not public submission' do before { subject.stub(:is_public_submission) { false } } - it { should_not validate_presence_of(:github_org) } + it { should validate_presence_of(:github_org) } end context 'if not public submission, implicit' do - it { should_not validate_presence_of(:github_org) } + it { should validate_presence_of(:github_org) } end end From 59591b992c32a6400f150b197b492cdc8140313e Mon Sep 17 00:00:00 2001 From: Ivan Date: Mon, 2 Mar 2015 14:03:42 -0800 Subject: [PATCH 3/8] Changed the project spec so it includes the required github org --- spec/models/project_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/models/project_spec.rb b/spec/models/project_spec.rb index a17254ef..dd010f10 100644 --- a/spec/models/project_spec.rb +++ b/spec/models/project_spec.rb @@ -83,7 +83,7 @@ end describe '#related_projects' do - let(:organization) { Organization.create!(name: 'CodeMontage') } + let(:organization) { Organization.create!(name: 'CodeMontage', github_org: 'codeMontage') } before do @project_1 = Project.create!(name: 'Code Montage', organization_id: organization.id, github_repo: 'codemontage') From e12af54a8bf46e1ef2f791e29c2fa68a8e9aa15a Mon Sep 17 00:00:00 2001 From: Ivan Date: Mon, 2 Mar 2015 15:31:25 -0800 Subject: [PATCH 4/8] Modify spec to appease houndci requirements --- spec/models/project_spec.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/spec/models/project_spec.rb b/spec/models/project_spec.rb index dd010f10..848fb126 100644 --- a/spec/models/project_spec.rb +++ b/spec/models/project_spec.rb @@ -83,7 +83,8 @@ end describe '#related_projects' do - let(:organization) { Organization.create!(name: 'CodeMontage', github_org: 'codeMontage') } + let(:organization) { Organization.create!(name: 'CodeMontage', + github_org: 'codeMontage') } before do @project_1 = Project.create!(name: 'Code Montage', organization_id: organization.id, github_repo: 'codemontage') From 712e33de7554e67c0232272e619195f8383dee12 Mon Sep 17 00:00:00 2001 From: Ivan Date: Mon, 2 Mar 2015 15:42:45 -0800 Subject: [PATCH 5/8] Modify spec per houndci --- spec/models/project_spec.rb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/spec/models/project_spec.rb b/spec/models/project_spec.rb index 848fb126..0e3f12e0 100644 --- a/spec/models/project_spec.rb +++ b/spec/models/project_spec.rb @@ -83,8 +83,7 @@ end describe '#related_projects' do - let(:organization) { Organization.create!(name: 'CodeMontage', - github_org: 'codeMontage') } + let(:organization) { Organization.create!(name: "CodeMontage", github_org: "codeMontage") } before do @project_1 = Project.create!(name: 'Code Montage', organization_id: organization.id, github_repo: 'codemontage') From 5a63b2691be111eaed7f9eb6a80c132d5e465afb Mon Sep 17 00:00:00 2001 From: Ivan Date: Mon, 9 Mar 2015 10:52:29 -0700 Subject: [PATCH 6/8] Modify the organization mvc to use client side validation for org_github_name --- app/controllers/organizations_controller.rb | 1 + app/models/organization.rb | 2 +- app/views/organizations/new.html.erb | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/app/controllers/organizations_controller.rb b/app/controllers/organizations_controller.rb index 26313edc..6b9f2832 100644 --- a/app/controllers/organizations_controller.rb +++ b/app/controllers/organizations_controller.rb @@ -1,6 +1,7 @@ class OrganizationsController < ApplicationController def new @organization = Organization.new + @organization.is_public_submission = current_user.is_admin unless current_user.nil? @project = @organization.projects.build(params[:projects]) end diff --git a/app/models/organization.rb b/app/models/organization.rb index 0aaf940c..137838fd 100644 --- a/app/models/organization.rb +++ b/app/models/organization.rb @@ -13,7 +13,7 @@ class Organization < ActiveRecord::Base attr_accessor :is_public_submission validates :name, presence: true - validates :github_org, presence: true + validates :github_org, presence: true, unless: :is_public_submission # Paperclip has_attached_file :logo, styles: { thumb: '100x100>', medium: '250x250>' }, diff --git a/app/views/organizations/new.html.erb b/app/views/organizations/new.html.erb index 6c19fa01..ca34a340 100644 --- a/app/views/organizations/new.html.erb +++ b/app/views/organizations/new.html.erb @@ -15,7 +15,7 @@ <%= f.input :name, :label => 'Organization Name', error_html: { class: "error" } %>
- <%= f.input :github_org, :label => 'Organization GitHub Username', :required => true, wrapper_html: { class: 'large-6 columns'}, error_html: { class: "error"} %> + <%= f.input :github_org, validate: true, :label => 'Organization GitHub Username', :required => true, wrapper_html: { class: 'large-6 columns'}, error_html: { class: "error"} %> <%= f.input :url, :label => 'Organization Website', :required => false, :as => :url, wrapper_html: { class: 'large-6 columns'} %>
From b3a58d1afd1e1aa27390be930e98ed1e4962ce4c Mon Sep 17 00:00:00 2001 From: Ivan Date: Mon, 9 Mar 2015 11:08:51 -0700 Subject: [PATCH 7/8] Modify spec so it validates both public and admin submissions and split code line for hound --- app/controllers/organizations_controller.rb | 3 ++- spec/models/organization_spec.rb | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/app/controllers/organizations_controller.rb b/app/controllers/organizations_controller.rb index 6b9f2832..cf36d8f4 100644 --- a/app/controllers/organizations_controller.rb +++ b/app/controllers/organizations_controller.rb @@ -1,7 +1,8 @@ class OrganizationsController < ApplicationController def new @organization = Organization.new - @organization.is_public_submission = current_user.is_admin unless current_user.nil? + @organization.is_public_submission = + current_user.is_admin unless current_user.nil? @project = @organization.projects.build(params[:projects]) end diff --git a/spec/models/organization_spec.rb b/spec/models/organization_spec.rb index 1d275ebb..7cd8538f 100644 --- a/spec/models/organization_spec.rb +++ b/spec/models/organization_spec.rb @@ -8,7 +8,7 @@ context 'validations' do context 'if public submission' do before { subject.stub(:is_public_submission) { true } } - it { should validate_presence_of(:github_org) } + it { should_not validate_presence_of(:github_org) } end context 'if not public submission' do From 954d67739b170cb264fed9091967bf124b8d424b Mon Sep 17 00:00:00 2001 From: Ivan Date: Mon, 9 Mar 2015 11:10:45 -0700 Subject: [PATCH 8/8] undid the line break since hound is clomplaining of trailing white space --- app/controllers/organizations_controller.rb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/app/controllers/organizations_controller.rb b/app/controllers/organizations_controller.rb index cf36d8f4..6b9f2832 100644 --- a/app/controllers/organizations_controller.rb +++ b/app/controllers/organizations_controller.rb @@ -1,8 +1,7 @@ class OrganizationsController < ApplicationController def new @organization = Organization.new - @organization.is_public_submission = - current_user.is_admin unless current_user.nil? + @organization.is_public_submission = current_user.is_admin unless current_user.nil? @project = @organization.projects.build(params[:projects]) end