Skip to content

Commit

Permalink
refs joshsoftware#88 Factories added and pending test-cases
Browse files Browse the repository at this point in the history
WIP - added basic functionality test-cases.
  • Loading branch information
gautamrege authored and BandanaPandey committed Aug 24, 2016
1 parent 42eeaac commit 123afb9
Show file tree
Hide file tree
Showing 4 changed files with 130 additions and 0 deletions.
5 changes: 5 additions & 0 deletions app/models/hackathon.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class Hackathon < Subscription
field :update_interval, type: Integer, default: 15

belongs_to :group
end
23 changes: 23 additions & 0 deletions test/factories/hackathons.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
FactoryGirl.define do
factory :hackathon do
update_interval 15

group
association :round, :hackathon, status: "inactive"

after(:create) do |hackathon, evaluator|
hackathon.group.owner_id = hackathon.user.id
hackathon.round.name = hackathon.group.name = "#{hackathon.user.name}'s Hackathon"
end

factory :hackathon_with_repositories do
transient do
repos_count 3
end

after(:create) do |hackathon, evaluator|
create_list(:repositories, evaluator.repos_count, hackathon: hackathon)
end
end
end
end
5 changes: 5 additions & 0 deletions test/factories/rounds.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@
end_date {Faker::Time.between(DateTime.now + 29, DateTime.now + 30)}
status {random = ["active","open","inactive"].sample}

trait :hackathon do
from_date { Faker::Time.between(DateTime.now + 1, DateTime.now + 2)}
end_date {Faker::Time.between(DateTime.now + 3, DateTime.now + 5)}
end

factory :round_with_commits do
transient do
commits_count 1
Expand Down
97 changes: 97 additions & 0 deletions test/models/hackathon_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
require "test_helper"
require "sidekiq/testing"

class HackathonTest < ActiveSupport::TestCase

def setup
Sidekiq::Testing.fake!
@hackathon = create(:hackathon, user: create(:user))
end

test "is_valid" do
assert(@hackathon.valid?)
assert(@hackathon.round.valid?)
assert(@hackathon.group.valid?)
end

test "does_not_create_any_goal" do
end

test "has_valid_hackathon_group" do
end

test "is_valid_if_there_is_only_group_admin_and_no_members_in_the_hackathon_group" do
end

test "has_valid_hackathon_round" do
end

test "hackathon_round_has_initial_state_as_inactive" do
end

test "sidekiq_job_should_be_enqueued_to_open_hackathon_round_at_start_datetime" do
end

test "update_interval_can_be_updated_if_hackathon_round_is_inactive" do
end

test "update_interval_cannot_be_updated_if_hackathon_round_is_open" do
end

test "update_interval_cannot_be_updated_if_hackathon_round_is_closed" do
end

test "is_valid_if_repositories_array_is_blank" do
end

test "is_valid_if_repositories_array_has_valid_repository_ids" do
end

test "repositories_should_not_reference_hackathon" do#check inverse_of: nil
end

# Need to add test cases to add repositories.
test "points_is_updated_if_round_spans_different_months" do # eg. Hackathon is from 30-Mar till 2-Apr
end

test "points_is_updated_for_commits_and_activity_only_for_hackathon_repositories" do
end

test "points_is_updated_for_all_commits_and_activity_if_hackathon_repositories_is_blank" do
end

test "points_is_updated_only_for_commits_and_activity_between_start_and_end_of_hackathon_round" do
end

test "points_is_not_calculated_when_the_hackathon_round_is_inactive" do
end

test "points_updation_does_not_create_any_transactions" do
end

test "sidekiq_job_should_be_enqueued_for_next_fetch_data_after_udpate_interval" do
end

test "new_member_can_be_added_to_hackathon_group_if_hackathon_round_is_open" do
end

test "new_member_points_is_calculated_from_round_start_datetime_if_hackathon_round_is_open" do
end

test "existing_member_points_is_updated_from_last_interval_time_if_hackathon_round_is_open" do
end

test "widget_shows_points_of_members_with_non_zero_points_only_for_the_hackathon_round" do
end

test "widget_shows_points_of_members_if_hackathon_round_is_closed" do
end

# not sure if we need to check this.
test "hackathon_round_score_is_different_from_user_monthly_subscription_round" do
end

test "hackathon_round_score_is_a_subset_of_user_monthly_subscription_round" do
end

end

0 comments on commit 123afb9

Please sign in to comment.