Sha256: 4f630322658669bd057b174487b2365efbdaff00bc90b1770449de92aa600438

Contents?: true

Size: 1.14 KB

Versions: 17

Compression:

Stored size: 1.14 KB

Contents

require 'spec_helper'

describe CassandraObject::Associations do
  context "belongs_to" do
    it "should fetch the user record from the belongs_to relationship from a cassandra object" do
      user = User.create! :position => 1
      issue = Issue.create! :description => 'web site not working', :worth => 1.5, :user_id => user.id
      expect(issue.user.id).to eq user.id
    end

    it "should fetch the cassandra object from the belongs_to relationship from an active record object" do
      issue = Issue.create! :description => 'web site not working', :worth => 1.5
      user = User.create! :position => 1, :issue_id => issue.id
      role = Role.create! :name => 'admin', :user_id => user.id

      expect(role.user.id).to eq user.id
      expect(user.issue.id).to eq issue.id
    end

    it "should set the foreign key attribute when assigned through the belongs_to relationship" do
      issue = Issue.create! :description => 'web site not working', :worth => 1.5
      user = User.create! :position => 1, :issue => issue
      expect(user.issue_id).to eq issue.id

      user.issue = issue
      expect(user.issue_id).to eq issue.id
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
sessionm-cassandra_object-4.0.32 spec/cassandra_object/associations_spec.rb
sessionm-cassandra_object-4.0.31 spec/cassandra_object/associations_spec.rb
sessionm-cassandra_object-4.0.30 spec/cassandra_object/associations_spec.rb
sessionm-cassandra_object-4.0.29 spec/cassandra_object/associations_spec.rb
sessionm-cassandra_object-4.0.28 spec/cassandra_object/associations_spec.rb
sessionm-cassandra_object-4.0.27 spec/cassandra_object/associations_spec.rb
sessionm-cassandra_object-4.0.26 spec/cassandra_object/associations_spec.rb
sessionm-cassandra_object-4.0.25 spec/cassandra_object/associations_spec.rb
sessionm-cassandra_object-4.0.24 spec/cassandra_object/associations_spec.rb
sessionm-cassandra_object-4.0.23 spec/cassandra_object/associations_spec.rb
sessionm-cassandra_object-4.0.22 spec/cassandra_object/associations_spec.rb
sessionm-cassandra_object-4.0.21 spec/cassandra_object/associations_spec.rb
sessionm-cassandra_object-4.0.20 spec/cassandra_object/associations_spec.rb
sessionm-cassandra_object-4.0.18 spec/cassandra_object/associations_spec.rb
sessionm-cassandra_object-4.0.17 spec/cassandra_object/associations_spec.rb
sessionm-cassandra_object-4.0.16 spec/cassandra_object/associations_spec.rb
sessionm-cassandra_object-4.0.15 spec/cassandra_object/associations_spec.rb