conversations, fixes #6594

Test plan:
- send a message to multiple people you have not previously had a
  conversation with
- observe that the message was successfully sent (but nothing is added
  to the conversation list)

Change-Id: I3b3b57a58faa10bfeb3067112810226434ffd532
Reviewed-on: https://gerrit.instructure.com/8001
Tested-by: Hudson <hudson@instructure.com>
Reviewed-by: Ryan Florence <ryanf@instructure.com>
fix conversation loading errors, closes #6812

Change-Id: Idaafd241be4dfa62197245e792342d11a1cc046e
Reviewed-on: https://gerrit.instructure.com/8109
Tested-by: Hudson <hudson@instructure.com>
Reviewed-by: Cameron Matheson <cameron@instructure.com>
updated selenium specs to use assert_flash_error and assert_flash_notice

Change-Id: I622214e35944a62acdb0324181a83926769f60d1
Reviewed-on: https://gerrit.instructure.com/8164
Reviewed-by: Bryan Madsen <bryan@instructure.com>
Tested-by: Hudson <hudson@instructure.com>
show muted assignment indicator in gradebook2

there was already a tooltip as you hover over
each submission and the header menu let you mute/
unmute but I guess people wanted to see the little
'muted' icon in the header as well

in the process I broke it out into its own
handlebars template

fixes: #6804

test plan:
 * mute an assignment
 * go to gradebook2
 * look for a little mute icon in the header of
   that  column like on gradebook1

Change-Id: If728a4f11241440d377264123c0824edf05f12b3
Reviewed-on: https://gerrit.instructure.com/8114
Tested-by: Hudson <hudson@instructure.com>
Tested-by: Jake Sorce <jake@instructure.com>
Reviewed-by: Jake Sorce <jake@instructure.com>
show outcomes from all associated accounts; fixes #6800

we were showing outcomes for associated accounts for course contexts but not
sub-account contexts. now we are.

test plan:
- create an account level outcome
- create a sub-account level rubric
- click find outcome criteria
- ensure that the account level outcome is available

Change-Id: I64a8feacadecd3bbc12eedc3c1c5ccea9b16360c
Reviewed-on: https://gerrit.instructure.com/8125
Tested-by: Hudson <hudson@instructure.com>
Reviewed-by: Rob Orton <rob@instructure.com>
Reviewed-by: Cody Cutrer <cody@instructure.com>
added js_env view/controller helper

this helper is the mechanism to send data from
rails to the JavaScript w/o requiring an xhr
or dumping data into the DOM and pulling it back
out /barf

you can call it from a view or a controller

test case:
1. call `js_env :FOO => 'bar'` in a view or
   in a controller
2. load the page
3. open the web console and inspect the ENV
   global JavaScript variable
4. ENV.FOO should be 'bar', wassupnow?

Change-Id: Ie079ba0ee610fc6a9e837cd1301ee29b08201e65
Reviewed-on: https://gerrit.instructure.com/8170
Tested-by: Hudson <hudson@instructure.com>
Reviewed-by: Ryan Shaw <ryan@instructure.com>
clean up wait_for_dom_ready in selenium files

Change-Id: I3265319a5b31ea778aa881ee7582eab66c517dbd
Reviewed-on: https://gerrit.instructure.com/8176
Reviewed-by: Bryan Madsen <bryan@instructure.com>
Tested-by: Hudson <hudson@instructure.com>
selenium file cleanup

Change-Id: I34431e9fcdd05626e0f7d2b9ecfe8d760a8145ee
Reviewed-on: https://gerrit.instructure.com/8174
Tested-by: Hudson <hudson@instructure.com>
Reviewed-by: Bryan Madsen <bryan@instructure.com>
fix invitees visiting unpublished courses

don't try and accept! (or reject!) when they're not actually invited.
only show "invitation accepted/rejected" flashes when it actually
happened. don't allow previewing invitees to see unpublished courses.
don't show invitation related flashes when displaying a "you can't look
at this" page. fixes #6708.

