Skip to content

Commit

Permalink
Merge 7e8c677 into 6a4fc1a
Browse files Browse the repository at this point in the history
  • Loading branch information
aninditamozumder committed Nov 10, 2015
2 parents 6a4fc1a + 7e8c677 commit 504d863
Show file tree
Hide file tree
Showing 7 changed files with 189 additions and 4 deletions.
5 changes: 3 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ gem 'dynamic_form'
gem 'edavis10-ruby-web-search'
gem 'engtagger'
gem 'expertiza-authlogic', github: 'expertiza/authlogic', :require => 'authlogic'
gem "factory_girl_rails","~> 4.0"
gem 'fastercsv'
gem 'ffi-aspell'
gem 'font-awesome-rails'
Expand Down Expand Up @@ -55,7 +56,7 @@ gem 'uglifier'
gem 'will_paginate'
gem 'zip-zip'
gem 'react-rails', '~> 1.0'

gem 'rspec-rails', '~> 3.0'
group :development do
gem 'daemons'
gem 'pry'
Expand All @@ -72,7 +73,7 @@ group :test do
gem 'guard-rails'
gem 'guard-rspec'
gem 'launchy'
gem 'rspec-rails'
#gem 'rspec-rails'
gem 'shoulda'
gem 'test-unit'
end
Expand Down
8 changes: 7 additions & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,11 @@ GEM
erubis (2.7.0)
eventmachine (1.0.8)
execjs (2.6.0)
factory_girl (4.5.0)
activesupport (>= 3.0.0)
factory_girl_rails (4.5.0)
factory_girl (~> 4.5.0)
railties (>= 3.0.0)
faraday (0.9.1)
multipart-post (>= 1.2, < 3)
fastercsv (1.5.5)
Expand Down Expand Up @@ -423,6 +428,7 @@ DEPENDENCIES
edavis10-ruby-web-search
engtagger
expertiza-authlogic!
factory_girl_rails (~> 4.0)
fastercsv
ffi-aspell
font-awesome-rails
Expand Down Expand Up @@ -458,7 +464,7 @@ DEPENDENCIES
react-rails (~> 1.0)
rgl
rjb
rspec-rails
rspec-rails (~> 3.0)
rubyzip
rwordnet (= 0.1.3)
sass-rails (= 5.0.3)
Expand Down
3 changes: 2 additions & 1 deletion app/models/assignment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ def candidate_topics_to_review(reviewer)
#This method is only for the assignments without topics
def candidate_assignment_teams_to_review(reviewer)
# the contributors are AssignmentTeam objects

contributor_set = Array.new(contributors)

# Reject contributors that have no submissions
Expand Down Expand Up @@ -335,7 +336,7 @@ def contributor_to_review(reviewer, topic)
def contributors
#ACS Contributors are just teams, so removed check to see if it is a team assignment
@contributors ||= teams #ACS
end
end

def assign_metareviewer_dynamically(meta_reviewer)
# The following method raises an exception if not successful which
Expand Down
55 changes: 55 additions & 0 deletions spec/factories.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
require 'factory_girl_rails'

FactoryGirl.define do

#instructor for assignment
factory :user do
sequence(:name) { |n| "NewName #{n}" }
fullname {"test_user"}
email {"sjolly@ncsu.edu"}
parent_id =1
is_new_user=true
end


# Factory for Assignment with name
factory :assignment do
#name {'OSS'}
sequence(:name) { |n| "OS #{n}" }
submitter_count {3}
is_coding_assignment {true}
microtask {true}
review_assignment_strategy {'Auto-Selected'}
association :instructor, factory: :user
association :wiki_type, factory: :wiki_type
end

# Factory for Assignment without name
factory :assignment_without_name, class: Assignment do
name {}
submitter_count {3}
is_coding_assignment {true}
microtask {true}
review_assignment_strategy {'Auto-Selected'}
association :instructor, factory: :user
association :wiki_type, factory: :wiki_type
end

