Add Tony Bowden

Add Tony Bowden

<% @title = "About" %>

Contact Us

If your question isn't answered here, or you just wanted to let us know
something about the site, contact us.

Introduction to WhatDoTheyKnow

What is WhatDoTheyKnow for?

To help you find out inside information about what the UK government
is doing.

How does the site work?

You choose the public authority that you would like information from, then
write a brief note describing what you want to know. We then send your request
to the public authority. Any response they make is automatically published on the
website for you and anyone else to find and read.

Why would I bother to do this?

You pay taxes, and then government does things with the money. All sorts of
things that affect your life, from healthcare through to national defence. Some
it does badly, some it does well. The more we find out about how government
works, the better able we are to make suggestions to improve the things that
are done badly, and to celebrate the things that are done well.

Why would the public authority bother to reply?

Under Freedom of Information (FOI) law, they have to respond.

Who makes it?

WhatDoTheyKnow is made by mySociety,
and was initially funded by the JRSST Charitable Trust. mySociety is a project of the
registered charity UK Citizens Online Democracy.
If you like what we're doing, then you can
make a donation.

Making requests

You're missing the public authority that I want to request from!

Please contact us with the name of the public authority and,
if you can find it, their contact email address for Freedom of Information requests.
If you'd like to help add a whole category of public authority to the site, for example all
primary care trusts or all schools, then please
edit this shared spreadsheet (Google account required).

How quickly will I get a response?

By law public authorities must respond within 20 days, excluding weekends and
any UK bank holidays. The date that the response is due by is shown on the
page for your request. You will be emailed if this date goes by without
a response, so you can send the public authority another note to hurry them up.
Note: If you had to clarify your request, the clock starts from that date,
instead of the date they received your initial request.

What if I'm not satisfied with the response?

If you didn't get the information you asked for, or you didn't get it in time,
then read our page 'Unhappy about the response you got?'.

Can you tell me more of the nitty gritty about the process of making requests?

Have a look at the
access to official information
pages on the Information Commisioner's website.

Can I request information about myself?

Not using this site. Requests made using WhatDoTheyKnow are public, made under the
Freedom of Information Act, and cannot help you find information about a
private individual. If you would like to know what information a public
authority holds about yourself, you should make a "Subject Access Request" in
private using Data Protection law.  The leaflet Subject
Access - A guide for data subjects (on the Information Commisioner's
website) explains how to do this.

I'd like to keep my request secret! (At least until I publish my story)

WhatDoTheyKnow is currently only designed for public requests. All
responses that we receive are automatically published on the website for anyone
to read.  You should contact the public authority directly if you would like to
make a request in private.  If you're interested in buying a system which helps
you manage FOI requests in secret, then contact us.

Why can I only request information about the environment from some authorities?

Some public authorities, such as South East Water,
don't come under the Freedom of Information Act, but do come under another law called
the Environmental Information Regulations (EIR). It's a very similar law, so you make a request
to them using WhatDoTheyKnow in just the same way as an FOI request. The only difference
is that on the page where you write you request, it reminds you that you can only
request "environmental information" and tells you what that means. It is quite broad.

So can I request information using EIR from other authorities?

Yes, just make a Freedom of Information (FOI) request as normal. The
authority has a duty to work out if the Environmental Information Regulations
(EIR) is the more appropriate legislation to reply under.

Privacy questions

Who gets to see my email address?

We will not disclose your email address to anyone, including the public
authority you are sending a request to, unless we are obliged to by law,
or you ask us to. If you send a message to another user on the site, then
it will reveal your email address to them. You will be told that this
is going to happen.

Will you send nasty, brutish spam to my email address?

Nope. After you sign up to WhatDoTheyKnow we will only send you emails
relating to a request you made, an email alert that you have signed up for,
or for other reasons that you specifically authorise. We will never give or
sell your email addresses to anyone else, unless we are obliged to by law, or
you ask us to.

Why will my name appear publically on the site?

It means that someone researching the same area can get in touch with you,
and maybe give you more information or ideas relating to your request.  Also,
we're going to publish the response with the name of the civil servant who
wrote it, so it seems only fair that your name should be public too!
Therefore, we encourage you to use your real name, but you may use a pseudonym
if you would like to be anonymous.

So I can make an FOI request using a pseudonym?