test-plan:
  - create unpublished courses in the default account and in a
    non-default account
  - create a user for each course and invite them as students to the courses
  - try and visit the courses as the respective students
  - both should see the "this course hasn't been published yet" page
  - both should see no flash-notice on that page
  - neither should be accepted to their course
  - create a user and invite them to one of the courses as a teacher
  - try and visit the course as the teacher
  - should not see the "this course hasn't been published yet" page

Change-Id: I5e6ce4541621bdc3d6dac0efe62a2741f7addabf
Reviewed-on: https://gerrit.instructure.com/8079
Reviewed-by: Jacob Fugal <jacob@instructure.com>
Tested-by: Hudson <hudson@instructure.com>
unpublished quiz preview fixes #6528

previewing the quiz is posted, and then redirected
with a get request but the preview parameter was
not passed through to the redirect, now it is.

test plan:
1. start a new quiz
2. add and save a question
3. click 'preview quiz'

you ought to be able to preview the quiz

also fixed the spec to check for the presence of
the questions container, rather than the title
since the title is present whether you're able to
preview the quiz or not.

Change-Id: I87a3a179ed79f464b7c765c9f23ba48226bb86ca
Reviewed-on: https://gerrit.instructure.com/8099
Tested-by: Hudson <hudson@instructure.com>
Reviewed-by: Ryan Florence <ryanf@instructure.com>
added resize_screen_to_default to wiki_and_tiny selenium spec

Change-Id: I4876093013b180832dd5ff54647c036615f19a78
Reviewed-on: https://gerrit.instructure.com/8171
Tested-by: Hudson <hudson@instructure.com>
Reviewed-by: Bryan Madsen <bryan@instructure.com>
improve error reports categories query on postgres

postgres can't/won't use the index for a DISTINCT query, so be a
bit more explicit with it to get it to use the index

test plan:
 * go to /error_reports
 * it should load fast, there should be a categories dropdown,
   and it should have a few things in it besides all categories
   (assuming you have some error reports)

Change-Id: If7c71cd669e7eadc1792eefe1fb6e85a08c054ed
Reviewed-on: https://gerrit.instructure.com/8190
Reviewed-by: Brian Palmer <brianp@instructure.com>
Tested-by: Hudson <hudson@instructure.com>
cleaning up sleeps in manage_groups selenium  spec

Change-Id: I30560891cdbc8732bfc354468e8489d589ec788d
Reviewed-on: https://gerrit.instructure.com/8175
Tested-by: Hudson <hudson@instructure.com>
Reviewed-by: Bryan Madsen <bryan@instructure.com>
clean up some unused and inefficient indexes

We optimize one index to leave out null values, and drop a bunch of
indexes that aren't used, or aren't generally used.

Dropping the unused stream_items.user_id column also drops two more
large unused indexes.

test plan: n/a

Change-Id: I3872365151676e5ce0867f7d6826e5a0d4447bbd
Reviewed-on: https://gerrit.instructure.com/8200
Tested-by: Hudson <hudson@instructure.com>
Reviewed-by: Ben Chobot <bench@instructure.com>
Reviewed-by: Cody Cutrer <cody@instructure.com>
conversation messages for submission comments, fixes #5443

this commit makes submission first-class citizens in conversations. this
means that when submission comments are added/deleted, or assignments are
unmuted, conversations and messages will be updated accordingly

the main impacts in the ui are:

1. submissions can be deleted from conversations. if a new comment is
   added, they will reappear
2. submissions factor into the message total for the conversation. each
   submission counts as a single message, even if there are multiple
   comments
3. submission messages affect unread-ness, and are reflected in the
   timestamp and text in the conversation preview

test plan:

