Skip to content

Commit

Permalink
fixed some style violation
Browse files Browse the repository at this point in the history
more style fixes

added trait for job, event factories

added traits for project, style fixes, merge fixes

added trait for public event

fixed job factory
  • Loading branch information
Praveen V authored and PraveenVignesh committed Mar 13, 2015
1 parent 50b386a commit 01869f3
Show file tree
Hide file tree
Showing 24 changed files with 209 additions and 207 deletions.
4 changes: 2 additions & 2 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,9 @@ GEM
factory_girl_rails (4.5.0)
factory_girl (~> 4.5.0)
railties (>= 3.0.0)
fakeweb (1.3.0)
faker (1.4.3)
i18n (~> 0.5)
fakeweb (1.3.0)
faraday (0.8.7)
multipart-post (~> 1.1)
fastercsv (1.5.5)
Expand Down Expand Up @@ -273,8 +273,8 @@ DEPENDENCIES
devise (~> 3.3.0)
dotenv-rails
factory_girl_rails
fakeweb
faker
fakeweb
friendly_id (~> 4.0.10)
geocoder
jquery-rails
Expand Down
2 changes: 1 addition & 1 deletion db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -142,11 +142,11 @@
t.datetime "updated_at", :null => false
t.string "image_url"
t.string "twitter", :limit => 15
t.string "slug"
t.string "logo_file_name"
t.string "logo_content_type"
t.integer "logo_file_size"
t.datetime "logo_updated_at"
t.string "slug"
end

add_index "organizations", ["slug"], :name => "index_organizations_on_slug", :unique => true
Expand Down
6 changes: 3 additions & 3 deletions spec/controllers/users_controller_spec.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
require 'spec_helper'
require "spec_helper"

describe UsersController do
describe "GET 'new'" do
it 'returns http success' do
get 'new'
it "returns http success" do
get "new"
response.should be_success
end
end
Expand Down
37 changes: 0 additions & 37 deletions spec/factories.rb

This file was deleted.

24 changes: 24 additions & 0 deletions spec/factories/events.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,28 @@
end_date { Time.new(2014, 10, 31) }
end
end

factory :cm_event, class: Event do
short_code { Faker::Lorem.word }
name Faker::Lorem.word

trait :end_tomorrow do
start_date Time.now
end_date Time.now + 1.day
end

trait :future do
start_date Time.now + 1.day
end_date Time.now + 2.day
end

trait :end_today do
start_date Time.now
end_date Time.now
end

trait :public do
is_public true
end
end
end
13 changes: 13 additions & 0 deletions spec/factories/job.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FactoryGirl.define do
factory :cm_job, class: Job do
title Faker::Lorem.sentence(1)

trait :expire_tomorrow do
expires_at DateTime.now + 1.day
end

trait :expired do
expires_at DateTime.now - 1.day
end
end
end
4 changes: 4 additions & 0 deletions spec/factories/organizations.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,8 @@
name "CodeMontage"
github_org "CodeMontageHQ"
end

factory :cm_organization, class: Organization do
name Faker::Company.name
end
end
13 changes: 13 additions & 0 deletions spec/factories/projects.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,17 @@
name "CodeMontage"
github_repo "codemontage"
end

factory :cm_project, class: Project do
name { Faker::Lorem.word }
github_repo { Faker::Lorem.word }

trait :inactive do
is_active false
end

trait :approved do
is_approved true
end
end
end
5 changes: 5 additions & 0 deletions spec/factories/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,9 @@
create_list(:service, 1, user: user)
end
end

factory :cm_user, class: User do
email { "#{Faker::Internet.user_name}@#{Faker::Internet.domain_name}" }
password Faker::Internet.password
end
end
38 changes: 19 additions & 19 deletions spec/features/pages_spec.rb
Original file line number Diff line number Diff line change
@@ -1,35 +1,35 @@
require 'spec_helper'
require "spec_helper"

describe 'The basic content site', #:js => true,
describe "The basic content site", #:js => true,
type: :feature do
context 'pages' do
it 'displays landing page' do
visit '/'
page.should have_content('Ready to change the world?')
context "pages" do
it "displays landing page" do
visit "/"
page.should have_content("Ready to change the world?")
end

it 'displays projects page' do
visit '/projects'
page.should have_content('Projects')
it "displays projects page" do
visit "/projects"
page.should have_content("Projects")
end

it 'displays jobs page' do
visit '/jobs'
it "displays jobs page" do
visit "/jobs"
page.should have_content("Jobs You've Been Looking For")
end

it 'displays coder day page' do
visit '/coder_day'
page.should have_content('Coder Day of Service')
it "displays coder day page" do
visit "/coder_day"
page.should have_content("Coder Day of Service")
end

it 'displays our story page' do
visit '/our_story'
page.should have_content('Major Contributors')
it "displays our story page" do
visit "/our_story"
page.should have_content("Major Contributors")
end

it 'displays resources page' do
visit '/resources'
it "displays resources page" do
visit "/resources"
page.should have_content("We're not the only ones")
end
end
Expand Down
38 changes: 20 additions & 18 deletions spec/helpers/application_helper_spec.rb
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
require 'spec_helper'
require "spec_helper"

describe ApplicationHelper do
describe '#display_url' do
it 'returns the domain portion of a given url' do
expect(helper.display_url('http://www.foo.com/bar/12')).to eq('www.foo.com/bar/12')
describe "#display_url" do
it "returns the domain portion of a given url" do
expect(helper.display_url("http://www.foo.com/bar/12")).
to eq("www.foo.com/bar/12")
end
end