Yes, you can. It is good practice for the public authority to reply to such
a request, except in special circumstances such as if they suspect you of
making vexatious requests. See Freedom of Information Good Practice Guidance No 6 for details. You
should refer to this if a public authority attempts to refuse a request because you used a pseudonym.
Saying that, you can avoid the problem by simply making your pseudonym look like a real person's name,
as there is no general obligation to prove your identity.

They've asked for my postal address!

If a public authority asks you for your full, physical address, reply to them saying
that section 8.1.b of the FOI Act asks for an "address for correspondence",
and that the email address you are using is sufficient.
The Ministry of Justice has guidance
on this –
"As well as hard copy written correspondence, requests that are
transmitted electronically (for example, in emails) are acceptable
... If a request is received by email and no postal address is given, the email
address should be treated as the return address."

Why does the list of things that I'm tracking appear publically on the site?

This helps you find others who are researching the same area of government,
so you can form groups to investigate or campaign together. It also helps us
show requests which are related to other requests. If you've ever used a
"social bookmarking" website such as Delicious, Digg or reddit, think of it like
that.

FOI officer questions

Why are you publishing responses to FOI requests?

Freedom of Information responses contain public information, which anybody could
easily request again from the public authority. Therefore,
there is no reason they shouldn't be published on the Internet. There are lots
of benefits - everything from preventing duplicate requests, to getting the public
more involved and interested in the work of government.

Are the people making requests real people?

Yes. This website is a service to help ordinary members of the public
make FOI requests, and easily track the responses. The people are real
people, for whom we have a verified email address unique to each person.

Aren't you making lots of vexatious requests?

WhatDoTheyKnow is not making any requests. We are sending requests on
behalf of our users, who are real people making the requests. Look at it like
this - if lots of different people made requests from different Hotmail email
addresses, then you would not think that Microsoft were making vexatious
requests. It is exactly the same if lots of requests are made via
WhatDoTheyKnow. Moreover, since all requests are public it is much easier for
you to see if one of our users is making vexatious requests, and for us to
block them when that happens.

Won't I be breaking copyright law by sending a response that you then publish?

No, you will simply be replying to an FOI request by email (the "expressed
preference" of the requester, under
section
11(1) of the Freedom of Information Act). That we are later republishing your
response is a separate matter of copyright law, and not something which FOIA lists
as a reason for rejecting a request.

Isn't it a problem that you publish the names of civil servants
and the text of emails?

Officers or servants responding to requests are doing so on behalf of the
public as part of their job, and we publish their response on that
basis. Usually the names and phone numbers of FOI officers are already
available on authority websites. We also encourage our users to give their real
name too, so it is fair both ways.

Do you publish email addresses or mobile phone numbers?

We automatically remove email addresses and labelled mobile phone numbers
that are in the email part of responses from public authorities. Please
contact us if we've missed one. We don't currently
remove these from attachments,
such as Word documents.

Can you take down private information about me?

If you see any information on the site which you'd like us to remove or
hide, then please let us know. We'll then
remove it, provided it is genuinely private information.

Credit where credit is due

Which people made WhatDoTheyKnow?

