Sha256: 7d68191af903866d9a55ba7d17cc6118de2bb802c7251c2e88254a9a7bad7c75

Contents?: true

Size: 1.77 KB

Versions: 9

Compression:

Stored size: 1.77 KB

Contents

require 'spec_helper'

describe 'Syncano::Resource::Collection' do
  before(:all) do
    @project = @client.projects.last || @client.projects.create(name: 'Test project')
  end

  it 'should create a new collection in Syncano' do
    count_before = @project.collections.count

    collection = @project.collections.create(name: 'Test collection', description: 'Just testing')
    collection.id.should_not be_nil

    count_after = @project.collections.count

    (count_after - count_before).should == 1
    @project.collections.last[:name].should == 'Test collection'
  end

  it 'should get all collections' do
    @project.collections.all.each do |collection|
      collection.id.should_not be_nil
      collection[:name].should_not be_nil
    end
  end

  it 'should get a one collection' do
    collection = @project.collections.last
    @project.collections.find(collection.id)[:name].should == collection[:name]
  end

  it 'should activate inactive collection' do
    collection = @project.collections.last

    if collection[:status] == 'active'
      collection.deactivate
      collection.reload!
    end
    collection[:status].should == 'inactive'

    collection.activate
    collection.reload!
    collection['status'].should == 'active'
  end

  it 'should deactivate active collection' do
    collection = @project.collections.last

    if collection[:status] == 'inactive'
      collection.activate
      collection.reload!
    end
    collection[:status].should == 'active'

    collection.deactivate
    collection.reload!
    collection[:status].should == 'inactive'
  end

  it 'should destroy a collection' do
    count_before = @project.collections.count
    @project.collections.last.destroy
    count_after = @project.collections.count

    (count_before - count_after).should == 1
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
syncano-3.1.4 spec/collections_spec.rb
syncano-3.1.3 spec/collections_spec.rb
syncano-3.1.2 spec/collections_spec.rb
syncano-3.1.1 spec/collections_spec.rb
syncano-3.1.1.beta5 spec/collections_spec.rb
syncano-3.1.1.beta4 spec/collections_spec.rb
syncano-3.1.1.beta3 spec/collections_spec.rb
syncano-3.1.1.beta2 spec/collections_spec.rb
syncano-3.1.1.beta spec/collections_spec.rb