Sha256: 2deae50b8a3d9c78f24825f30ed80f066b0b96b32deb8991f4b28e3b7145c5f3

Contents?: true

Size: 1.46 KB

Versions: 6

Compression:

Stored size: 1.46 KB

Contents

require 'spec_helper'

module Cellect::Server
  describe API do
    include_context 'API'
    
    { 'Ungrouped' => nil, 'Grouped' => 'grouped' }.each_pair do |grouping_type, grouping|
      SET_TYPES.shuffle.each do |set_type|
        context "#{ grouping_type } #{ set_type }" do
          let(:workflow_type){ [grouping, set_type].compact.join '_' }
          let(:workflow){ Workflow[workflow_type] }
          let(:user){ workflow.user 123 }
          before(:each){ pass_until workflow, is: :ready }
          
          let(:opts) do
            { subject_id: 123 }.tap do |h|
              h[:priority] = 456.0 if workflow.prioritized?
              h[:group_id] = 1 if workflow.grouped?
            end
          end
          
          it 'should add subjects' do
            if workflow.grouped? && workflow.prioritized?
              workflow.should_receive(:add).with subject_id: 123, group_id: 1, priority: 456.0
            elsif workflow.grouped?
              workflow.should_receive(:add).with subject_id: 123, group_id: 1, priority: nil
            elsif workflow.prioritized?
              workflow.should_receive(:add).with subject_id: 123, group_id: nil, priority: 456.0
            else
              workflow.should_receive(:add).with subject_id: 123, group_id: nil, priority: nil
            end
            
            put "/workflows/#{ workflow_type }/add", opts
            last_response.status.should == 200
          end
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
cellect-server-0.0.7 spec/server/api/add_spec.rb
cellect-server-0.0.6 spec/server/api/add_spec.rb
cellect-server-0.0.5 spec/server/api/add_spec.rb
cellect-server-0.0.4 spec/server/api/add_spec.rb
cellect-server-0.0.3 spec/server/api/add_spec.rb
cellect-server-0.0.2 spec/server/api/add_spec.rb