Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ group :development, :test do
gem 'dotenv-rails'
gem 'vcr'
gem 'fakeweb'
gem 'faker'
end

group :test do
Expand Down
3 changes: 3 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ GEM
factory_girl_rails (4.5.0)
factory_girl (~> 4.5.0)
railties (>= 3.0.0)
faker (1.4.3)
i18n (~> 0.5)
fakeweb (1.3.0)
faraday (0.8.7)
multipart-post (~> 1.1)
Expand Down Expand Up @@ -271,6 +273,7 @@ DEPENDENCIES
devise (~> 3.3.0)
dotenv-rails
factory_girl_rails
faker
fakeweb
friendly_id (~> 4.0.10)
geocoder
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
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 }

Choose a reason for hiding this comment

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

Unnecessary spacing detected.

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
22 changes: 22 additions & 0 deletions spec/models/event_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,26 @@
describe Event do
it { should have_many(:featured_projects) }
it { should have_many(:projects).through(:featured_projects) }
it { should have_many(:event_registrations) }
it { should have_many(:sponsors).through(:sponsorships) }
it { should have_many(:sponsorships) }
it { should have_many(:users).through(:event_registrations) }

before(:each) do
@event1 = create(:cm_event, :end_tomorrow, :public)
@event2 = create(:cm_event, :end_today)
@event3 = create(:cm_event, :future)
end

describe "upcoming event scope" do
it "should return only upcoming events" do
expect(Event.upcoming_events).to eq([@event1, @event3])
end
end

describe "featured events" do
it "should return only one upcoming event sorted by starting date" do
expect(Event.featured).to eq(@event1)
end
end
end
6 changes: 6 additions & 0 deletions spec/models/favorite_project_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
require "spec_helper"

describe FavoriteProject do
it { should belong_to(:project) }
it { should belong_to(:user) }
end
Loading