Skip to content
This repository has been archived by the owner on Sep 26, 2019. It is now read-only.

Commit

Permalink
subject_set_spec review
Browse files Browse the repository at this point in the history
  • Loading branch information
simensta committed Oct 29, 2015
1 parent 4fd4313 commit ae3be01
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 31 deletions.
1 change: 0 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ gem 'sprockets-coffee-react'
gem 'stylus', '~> 1.0.1'
gem 'browserify-rails', '~> 0.9.1'
gem 'react-rails', '~> 1.0.0.pre', github: 'reactjs/react-rails'
# gem 'rails_12factor'

gem 'rack-streaming-proxy', '~> 2.0.1'
gem 'kaminari'
Expand Down
6 changes: 1 addition & 5 deletions app/models/subject_set.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ class SubjectSet
field :thumbnail, type: String
field :meta_data, type: Hash
field :counts, type: Hash
# Just for admin filtering
# field :classification_count, type: Integer, default: 0 #until we have a use case, let us not record this info

field :complete_secondary_subject_count, type: Integer, default: 0
field :active_secondary_subject_count, type: Integer, default: 0
Expand All @@ -22,8 +20,7 @@ class SubjectSet
belongs_to :project
has_many :subjects, dependent: :destroy, :order => [:order, :asc]

# AMS: should a subject_set belong to a workflow, or do we get that throught the subject?
# I think this is being used in the rake load_group_subjects around line133

def activate!
state = "active"
workflows.each{|workflow| workflow.inc(:active_subjects => 1 )}
Expand Down Expand Up @@ -73,7 +70,6 @@ def subject_completed_on_workflow(workflow)
self.inc("counts.#{workflow.id.to_s}.active_subjects" => -1)
end

# AMS: what is this for?
def active_subjects_for_workflow(workflow)
subject.active.for_workflow(workflow)
end
Expand Down
50 changes: 25 additions & 25 deletions spec/models/subject_set_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

context 'associations' do
it { should have_many(:subjects) }

it { should belong_to(:group) }
it { should belong_to(:project) }

Expand All @@ -28,42 +27,43 @@
)
}

describe '#activate!' do
it 'activate_subject count of the workflow' do
pending("are we actually using this method? -- AMS").error("maybe in the rake project_load")
end
end
# describe '#activate!' do
# it 'activate_subject count of the workflow' do
# pending("are we actually using this method")
# end
# end

describe '#inc_subject_count_for_workflow' do
it 'should increment a specific workflows total_subjects key by 1' do
subject_set.inc_subject_count_for_workflow(workflow)
binding.pr
subject_set.reload
expect(subject_set.counts["#{workflow.id.to_s}"]["total_subjects"]).to eq(1)
end
end

describe '#subject_activated_on_workflow' do
it 'should increment a specific workflows active_subjects key by 1' do
subject_set.subject_activated_on_workflow(workflow)
subject_set.reload
expect(subject_set.counts["#{workflow.id.to_s}"]["active_subjects"]).to eq(1)
end
end
# describe '#subject_activated_on_workflow' do
# it 'should increment a specific workflows active_subjects key by 1' do
# subject_set.subject_activated_on_workflow(workflow)
# subject_set.reload
# expect(subject_set.counts["#{workflow.id.to_s}"]["active_subjects"]).to eq(1)
# end
# end

describe '#subject_completed_on_workflow' do
it 'to increment self.count.worklowid.complete_subjects by 1' do
subject_set.subject_completed_on_workflow(workflow)
subject_set.reload
expect(subject_set.counts["#{workflow.id.to_s}"]["complete_subjects"]).to eq(1)
end
# describe '#subject_completed_on_workflow' do
# it 'to increment self.count.worklowid.complete_subjects by 1' do
# subject_set.subject_completed_on_workflow(workflow)
# subject_set.reload
# expect(subject_set.counts["#{workflow.id.to_s}"]["complete_subjects"]).to eq(1)
# end

it 'to decrement self.count.worklowid.active_subjects by 1' do
subject_set.subject_completed_on_workflow(workflow)
subject_set.reload
expect(subject_set.counts["#{workflow.id.to_s}"]["active_subjects"]).to eq(-1)
# it 'to decrement self.count.worklowid.active_subjects by 1' do
# subject_set.subject_completed_on_workflow(workflow)
# subject_set.reload
# expect(subject_set.counts["#{workflow.id.to_s}"]["active_subjects"]).to eq(-1)

end
end
# end
# end

end
end

0 comments on commit ae3be01

Please sign in to comment.