-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
12 changed files
with
252 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Place all the behaviors and hooks related to the matching controller here. | ||
# All this logic will automatically be available in application.js. | ||
# You can use CoffeeScript in this file: http://coffeescript.org/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
// Place all the styles related to the hackathons controller here. | ||
// They will automatically be included in application.css. | ||
// You can use Sass (SCSS) here: http://sass-lang.com/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
class HackathonsController < ApplicationController | ||
include HackathonsHelper | ||
|
||
before_action :authenticate_user!, except: [ :show ] | ||
|
||
def create | ||
render :success | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
module HackathonsHelper | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
require "test_helper" | ||
require "sidekiq/testing" | ||
|
||
class HackathonsControllerTest < ActionController::TestCase | ||
setup do | ||
Sidekiq::Testing.fake! | ||
@user = FactoryGirl.create(:user, github_handle: "dummy") | ||
sign_in(@user) | ||
end | ||
|
||
teardown do | ||
sign_out(@user) | ||
end | ||
|
||
def create_hackathon | ||
#assert_difference 'Hackathon.count' do | ||
post :create, { name: "My Hack Day", | ||
from: Date.today.beginning_of_day, | ||
end: (Date.today + 2.days).end_of_day | ||
}, xhr: true | ||
#end | ||
assert_response :success | ||
assert_select ".repositories form" | ||
assert_select ".members form" | ||
end | ||
|
||
test "create a hackathon" do | ||
create_hackathon | ||
|
||
round = Round.where(name: "My Hack Day").first | ||
group = Group.where(name: "My Hack Day").first | ||
|
||
assert_includes @user.round, round | ||
assert_equal group.owner, @user | ||
end | ||
|
||
test "create a hackathon with specific respositories" do | ||
create_hackathon | ||
|
||
assert_difference 'Hackathon.last.repositories.count', 2 do | ||
post repositories_hackathon_url(id: Hackathon.last), { | ||
repositories: { "0": { name: 'dummy_repos_url' }, | ||
"1": { name: "dummy_repos_2_url" } | ||
} | ||
}, xhr: true | ||
end | ||
assert_response :success | ||
assert_select "#repositories tr", 2 # there should be 2 repositories in the list | ||
end | ||
|
||
test "add member to hackathon if member registered with CodeCuriosity" do | ||
create_hackathon | ||
|
||
# create a dummy user! | ||
FactoryGirl.create(:user, github_handle: "dummy", email: "[email protected]") | ||
|
||
assert_difference 'Hackathon.last.group.members.count', 1 do | ||
post join_hackathon(id: Hackathon.last), { | ||
"user_id": "dummy" | ||
}, xhr: true | ||
end | ||
assert_response :success | ||
assert_select "#group-members tr", 2 # owner and new member | ||
end | ||
|
||
test "flash notice if github handle not registered with CodeCuriosity" do | ||
create_hackathon | ||
|
||
assert_no_difference 'Hackathon.last.group.members.count' do | ||
post join_hackathon(id: Hackathon.last), { | ||
"user_id": "dummy" | ||
}, xhr: true | ||
end | ||
assert_response :success | ||
assert_equal "No such user. Invite using email", flash[:notice] | ||
end | ||
|
||
test "invite member to hackathon if email not exist and is not registered with CodeCuriosity" do | ||
create_hackathon | ||
|
||
assert_no_difference 'Hackathon.last.group.members.count' do | ||
post join_hackathon(id: Hackathon.last), { | ||
"user_id": "[email protected]" | ||
}, xhr: true | ||
end | ||
assert_response :success | ||
# test if email was sent to [email protected] | ||
end | ||
|
||
test "show hackathon widget" do | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,8 @@ | ||
FactoryGirl.define do | ||
factory :commit do | ||
commit_date { Faker::Time.between(DateTime.now - 1.hour, DateTime.now)} | ||
message {Faker::Lorem.paragraph} | ||
association :user | ||
association :repository | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
require "test_helper" | ||
|
||
class HackathonsHelperTest < ActionView::TestCase | ||
def test_sanity | ||
flunk "Need real tests" | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters