Skip to content
1 change: 1 addition & 0 deletions app/controllers/organizations_controller.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
class OrganizationsController < ApplicationController
def new
@organization = Organization.new
@organization.is_public_submission = current_user.is_admin unless current_user.nil?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line is too long. [87/80]

@project = @organization.projects.build(params[:projects])
end

Expand Down
4 changes: 2 additions & 2 deletions app/models/organization.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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, if: :is_public_submission
validates :name, presence: true
validates :github_org, presence: true, unless: :is_public_submission

# Paperclip
has_attached_file :logo, styles: { thumb: '100x100>', medium: '250x250>' },
Expand Down
2 changes: 1 addition & 1 deletion app/views/organizations/new.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

<%= f.input :name, :label => 'Organization Name', error_html: { class: "error" } %>
<div class="row">
<%= 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'} %>
</div>
<div class="row">
Expand Down
6 changes: 3 additions & 3 deletions spec/models/organization_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@
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
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

Expand Down
2 changes: 1 addition & 1 deletion spec/models/project_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down