Sha256: 1370c06fb3e7764efa54baa64f1e4001a8b1281e03f6536d39fe8e89c45cca2a

Contents?: true

Size: 1.41 KB

Versions: 16

Compression:

Stored size: 1.41 KB

Contents

require 'spec_helper'

describe Revision do

  before :each do
    Fire.reset_tree!
    @params = { branch: 'b', time: '1990-03-21T10:00', user: 'me' }
  end

  it 'should have a collection' do
    expect(Revision.new.collection_name).to eq('Revision')
  end


  it 'should add an object' do
    Revision.add(@params)

    revision = Revision.take(@params)

    expect(revision.time).to be
    expect(revision.branch).to eq(?b)
    expect(revision.user).to eq('me')

    expect(revision.data.keys).to eq([ :branch, :time, :user ])
  end

  it 'should create a thread object' do
    revision = Revision.add(@params)
    revision.add_to_threads(thread_id: 2, status: 'failed')
    expect(revision.threads.count).to eq(1)
  end

  it 'should add a thread object' do
    Revision.add(@params)

    revision = Revision.take(@params)

    revision.add_to_threads(thread_id: 1, status: 'started')
    revision.add_to_threads(thread_id: 2, status: 'failed')

    revision = Revision.take(@params)

    expect(revision.threads.count).to eq(2)
    expect(revision.threads.map(&:thread_id)).to eq([1, 2])
    expect(revision.threads.map(&:status)).to eq(['started', 'failed'])

    revision.add_to_threads(thread_id: 1, status: 'passed')

    revision = Revision.take(@params)

    thread = revision.threads.last

    thread.status = 'perfect'
    thread.save

    expect(Revision.take(@params).threads.map(&:status)).to eq(['passed', 'perfect'])
  end

end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
sw2at-ui-0.0.16 spec/models/revision_spec.rb
sw2at-ui-0.0.15 spec/models/revision_spec.rb
sw2at-ui-0.0.14 spec/models/revision_spec.rb
sw2at-ui-0.0.13 spec/models/revision_spec.rb
sw2at-ui-0.0.12 spec/models/revision_spec.rb
sw2at-ui-0.0.11 spec/models/revision_spec.rb
sw2at-ui-0.0.10 spec/models/revision_spec.rb
sw2at-ui-0.0.9 spec/models/revision_spec.rb
sw2at-ui-0.0.8 spec/models/revision_spec.rb
sw2at-ui-0.0.7 spec/models/revision_spec.rb
sw2at-ui-0.0.6 spec/models/revision_spec.rb
sw2at-ui-0.0.5 spec/models/revision_spec.rb
sw2at-ui-0.0.4 spec/models/revision_spec.rb
sw2at-ui-0.0.3 spec/models/revision_spec.rb
sw2at-ui-0.0.2 spec/models/revision_spec.rb
sw2at-ui-0.0.1 spec/models/revision_spec.rb