     {:ok, member} = Repo.insert(changeset)
 
     if params[:door_group] do
-      changeset = DoorGroupMember.changeset(%DoorGroupMember{}, member_id: member.id, door_group_id: params.door_group.id)
+      changeset = DoorGroupMember.changeset(%DoorGroupMember{}, %{member_id: member.id, door_group_id: params.door_group.id})
       Repo.insert(changeset)
     end
 

    door = create_door door_group: door_group
    member = create_member company: company, door_group: door_group
    rfid_token = create_rfid_token member: member
    assert RfidToken.access_permitted?("abcd1234", door.id)
  end

  test "checking that the door should not be allowed to open if the token is inactive" do
    company = create_company
    member = create_member company: company
    rfid_token = create_rfid_token member: member, active: false
    refute RfidToken.access_permitted?("abcd1234")
  end

  test "the door should not be allowed to open if the member is inactive" do
    company = create_company
    member = create_member company: company, active: false
    rfid_token = create_rfid_token member: member
    refute RfidToken.access_permitted?("abcd1234")
  end

  test "the door should not be allowed to open if the company departed" do
    {:ok, departure} = Ecto.DateTime.cast("2015-04-30 00:00:00")
    company = create_company departure_date: departure
    member = create_member company: company
    rfid_token = create_rfid_token member: member
    refute RfidToken.access_permitted?("abcd1234")
  end

  test "the door should not be allowed to open if the token is not enrolled" do
    refute RfidToken.access_permitted?("abcd1234")
  end
end

    {:ok, door} = Repo.insert(changeset)

    if params[:door_group] do
      changeset = DoorGroupDoor.changeset(%DoorGroupDoor{}, %{door_id: door.id, door_group_id: params.door_group.id})
      Repo.insert(changeset)
    end