1. confirm submissions appear in the appropriate conversations, i.e.
   * submissions with no comments should not appear in any conversations
   * submissions where there are comments but not by instructors:
     * should appear in each instructor's private conversation with the
       submitter
     * should not appear in the submitter's private conversations with
       anyone
   * submissions where there are comments by instructors:
     * should appear in each commenting instructor's private conversation
       with the submitter
     * should appear in submitter's private conversations with each
       commenting instructor
   adding or removing submission comments should update private
   conversations accordingly (e.g. when one teacher comments on a
   submission, it should be removed from the other teachers' private
   conversations with the submitter).
2. for each scenario above where the submission comments are added and
   appear in conversations, ensure that the submission as a whole behaves
   like a single conversation message, i.e.
   * the unread conversations count is incremented and the private
     conversation is marked as unread (if it didn't exist or was already
     read)
   * the latest submission comment and timestamp should be reflected in
     the conversation pane on the left side
   * you can delete the submission from the conversation. if new comments
     are posted on the submission, the submission should reappear in the
     conversation (provided it still matches the criteria in 1.). note
     that submission can not be forwarded to other conversations.
3. submissions should differ from traditional conversation messages in
   that:
   * they should not trigger conversation notifications
   * they should not create/bump conversation stream items. if a
     conversation has non-submission messages, the submission and its
     comments should appear in the stream item, but they should not
     cause it to jump to the top

migration:

existing submissions/comments will be migrated in, but not necessarily
through a traditional rails migration. to bring in those messages, run
the following from the rails console:

 Submission.find_each{ |s| s.create_or_update_conversations!(:migrate) }

Change-Id: I06dcb8728402a6c4c613d445b80432a1f2973b73
Reviewed-on: https://gerrit.instructure.com/8086
Tested-by: Hudson <hudson@instructure.com>
Reviewed-by: Jacob Fugal <jacob@instructure.com>
fixing some pending selenium tests

Change-Id: Ib8fe928589c858b893b1f17aacd9374a6e5c8212
Reviewed-on: https://gerrit.instructure.com/8177
Tested-by: Hudson <hudson@instructure.com>
Reviewed-by: Bryan Madsen <bryan@instructure.com>
upgrade to selenium 2.17 webdriver

Change-Id: I896f70f81a97ab3e9a3c2399aa17c420f72c1c54
Reviewed-on: https://gerrit.instructure.com/8206
Tested-by: Hudson <hudson@instructure.com>
Reviewed-by: Ryan Shaw <ryan@instructure.com>
ignore blank as_user_id

test plan:
 * do an api call providing as_user_id=, but no actual value
 * it should succeed

Change-Id: I3114e672ea427935045fa64be7c03c922290d042
Reviewed-on: https://gerrit.instructure.com/8227
Reviewed-by: Zach Wily <zach@instructure.com>
Tested-by: Zach Wily <zach@instructure.com>
support https for retrieving lti xml configs

net http needs some additional config in order
to support https requests.

fixes #6938

test plan:
- try adding an external tool with an http url config
  (like http://lti-examples.heroku.com/config/course_navigation.xml)
- make sure it adds correctly

- try adding an external tool with an https url config
  (like https://lti-examples.heroku.com/config/course_navigation.xml)
- make sure it adds correctly

Change-Id: Ia26c7d383069bccf761f18a2993f352002cc868a
Reviewed-on: https://gerrit.instructure.com/8139
Tested-by: Hudson <hudson@instructure.com>
Reviewed-by: Bracken Mosbacker <bracken@instructure.com>
account-level tools couldn't be configured by url

previously this would only work for course-level tools

fixes #6935

test plan:
- try adding a tool to an account by url configuration
- make sure it doesn't die

Change-Id: Id04a0619bd733d351098731cf2db67f8a26936dd
Reviewed-on: https://gerrit.instructure.com/8136
Tested-by: Hudson <hudson@instructure.com>
Reviewed-by: Bracken Mosbacker <bracken@instructure.com>