Oh, nearly everyone (and maybe you too)!

    Heather Brooke
    (vampy!) has
    been pushing the idea of a UK FOI archive for years now.

    Both Phil Rodgers and Francis Irving
    entered it in a mySociety competition for ideas for public interest websites to build.

    It won,
    and then Chris Lightfoot (RIP :()
    thought up the wheeze of intercepting email responses to requests and
    automatically publishing them.

    Tom Steinberg got the cash to pay for the site from
    a dead chocolate mogul (thank you!) ...

    ... so that Francis Irving, Angie Ahl, Tommy Martin, Louise Crow, Matthew Somerville
    and Tom Steinberg could do the complex mixture of design and coding to build
    what you see today.

    Thanks particularly to Julian Todd (great blog!),
    Francis Davey, and Etienne Pollard for using the site early on and giving
    feedback (and/or legal advice!), and also to all our other users and
    testers.

    Lots of people have been looking up FOI email addresses, and a few
    volunteering to run the site - most especially Adam McGreggor, Alex
    Skene, John Cross and Tony Bowden.

Finally we couldn't do any of this without those
crazy people who volunteer,
amongst many other things, to do the accounts and fill in our VAT return.

You're all stars.

<% @title = "About" %>

Contact Us

If your question isn't answered here, or you just wanted to let us know
something about the site, contact us.

Introduction to WhatDoTheyKnow

What is WhatDoTheyKnow for?

To help you find out inside information about what the UK government
is doing.

How does the site work?

You choose the public authority that you would like information from, then
write a brief note describing what you want to know. We then send your request
to the public authority. Any response they make is automatically published on the
website for you and anyone else to find and read.

Why would I bother to do this?

You pay taxes, and then government does things with the money. All sorts of
things that affect your life, from healthcare through to national defence. Some
it does badly, some it does well. The more we find out about how government
works, the better able we are to make suggestions to improve the things that
are done badly, and to celebrate the things that are done well.

Why would the public authority bother to reply?

Under Freedom of Information (FOI) law, they have to respond.

Who makes it?

WhatDoTheyKnow is made by mySociety,
and was initially funded by the JRSST Charitable Trust. mySociety is a project of the
registered charity UK Citizens Online Democracy.
If you like what we're doing, then you can
make a donation.

Making requests

You're missing the public authority that I want to request from!

Please contact us with the name of the public authority and,
if you can find it, their contact email address for Freedom of Information requests.
If you'd like to help add a whole category of public authority to the site, for example all
primary care trusts or all schools, then please
edit this shared spreadsheet (Google account required).

How quickly will I get a response?

By law public authorities must respond within 20 days, excluding weekends and
any UK bank holidays. The date that the response is due by is shown on the
page for your request. You will be emailed if this date goes by without
a response, so you can send the public authority another note to hurry them up.
Note: If you had to clarify your request, the clock starts from that date,
instead of the date they received your initial request.

What if I'm not satisfied with the response?

If you didn't get the information you asked for, or you didn't get it in time,
then read our page 'Unhappy about the response you got?'.

Can you tell me more of the nitty gritty about the process of making requests?

Have a look at the
access to official information
pages on the Information Commisioner's website.

Can I request information about myself?

Not using this site. Requests made using WhatDoTheyKnow are public, made under the
Freedom of Information Act, and cannot help you find information about a
private individual. If you would like to know what information a public
authority holds about yourself, you should make a "Subject Access Request" in
private using Data Protection law.  The leaflet Subject
Access - A guide for data subjects (on the Information Commisioner's
website) explains how to do this.

I'd like to keep my request secret! (At least until I publish my story)

WhatDoTheyKnow is currently only designed for public requests. All
responses that we receive are automatically published on the website for anyone
to read.  You should contact the public authority directly if you would like to
make a request in private.  If you're interested in buying a system which helps
you manage FOI requests in secret, then contact us.

Why can I only request information about the environment from some authorities?

Some public authorities, such as South East Water,
don't come under the Freedom of Information Act, but do come under another law called
the Environmental Information Regulations (EIR). It's a very similar law, so you make a request
to them using WhatDoTheyKnow in just the same way as an FOI request. The only difference
is that on the page where you write you request, it reminds you that you can only
request "environmental information" and tells you what that means. It is quite broad.

So can I request information using EIR from other authorities?

Yes, just make a Freedom of Information (FOI) request as normal. The
authority has a duty to work out if the Environmental Information Regulations
(EIR) is the more appropriate legislation to reply under.

Privacy questions

Who gets to see my email address?

We will not disclose your email address to anyone, including the public
authority you are sending a request to, unless we are obliged to by law,
or you ask us to. If you send a message to another user on the site, then
it will reveal your email address to them. You will be told that this
is going to happen.

Will you send nasty, brutish spam to my email address?

Nope. After you sign up to WhatDoTheyKnow we will only send you emails
relating to a request you made, an email alert that you have signed up for,
or for other reasons that you specifically authorise. We will never give or
sell your email addresses to anyone else, unless we are obliged to by law, or
you ask us to.

Why will my name appear publically on the site?

It means that someone researching the same area can get in touch with you,
and maybe give you more information or ideas relating to your request.  Also,
we're going to publish the response with the name of the civil servant who
wrote it, so it seems only fair that your name should be public too!
Therefore, we encourage you to use your real name, but you may use a pseudonym
if you would like to be anonymous.

So I can make an FOI request using a pseudonym?

Yes, you can. It is good practice for the public authority to reply to such
a request, except in special circumstances such as if they suspect you of
making vexatious requests. See Freedom of Information Good Practice Guidance No 6 for details. You
should refer to this if a public authority attempts to refuse a request because you used a pseudonym.
Saying that, you can avoid the problem by simply making your pseudonym look like a real person's name,
as there is no general obligation to prove your identity.

They've asked for my postal address!

If a public authority asks you for your full, physical address, reply to them saying
that section 8.1.b of the FOI Act asks for an "address for correspondence",
and that the email address you are using is sufficient.
The Ministry of Justice has guidance
on this –
"As well as hard copy written correspondence, requests that are
transmitted electronically (for example, in emails) are acceptable
... If a request is received by email and no postal address is given, the email
address should be treated as the return address."

Why does the list of things that I'm tracking appear publically on the site?

This helps you find others who are researching the same area of government,
so you can form groups to investigate or campaign together. It also helps us
show requests which are related to other requests. If you've ever used a
"social bookmarking" website such as Delicious, Digg or reddit, think of it like
that.

FOI officer questions

Why are you publishing responses to FOI requests?

Freedom of Information responses contain public information, which anybody could
easily request again from the public authority. Therefore,
there is no reason they shouldn't be published on the Internet. There are lots
of benefits - everything from preventing duplicate requests, to getting the public
more involved and interested in the work of government.

Are the people making requests real people?

Yes. This website is a service to help ordinary members of the public
make FOI requests, and easily track the responses. The people are real
people, for whom we have a verified email address unique to each person.

Aren't you making lots of vexatious requests?

WhatDoTheyKnow is not making any requests. We are sending requests on
behalf of our users, who are real people making the requests. Look at it like
this - if lots of different people made requests from different Hotmail email
addresses, then you would not think that Microsoft were making vexatious
requests. It is exactly the same if lots of requests are made via
WhatDoTheyKnow. Moreover, since all requests are public it is much easier for
you to see if one of our users is making vexatious requests, and for us to
block them when that happens.

Won't I be breaking copyright law by sending a response that you then publish?

No, you will simply be replying to an FOI request by email (the "expressed
preference" of the requester, under
section
11(1) of the Freedom of Information Act). That we are later republishing your
response is a separate matter of copyright law, and not something which FOIA lists
as a reason for rejecting a request.

Isn't it a problem that you publish the names of civil servants
and the text of emails?

Officers or servants responding to requests are doing so on behalf of the
public as part of their job, and we publish their response on that
basis. Usually the names and phone numbers of FOI officers are already
available on authority websites. We also encourage our users to give their real
name too, so it is fair both ways.

Do you publish email addresses or mobile phone numbers?

We automatically remove email addresses and labelled mobile phone numbers
that are in the email part of responses from public authorities. Please
contact us if we've missed one. We don't currently
remove these from attachments,
such as Word documents.

Can you take down private information about me?

If you see any information on the site which you'd like us to remove or
hide, then please let us know. We'll then
remove it, provided it is genuinely private information.

Credit where credit is due

Which people made WhatDoTheyKnow?

Oh, nearly everyone (and maybe you too)!

    Heather Brooke
    (vampy!) has
    been pushing the idea of a UK FOI archive for years now.

    Both Phil Rodgers and Francis Irving
    entered it in a mySociety competition for ideas for public interest websites to build.

    It won,
    and then Chris Lightfoot (RIP :()
    thought up the wheeze of intercepting email responses to requests and
    automatically publishing them.

    Tom Steinberg got the cash to pay for the site from
    a dead chocolate mogul (thank you!) ...

    ... so that Francis Irving, Angie Ahl, Tommy Martin, Louise Crow, Matthew Somerville
    and Tom Steinberg could do the complex mixture of design and coding to build
    what you see today.

    Thanks particularly to Julian Todd (great blog!),
    Francis Davey, and Etienne Pollard for using the site early on and giving
    feedback (and/or legal advice!), and also to all our other users and
    testers.

    Lots of people have been looking up FOI email addresses, and a few
    volunteering to run the site - most especially Adam McGreggor, Alex
    Skene and John Cross.

Finally we couldn't do any of this without those
crazy people who volunteer,
amongst many other things, to do the accounts and fill in our VAT return.

You're all stars.


Added logic to enable/disable PDF and Watch buttons based on system policies

<% @page_title = @page.title %>

<% if @project and !@project.nav_content.blank? and !@project.nav_content.blank? %>

    <%= render_filtered(@project, :nav_content, self) %>

<% end %>

<% show_pdf_button = Policy.lookup(:pdf_generator).value %>
<% show_watch_button = Policy.lookup(:watch_emails).value %>

<% unless @page.title == 'index' %>

    <%= h(@page.title) %>

    <% if current_user.can_edit_pages?(@project) %>
      <%= link_to_page_editor(@page) %>
    <% end %>
    <% if !current_user.new_record? && show_watch_button %>
      <%= link_to_page_watcher(@page) %>
    <% end %>
    <% unless @project.to_s.empty? %>
      <%= link_to_page_printer(@page) %>
      <%= link_to_page_pdf(@page) if show_pdf_button %>
    <% end %>

<% end %>

<%= render_page(@page) %>

  Updated <%= h(format_time_from(@page.updated_at, current_user)) %>
  by <%= link_to_person(@page.updated_by) %>

  <% if current_user.can_edit_pages?(@project) %>
    <%= link_to_page_editor(@page) %>
  <% end %>
  <% if !current_user.new_record? && show_watch_button %>
    <%= link_to_page_watcher(@page) %>
  <% end %>
  <% unless @project.to_s.empty? %>
    <%= link_to_page_printer(@page) %>
    <%= link_to_page_pdf(@page) if show_pdf_button %>
  <% end %>

Tags: <%= render_tag_editor(@page) %>

<%= tag_cloud_for(@page) %>

<%= comment_section_for(@page) %>

<% @page_title = @page.title %>

<% if @project and !@project.nav_content.blank? and !@project.nav_content.blank? %>

    <%= render_filtered(@project, :nav_content, self) %>

<% end %>

<% unless @page.title == 'index' %>

    <%= h(@page.title) %>

    <% if current_user.can_edit_pages?(@project) %>
      <%= link_to_page_editor(@page) %>
    <% end %>
    <% unless current_user.new_record? %>
      <%= link_to_page_watcher(@page) %>
    <% end %>
    <% unless @project.to_s.empty? %>
      <%= link_to_page_printer(@page) %>
      <%= link_to_page_pdf(@page) %>
    <% end %>

<% end %>

<%= render_page(@page) %>

  Updated <%= h(format_time_from(@page.updated_at, current_user)) %>
  by <%= link_to_person(@page.updated_by) %>

  <% if current_user.can_edit_pages?(@project) %>
    <%= link_to_page_editor(@page) %>
  <% end %>
  <% unless current_user.new_record? %>
    <%= link_to_page_watcher(@page) %>
  <% end %>
  <% unless @project.to_s.empty? %>
    <%= link_to_page_printer(@page) %>
    <%= link_to_page_pdf(@page) %>
  <% end %>

Tags: <%= render_tag_editor(@page) %>

<%= tag_cloud_for(@page) %>

<%= comment_section_for(@page) %>


Add context and tests for SC.CollectionView selection delegate.

  * Should use isSelectable to determine selectability in the absence of a delegate
  * Should query the delegate for selectability
  * Should select the next selectable item
  * Should select the previous selectable item
  * Should retain selection when no previous item is selectable
  * Should retain selection when no further item is selectable

<% content_for('final') do %>
<script>

// create some item data...
[
 { guid: '1001', name: 'item one' },
 { guid: '1002', name: 'item two' },
 { guid: '1003', name: 'item three' },
 { guid: '1004', name: 'item four' },
 { guid: '1005', name: 'item five' },
 { guid: '1006', name: 'item six' }
].each(function(o){ SC.Store.addRecord(SC.Record.create(o)); });

// a collection to hold the items...
testCollection = SC.Record.collection();
testCollection.refresh();

// a controller for the collection...
testController = SC.CollectionController.create();

Test.context("A SC.CollectionView with it's content set to a SC.CollectionController 1", {

  "Should scroll to the selected item": function()
  {
    testCollectionView.get('rootElement').scrollTop.shouldEqual(0);
    testCollectionView.scrollToContent( testCollection.get('records').last() );
    testCollectionView.get('itemViews').length.shouldEqual(3);
    scrollView.get('rootElement').scrollTop.shouldEqual(30);
  },

  setup: function()
  {
    // add a scroll view wrapper.
    scrollView = SC.ScrollView.create() ;
    scrollView.set('frame', { x: 10, y: 10, width: 100, height: 30 }) ;
    SC.window.appendChild(scrollView) ;

    // create the view...
    testCollectionView = SC.ListView.create({
      contentValueKey: 'name',
      contentBinding: 'testController.arrangedObjects',
      selectionBinding: 'testController.selection'
    }) ;
    scrollView.set('content', testCollectionView) ;

    testController.set('content', testCollection) ;
  },

  teardown: function()
  {
    // remove the view from SC.window
    testCollectionView.removeFromParent() ;
    scrollView.removeFromParent() ;

    delete testCollectionView ;
    delete scrollView ;

    testController.set('content', null) ;
  }

});

Test.context("A SC.CollectionView with it's content set to a SC.CollectionController 2", {

  "Should not scroll to the selected item if it's already fully visible": function()
  {
    scrollView.get('rootElement').scrollTop.shouldEqual(0);
    testCollectionView.scrollToContent( testCollection.get('records')[1] );
    scrollView.get('rootElement').scrollTop.shouldEqual(0);
  },

  setup: function()
  {
    // add a scroll view wrapper.
    scrollView = SC.ScrollView.create() ;
    scrollView.set('frame', { x: 10, y: 10, width: 100, height: 30 }) ;
    SC.window.appendChild(scrollView) ;

    // create the view...
    testCollectionView = SC.ListView.create({
      contentValueKey: 'name',
      contentBinding: 'testController.arrangedObjects',
      selectionBinding: 'testController.selection'
    }) ;
    scrollView.set('content', testCollectionView) ;

    testController.set('content', testCollection) ;
  },

  teardown: function()
  {
    // remove the view from SC.window
    testCollectionView.removeFromParent() ;
    scrollView.removeFromParent() ;

    delete testCollectionView ;
    delete scrollView ;

    testController.set('content', null) ;
  }

});

Test.context("A SC.CollectionView with it's content set to a SC.CollectionController 3", {

  "Should contain the same number of visible item views as it's controller has records": function()
  {
    testCollectionView.get('itemViews').length.shouldEqual(2);
  },

  "Should update it's item views as it's controller is updated": function()
   {
     var valueOfFirstItemView = function() {
       var itemView = testCollectionView.get('itemViews').first() ;
       return (itemView) ? itemView.get('content').get('guid') : null ;
     } ;

     valueOfFirstItemView().shouldEqual('1001') ;

     var rec = SC.Record.create({ guid: '0999', name: 'item zero' });
     SC.Store.addRecord( rec );

     valueOfFirstItemView().shouldEqual('0999') ;
     testCollectionView.get('itemViews').length.shouldEqual(2);

     rec.destroy();
     SC.Store.removeRecord(rec);
     delete rec;
   },

  setup: function()
  {
    // add a scroll view wrapper.
    scrollView = SC.ScrollView.create() ;
    scrollView.set('frame', { x: 10, y: 10, width: 100, height: 30 }) ;
    SC.window.appendChild(scrollView) ;

    // create the view...
    testCollectionView = SC.ListView.create({
      contentValueKey: 'name',
      contentBinding: 'testController.arrangedObjects',
      selectionBinding: 'testController.selection'
    }) ;
    scrollView.set('content', testCollectionView) ;

    testController.set('content', testCollection) ;
  },

  teardown: function()
  {
    // remove the view from SC.window
    testCollectionView.removeFromParent() ;
    scrollView.removeFromParent() ;

    delete testCollectionView ;
    delete scrollView ;

    testController.set('content', null) ;
  }

});

Test.context("A SC.CollectionView with it's content set to a SC.ArrayController",
{
  "Should contain the same number of item views as it's controller has records": function()
  {
    this.controller.get('length').shouldEqual(6);
    this.view.get('itemViews').length.shouldEqual(6);
  },
  "Should update it's item views as it's controller is updated": function()
  {
    this.view.get('itemViews').length.shouldEqual(6);
    this.controller.pushObject({ guid: '1007', name: 'item seven' });
    this.view.get('itemViews').length.shouldEqual(7);
    this.controller.popObject();
    this.view.get('itemViews').length.shouldEqual(6);
  },

  setup: function()
  {
    // create the view...
    this.view = SC.CollectionView.create();
    SC.window.appendChild(this.view);

    // create some item data...
    this.array = [
      { guid: '1001', name: 'item one' },
      { guid: '1002', name: 'item two' },
      { guid: '1003', name: 'item three' },
      { guid: '1004', name: 'item four' },
      { guid: '1005', name: 'item five' },
      { guid: '1006', name: 'item six' }
    ];

    this.controller = SC.ArrayController.create();
    this.controller.set('content', this.array);
    this.view.set('content', this.controller);
  },
  teardown: function()
  {
    // remove the view from SC.window
    this.view.removeFromParent();

    delete this.view;
    delete this.array;
    delete this.controller;
  }
});

Test.context("SC.CollectionView selection delegate support", {
  "Should use isSelectable to determine selectability in the absence of a delegate": function () {
    this.view.set('delegate', null);
    this.view.set('isSelectable', NO);
    this.view.selectItems([this.array[0], this.array[1]]);
    this.view.get('selection').length.shouldEqual(0);

    this.view.set('isSelectable', YES);
    this.view.selectItems([this.array[0], this.array[1]]);
    this.view.get('selection').length.shouldEqual(2);
  },

  "Should query the delegate for selectability": function () {
    this.view.selectItems([this.array[0], this.array[1]]);
    this.view.get('selection').shouldEqualEnum([this.array[1]]);
  },

  "Should select the next selectable item": function () {
    this.view.selectItems([this.array[2]]);
    this.view.selectNextItem();
    this.view.get('selection').shouldEqualEnum([this.array[4]]);
  },

  "Should select the previous selectable item": function () {
    this.view.selectItems([this.array[2]]);
    this.view.selectPreviousItem();
    this.view.get('selection').shouldEqualEnum([this.array[1]]);
  },

  "Should retain selection when no previous item is selectable": function () {
    this.view.selectItems([this.array[1]]);
    this.view.selectPreviousItem();
    this.view.get('selection').shouldEqualEnum([this.array[1]]);
  },

  "Should retain selection when no further item is selectable": function () {
    this.view.selectItems([this.array[4]]);
    this.view.selectNextItem();
    this.view.get('selection').shouldEqualEnum([this.array[4]]);
  },

  setup: function () {
    // create the view...
    this.view = SC.CollectionView.create();
    SC.window.appendChild(this.view);

    // create some item data...
    this.array = [
      { guid: '1001', name: 'item one', canSelect: NO },
      { guid: '1002', name: 'item two', canSelect: YES },
      { guid: '1003', name: 'item three', canSelect: YES },
      { guid: '1004', name: 'item four', canSelect: NO },
      { guid: '1005', name: 'item five', canSelect: YES },
      { guid: '1006', name: 'item six', canSelect: NO }
    ];

    this.delegate = SC.Object.create({
      collectionViewShouldSelectItem: function (view, item) {
        return item.canSelect;
      }
    });

    this.controller = SC.ArrayController.create();
    this.controller.set('content', this.array);
    this.view.set('isSelectable', YES);
    this.view.set('content', this.controller);
    this.view.set('delegate', this.delegate);
  },

  teardown: function () {
    // remove the view from SC.window
    this.view.removeFromParent();

    delete this.view;
    delete this.array;
    delete this.delegate;
    delete this.controller;
  }
});

</script>

<% end %>

<% content_for('final') do %>
<script>

// create some item data...
[
 { guid: '1001', name: 'item one' },
 { guid: '1002', name: 'item two' },
 { guid: '1003', name: 'item three' },
 { guid: '1004', name: 'item four' },
 { guid: '1005', name: 'item five' },
 { guid: '1006', name: 'item six' }
].each(function(o){ SC.Store.addRecord(SC.Record.create(o)); });

// a collection to hold the items...
testCollection = SC.Record.collection();
testCollection.refresh();

// a controller for the collection...
testController = SC.CollectionController.create();

Test.context("A SC.CollectionView with it's content set to a SC.CollectionController 1", {

  "Should scroll to the selected item": function()
  {
    testCollectionView.get('rootElement').scrollTop.shouldEqual(0);
    testCollectionView.scrollToContent( testCollection.get('records').last() );
    testCollectionView.get('itemViews').length.shouldEqual(3);
    scrollView.get('rootElement').scrollTop.shouldEqual(30);
  },

  setup: function()
  {
    // add a scroll view wrapper.
    scrollView = SC.ScrollView.create() ;
    scrollView.set('frame', { x: 10, y: 10, width: 100, height: 30 }) ;
    SC.window.appendChild(scrollView) ;

    // create the view...
    testCollectionView = SC.ListView.create({
      contentValueKey: 'name',
      contentBinding: 'testController.arrangedObjects',
      selectionBinding: 'testController.selection'
    }) ;
    scrollView.set('content', testCollectionView) ;

    testController.set('content', testCollection) ;
  },

  teardown: function()
  {
    // remove the view from SC.window
    testCollectionView.removeFromParent() ;
    scrollView.removeFromParent() ;

    delete testCollectionView ;
    delete scrollView ;

    testController.set('content', null) ;
  }

});

Test.context("A SC.CollectionView with it's content set to a SC.CollectionController 2", {

  "Should not scroll to the selected item if it's already fully visible": function()
  {
    scrollView.get('rootElement').scrollTop.shouldEqual(0);
    testCollectionView.scrollToContent( testCollection.get('records')[1] );
    scrollView.get('rootElement').scrollTop.shouldEqual(0);
  },

  setup: function()
  {
    // add a scroll view wrapper.
    scrollView = SC.ScrollView.create() ;
    scrollView.set('frame', { x: 10, y: 10, width: 100, height: 30 }) ;
    SC.window.appendChild(scrollView) ;

    // create the view...
    testCollectionView = SC.ListView.create({
      contentValueKey: 'name',
      contentBinding: 'testController.arrangedObjects',
      selectionBinding: 'testController.selection'
    }) ;
    scrollView.set('content', testCollectionView) ;

    testController.set('content', testCollection) ;
  },

  teardown: function()
  {
    // remove the view from SC.window
    testCollectionView.removeFromParent() ;
    scrollView.removeFromParent() ;

    delete testCollectionView ;
    delete scrollView ;

    testController.set('content', null) ;
  }

});

Test.context("A SC.CollectionView with it's content set to a SC.CollectionController 3", {

  "Should contain the same number of visible item views as it's controller has records": function()
  {
    testCollectionView.get('itemViews').length.shouldEqual(2);
  },

  "Should update it's item views as it's controller is updated": function()
   {
     var valueOfFirstItemView = function() {
       var itemView = testCollectionView.get('itemViews').first() ;
       return (itemView) ? itemView.get('content').get('guid') : null ;
     } ;

     valueOfFirstItemView().shouldEqual('1001') ;

     var rec = SC.Record.create({ guid: '0999', name: 'item zero' });
     SC.Store.addRecord( rec );

     valueOfFirstItemView().shouldEqual('0999') ;
     testCollectionView.get('itemViews').length.shouldEqual(2);

     rec.destroy();
     SC.Store.removeRecord(rec);
     delete rec;
   },

  setup: function()
  {
    // add a scroll view wrapper.
    scrollView = SC.ScrollView.create() ;
    scrollView.set('frame', { x: 10, y: 10, width: 100, height: 30 }) ;
    SC.window.appendChild(scrollView) ;

    // create the view...
    testCollectionView = SC.ListView.create({
      contentValueKey: 'name',
      contentBinding: 'testController.arrangedObjects',
      selectionBinding: 'testController.selection'
    }) ;
    scrollView.set('content', testCollectionView) ;

    testController.set('content', testCollection) ;
  },

  teardown: function()
  {
    // remove the view from SC.window
    testCollectionView.removeFromParent() ;
    scrollView.removeFromParent() ;

    delete testCollectionView ;
    delete scrollView ;

    testController.set('content', null) ;
  }

});

Test.context("A SC.CollectionView with it's content set to a SC.ArrayController",
{
  "Should contain the same number of item views as it's controller has records": function()
  {
    this.controller.get('length').shouldEqual(6);
    this.view.get('itemViews').length.shouldEqual(6);
  },
  "Should update it's item views as it's controller is updated": function()
  {
    this.view.get('itemViews').length.shouldEqual(6);
    this.controller.pushObject({ guid: '1007', name: 'item seven' });
    this.view.get('itemViews').length.shouldEqual(7);
    this.controller.popObject();
    this.view.get('itemViews').length.shouldEqual(6);
  },
  setup: function()
  {
    // create the view...
    this.view = SC.CollectionView.create();
    SC.window.appendChild(this.view);

    // create some item data...
    this.array = [
      { guid: '1001', name: 'item one' },
      { guid: '1002', name: 'item two' },
      { guid: '1003', name: 'item three' },
      { guid: '1004', name: 'item four' },
      { guid: '1005', name: 'item five' },
      { guid: '1006', name: 'item six' }
    ];

    this.controller = SC.ArrayController.create();
    this.controller.set('content', this.array);
    this.view.set('content', this.controller);
  },
  teardown: function()
  {
    // remove the view from SC.window
    this.view.removeFromParent();

    delete this.view;
    delete this.array;
    delete this.controller;
  }
});

</script>

<% end %>