context 'logo retrieval' do
context "logo retrieval" do
let(:organization) { Organization.new }
let(:logo) { double }

describe '#find_logo' do
describe "#find_logo" do
it "returns an organization's attached logo if it exists" do
organization.stub(:logo) { logo }
logo.should_receive(:url).with(:medium)
Expand All @@ -20,38 +21,39 @@

it "returns an organizations's image_url if no attached logo exists" do
organization.stub(:logo) { nil }
organization.stub(:image_url) { 'foo.png' }
expect(helper.find_logo(organization)).to eq('foo.png')
organization.stub(:image_url) { "foo.png" }
expect(helper.find_logo(organization)).to eq("foo.png")
end
end

describe '#find_logo?' do
it 'returns true if an organization has a logo attachment' do
organization.stub(:logo) { 'something' }
describe "#find_logo?" do
it "returns true if an organization has a logo attachment" do
organization.stub(:logo) { "something" }
organization.stub(:image_url) { nil }
expect(helper.find_logo?(organization)).to be_true
end

it 'returns true if an organization has an image_url defined' do
it "returns true if an organization has an image_url defined" do
organization.stub(:logo) { nil }
organization.stub(:image_url) { 'foo.png' }
organization.stub(:image_url) { "foo.png" }
expect(helper.find_logo?(organization)).to be_true
end

it 'returns false if neither logo nor image_url are present' do
it "returns false if neither logo nor image_url are present" do
organization.stub(:logo) { nil }
organization.stub(:image_url) { nil }
expect(helper.find_logo?(organization)).to be_false
end
end
end

describe '#twitter_url' do
it 'returns twitter url for given non nil handle' do
helper.twitter_url('CodeMontage').should eq('http://twitter.com/CodeMontage')
describe "#twitter_url" do
it "returns twitter url for given non nil handle" do
helper.twitter_url("CodeMontage").
should eq("http://twitter.com/CodeMontage")
end

it 'returns nil when nil is given' do
it "returns nil when nil is given" do
helper.twitter_url(nil).should eq(nil)
end
end
Expand Down
58 changes: 32 additions & 26 deletions spec/helpers/project_controller_helper_spec.rb
Original file line number Diff line number Diff line change
@@ -1,59 +1,65 @@
require 'spec_helper'
require "spec_helper"

describe ProjectControllerHelper do
describe '#code_later_url' do
describe "#code_later_url" do
let(:url) { helper.code_later_url }

before do
Date.stub(:tomorrow) { Date.parse('1971/12/17') }
Date.stub(:tomorrow) { Date.parse("1971/12/17") }
end

it 'returns a url with a start date parameter of tomorrow at 2pm' do
it "returns a url with a start date parameter of tomorrow at 2pm" do
url = helper.code_later_url
expected = '19711217T140000Z'
expected = "19711217T140000Z"
expect(url.include?(expected)).to be_true
end

it 'returns a url with an end date parameter of tomorrow at 6pm' do
it "returns a url with an end date parameter of tomorrow at 6pm" do
url = helper.code_later_url
expected = '19711217T180000Z'
expected = "19711217T180000Z"
expect(url.include?(expected)).to be_true
end
end

describe '#project_tags_link_list' do
describe "#project_tags_link_list" do
let(:project) do
Project.new(
organization_id: 1,
name: 'CodeMontage Platform',
github_repo: 'codemontage'
name: "CodeMontage Platform",
github_repo: "codemontage"
)
end

before do
project.stub(:causes) { [double('Tag', name: 'Cause1'), double('Tag', name: 'Cause2')] }
project.stub(:technologies) { [double('Tag', name: 'Ruby'), double('Tag', name: 'Rails')] }
project.stub(:causes) do
[double("Tag", name: "Cause1"), double("Tag", name: "Cause2")]
end
project.stub(:technologies) do
[double("Tag", name: "Ruby"), double("Tag", name: "Rails")]
end
end

context 'given a technologies argument' do
let(:links_list) { helper.project_tags_link_list(project, 'technologies') }
context "given a technologies argument" do
let(:links_list) do
helper.project_tags_link_list(project, "technologies")
end

it 'returns a list of technology links' do
expect(links_list).to include('Ruby')
expect(links_list).to include('Rails')
expect(links_list).to include(projects_path(tags: 'Ruby'))
expect(links_list).to include(projects_path(tags: 'Rails'))
it "returns a list of technology links" do
expect(links_list).to include("Ruby")
expect(links_list).to include("Rails")
expect(links_list).to include(projects_path(tags: "Ruby"))
expect(links_list).to include(projects_path(tags: "Rails"))
end
end

context 'given a causes argument' do
let(:links_list) { helper.project_tags_link_list(project, 'causes') }
context "given a causes argument" do
let(:links_list) { helper.project_tags_link_list(project, "causes") }

it 'returns a list of cause links' do
expect(links_list).to include('Cause1')
expect(links_list).to include('Cause2')
expect(links_list).to include(projects_path(tags: 'Cause1'))
expect(links_list).to include(projects_path(tags: 'Cause2'))
it "returns a list of cause links" do
expect(links_list).to include("Cause1")
expect(links_list).to include("Cause2")
expect(links_list).to include(projects_path(tags: "Cause1"))
expect(links_list).to include(projects_path(tags: "Cause2"))
end
end
end
Expand Down
Loading

0 comments on commit 01869f3

Please sign in to comment.