diff --git a/app/models/hackathon.rb b/app/models/hackathon.rb new file mode 100644 index 00000000..b77a590a --- /dev/null +++ b/app/models/hackathon.rb @@ -0,0 +1,5 @@ +class Hackathon < Subscription + field :update_interval, type: Integer, default: 15 + + belongs_to :group +end diff --git a/test/factories/hackathons.rb b/test/factories/hackathons.rb new file mode 100644 index 00000000..c135c483 --- /dev/null +++ b/test/factories/hackathons.rb @@ -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 diff --git a/test/factories/rounds.rb b/test/factories/rounds.rb index 108e19c1..cc49da96 100644 --- a/test/factories/rounds.rb +++ b/test/factories/rounds.rb @@ -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 diff --git a/test/models/hackathon_test.rb b/test/models/hackathon_test.rb new file mode 100644 index 00000000..8dadf6cd --- /dev/null +++ b/test/models/hackathon_test.rb @@ -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