# Factory for wiki type
factory :wiki_type do
name {'wiki_1a'}
end

# Factory for Assignment Team

factory :assignmentTeam, class: AssignmentTeam do

end

factory :signed_up_topic, class: SignUpTopic do
topic_name {'TestApplication'}
topic_identifier {'A1234B1234'}
#association :assignment, factory: :assignment
assignment
end
end
107 changes: 107 additions & 0 deletions spec/models/assignment_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
require 'rails_helper'
require 'spec_helper'

describe "validations" do
it "assignment should exist" do
FactoryGirl.create(:assignment).should be_valid
end

it "assignment without name should not exist" do
FactoryGirl.build(:assignment_without_name).should_not be_valid
end

it "checks whether Assignment Team is created or not" do
FactoryGirl.create(:assignmentTeam).should be_valid
end

it "checks whether signed up topic is created or not" do
FactoryGirl.create(:signed_up_topic).should be_valid
end

end

describe "#team_assignment" do
it "checks team assignment should be true" do
assign = FactoryGirl.create(:assignment)
res = assign.team_assignment
expect(res).to be true
end
end

describe "#has_teams?" do
it "checks assignment should have a team" do
assign = FactoryGirl.build(:assignment)
assign_team = FactoryGirl.create(:assignmentTeam)
assign.teams << assign_team
assign.save!
res = assign.has_teams?
expect(res).to be true
end
end

describe "#has_topics?" do
it "checks assignment should have a topic" do
assign_signed_up_topic = FactoryGirl.create(:signed_up_topic)
assign_topic = FactoryGirl.build(:assignment)
assign_topic.sign_up_topics << assign_signed_up_topic
assign_topic.save!
res = assign_topic.has_topics?
expect(res).to be true
end
end

describe "#is_wiki_assignment" do
it "checks assignment should be a wiki assignment" do
assign = FactoryGirl.create(:assignment)
id = assign.is_wiki_assignment
expect(id).to be true
end
end

describe "#is_google_doc" do
it "checks whether assignment is a google doc" do
assign = FactoryGirl.create(:assignment)
res = assign.is_google_doc
expect(res).to be false
end
end

describe "#is_microtask?" do
it "checks whether assignment is a micro task" do
assign = FactoryGirl.create(:assignment)
id = assign.is_microtask?
expect(id).to be true
end
end

describe "#dynamic_reviewer_assignment?" do
it "checks the Review Strategy Assignment" do
assign = FactoryGirl.create(:assignment)
id = assign.dynamic_reviewer_assignment?
expect(id).to be true
end
end

describe "#is_coding_assignment?" do
it "checks assignment should be coding assignment" do
assign = FactoryGirl.create(:assignment).should be_valid
end
end

describe "#candidate_assignment_teams_to_review" do
it "returns nil if if there are no contributors" do
assign = FactoryGirl.create(:assignment)
reviewer = FactoryGirl.create(:user)
cand_team = assign.candidate_assignment_teams_to_review(reviewer)
expect(cand_team).to be_empty
end

end

describe "#candidate_topics_for_quiz" do
it "returns nil if sign up topic is empty" do
assign = FactoryGirl.create(:assignment)
cand_team = assign.candidate_topics_for_quiz
expect(cand_team).to be_nil
end
end
11 changes: 11 additions & 0 deletions spec/models/team_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
require 'spec_helper'
require 'rails_helper'

describe Team do
it "when team is valid" do
FactoryGirl.build(:team,name: nil).should be_valid
end



end
4 changes: 4 additions & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Record code coverage with coveralls on Travis
require 'factory_girl_rails'
require 'coveralls'
Coveralls.wear! 'rails'

Expand Down Expand Up @@ -27,6 +28,9 @@
#
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
RSpec.configure do |config|
config.include FactoryGirl::Syntax::Methods

#RSpec.configure do |config|
# The settings below are suggested to provide a good initial experience
# with RSpec, but feel free to customize to your heart's content.
=begin
Expand Down

0 comments on commit 504d863

Please sign in to comment.