Commit Graph

196 Commits

Author SHA1 Message Date
Ethan Vizitei 0215a61aa8 bulk_insert can fail silently
TEST PLAN:
 - try to bulk_insert something with a missing parent
 - notice the actual error that occurs

Change-Id: Id93f3f52f0dc3e2ba50e98e144742b38d152bf5c
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/236204
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Cody Cutrer <cody@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
2020-05-05 14:40:29 +00:00
Ethan Vizitei bf534dab69 fix find_in_batches problem
FIXES CNVS-49060
flag = none

when the row count is exactly
the size of the batch, this
prevents the find_in_batches
code from erroring

TEST PLAN:
  1) find things in batches
  2) force it to make a temp_table with exactly batch_size
  3) batch iteration does not fail

Change-Id: I81ce7f6a58fa45e8041f814bac4cf5ec12879026
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/236102
Reviewed-by: Cody Cutrer <cody@instructure.com>
Reviewed-by: Gentry Beckmann <gbeckmann@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
2020-05-03 15:47:15 +00:00
Ethan Vizitei f558a7c3b3 host-specific circuit breaker
fixes CNVS-48937
flag = none

test plan:
  * start canvas
  * make it talk to some service for some reason
  * force the http call to return timeout errors
  * after enough of those within a short window
     we should start getting circuit breaker errors
  * make the http call not die
  * 15 seconds later circuit breaker errors should
     no longer happen

Change-Id: I3298932114bd2ed4a9e35e78ed41219403d4ee27
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/234637
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: James Williams <jamesw@instructure.com>
Reviewed-by: Simon Williams <simon@instructure.com>
Product-Review: Ethan Vizitei <evizitei@instructure.com>
QA-Review: Simon Williams <simon@instructure.com>
2020-04-22 16:06:52 +00:00
Cody Cutrer c8b0c29361 timeout when doing possibly unnecessary complicated counts for pagination
fixes USERS-274

test plan:
 * have a lot of users in an account (like 500)
 * go to /accounts/self/users
 * it should load, and show you how many pages there are
 * set the timeout to something absurdly low (like Setting.set('pagination_count_timeout', '1ms'))
 * go to the page again
 * it should still load the first page quickly, but the pages thingy at the bottom should only list
   1 and 2, and then an ellipsis

Change-Id: Ibc07036b39a9f4ed19d8824bb9254b23679298d1
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/234557
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Simon Williams <simon@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
2020-04-18 02:15:51 +00:00
Ethan Vizitei 38ccd99563 root account and shard tags for APM
closes APM-11
flag = none

TEST PLAN:
  * deploy to some environment with APM enabled
  * observe telemetry and confirm root_account
    and shard tags

Change-Id: I7246801c51617f10b8b7f3ca69b5d245375e81be
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/230415
Reviewed-by: Simon Williams <simon@instructure.com>
Reviewed-by: David Warkentin <dwarkentin@instructure.com>
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
QA-Review: Michael Hargiss <mhargiss@instructure.com>
Product-Review: Ethan Vizitei <evizitei@instructure.com>
2020-03-19 15:55:46 +00:00
Ethan Vizitei 8ce6b785aa enable auto-instrumentation for ddog APM
closes APM-7, APM-8
flag = none

hardcode set to a very low % of client sampling by default
to keep performance impact low.

test plan:
 * make sure telemetry is arriving in datadog APM
 * ensure trace traffic level is low, only from one cluster
     (proves settings are working)
 * canvas should not show degradation in response times post deployment

Change-Id: Ifca8d3f6239d6c4e70098dd2b68b9c2a1950e121
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/230064
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Simon Williams <simon@instructure.com>
QA-Review: Michael Hargiss <mhargiss@instructure.com>
Product-Review: Ethan Vizitei <evizitei@instructure.com>
2020-03-17 19:15:15 +00:00
Jacob Burroughs 93110b44d3 Create a general-purpose in-memory cache
Currently, this just replaces the dynamic_settings cache;
it will also be used to cache things from vault

flag=none

test plan:
- Dynamic settings specs pass

Change-Id: I314a2c377adbcda59d7a7ec2d7522f25a3de08eb
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/224230
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Cody Cutrer <cody@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
2020-01-23 17:11:49 +00:00
Cody Cutrer e285db6d12 bump inst-jobs
closes CORE-2754

Change-Id: I38a255abf0f6ae06d3f9323d7da53239a8ebaf47
Reviewed-on: https://gerrit.instructure.com/202528
Reviewed-by: James Williams <jamesw@instructure.com>
QA-Review: James Williams <jamesw@instructure.com>
Product-Review: James Williams <jamesw@instructure.com>
Tested-by: Jenkins
2019-07-25 18:51:34 +00:00
Cody Cutrer 707f798eaf allow configuring the default service tree for consul
Change-Id: Ic14fd4cf7326a88e5199e4ee1c0fb71a7d7598d0
Reviewed-on: https://gerrit.instructure.com/165386
Tested-by: Jenkins
Reviewed-by: James Williams  <jamesw@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
2018-09-27 19:29:49 +00:00
James Williams e293b2ca65 transform id columns when calling pluck on array
Change-Id: I0c8e8417bcead9d9e1243dabae1444fae3e3634b
Reviewed-on: https://gerrit.instructure.com/150278
Reviewed-by: Mysti Sadler <mysti@instructure.com>
Reviewed-by: Cody Cutrer <cody@instructure.com>
Tested-by: Jenkins
Product-Review: James Williams  <jamesw@instructure.com>
QA-Review: James Williams  <jamesw@instructure.com>
2018-05-24 14:42:23 +00:00
Rob Orton 777ba1f30d delete scribd
Change-Id: I20d2b6f522a742d220f4263e4d53353bbd996671
Reviewed-on: https://gerrit.instructure.com/146125
Tested-by: Jenkins
Reviewed-by: Jeremy Stanley <jeremy@instructure.com>
Product-Review: Rob Orton <rob@instructure.com>
QA-Review: Rob Orton <rob@instructure.com>
2018-04-10 17:39:52 +00:00
Cody Cutrer c988523bbe postgres 9.3 is already required
(Canvas won't even boot with an older version)

so remove conditionals for older features

Change-Id: Ied601ef97f527ac93d386a650a1bd23f198dcf04
Reviewed-on: https://gerrit.instructure.com/143634
Reviewed-by: Rob Orton <rob@instructure.com>
Tested-by: Jenkins
Product-Review: Rob Orton <rob@instructure.com>
QA-Review: Rob Orton <rob@instructure.com>
2018-03-14 22:25:58 +00:00
Cody Cutrer 4ab57d6217 use correct syntax for renaming a constraint in postgres
Change-Id: Iee92ce11c4840c7443fc619356141930dcc8f36e
Reviewed-on: https://gerrit.instructure.com/143609
Tested-by: Jenkins
Reviewed-by: James Williams  <jamesw@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
2018-03-14 20:15:31 +00:00
Tucker McKnight 474968d70f spec: Unit tests for find_foreign_key method
Change-Id: I2f33f08c285ca4b9e52d004134a521983ee90f9a
Reviewed-on: https://gerrit.instructure.com/143368
Tested-by: Jenkins
Reviewed-by: Rob Orton <rob@instructure.com>
Product-Review: Tucker McKnight <tmcknight@instructure.com>
QA-Review: Tucker McKnight <tmcknight@instructure.com>
2018-03-14 16:50:28 +00:00
Jacob Fugal 83fed6665c define account method on delayed jobs correctly
test-plan:
- without any other plugin defining `#account` on delayed jobs,
  `job.account` should still exist and should return Account.default
- with some other plugin already defining `#account` on delayed jobs,
  `job.account` should still use the plugin defined behavior

Change-Id: I5c74febd4525b4196e38c632cfb737a97090f704
Reviewed-on: https://gerrit.instructure.com/143005
Tested-by: Jenkins
Reviewed-by: Cody Cutrer <cody@instructure.com>
Reviewed-by: Michael Jasper <mjasper@instructure.com>
QA-Review: Michael Jasper <mjasper@instructure.com>
Product-Review: Jacob Fugal <jacob@instructure.com>
2018-03-08 22:07:01 +00:00
Jonathan Featherstone 88f74435c7 Fix dynamic_settings reload issue
Test Plan:
  * Configure canvas to work with 3rd party service (like address-book)
  * Confirm that canvas can connect to third party service
  * Save or touch any file (IE app/observers/live_events_observer.rb)
  * Reload page, and confirm that canvas can still connect to service

closes RECNVS-246

Change-Id: Ib3a1b12cdc038f90c139e4d4c957e960288b3e9a
Reviewed-on: https://gerrit.instructure.com/138638
Tested-by: Jenkins
Reviewed-by: Jacob Fugal <jacob@instructure.com>
Reviewed-by: Cody Cutrer <cody@instructure.com>
QA-Review: Collin Parrish <cparrish@instructure.com>
Product-Review: Jonathan Featherstone <jfeatherstone@instructure.com>
2018-01-24 21:28:36 +00:00
Cody Cutrer c3bbcdebde be more efficient with consul
fetch the entire tree at once, stuff it all in the cache, and
then only read from the cache (don't read for real, since we want
negative cache effects as well)

Change-Id: I18bfca57dcbeb0c1bbfdc90d210ac8de9290d434
Reviewed-on: https://gerrit.instructure.com/138754
Tested-by: Jenkins
Reviewed-by: Rob Orton <rob@instructure.com>
Reviewed-by: Tyler Pickett <tpickett@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
2018-01-23 17:55:33 +00:00
Cody Cutrer a460fcc37d configure cache store from consul
fixes CNVS-39235

also allow chaining of clusters (to share a cache store among
multiple clusters), and hot-reloading. but do it all carefully so that
if config doesn't change, we don't reconnect, and shared cache stores
are actually shared (not multiple connections)

Change-Id: I2b72472b4d0f4a34619878752801dd5c05a305a8
Reviewed-on: https://gerrit.instructure.com/125833
Tested-by: Jenkins
Reviewed-by: Rob Orton <rob@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
2017-09-13 17:30:48 +00:00
Cody Cutrer 7197e44389 refactor and impove DynamicSettings
closes CNVS-35834

 * allow specifying tree, service, and cluster for consul stuff
 * check multiple consul keys for each setting (cluster, env, region, global)

test plan:
 * an existing consul environment still works

Change-Id: I48e8fadeac2e140973bfc4b41c1cfb386532d15c
Reviewed-on: https://gerrit.instructure.com/125271
Tested-by: Jenkins
Reviewed-by: Rob Orton <rob@instructure.com>
Reviewed-by: Simon Williams <simon@instructure.com>
QA-Review: Tucker McKnight <tmcknight@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
2017-09-12 22:34:21 +00:00
Omar Khan 36c714c7a6 Add Module#class_name
This method is already defined by YARD, but we don't include YARD in our
production dependencies, so we have to reimplement it.

Test plan: check that production builds work

Change-Id: I1dc383b8ca5414a57151ac409795e53932f9cd8a
Reviewed-on: https://gerrit.instructure.com/122078
Reviewed-by: Cody Cutrer <cody@instructure.com>
Reviewed-by: Jon Jensen <jon@instructure.com>
Product-Review: Jon Jensen <jon@instructure.com>
QA-Review: Jon Jensen <jon@instructure.com>
Tested-by: Jenkins
2017-08-09 14:58:45 +00:00
Cody Cutrer f5fbc0b69d spec: mocha => rspec-mocks for initializers
Change-Id: Icaf253908a7b66c80878ca133bd758d52dfe5447
Reviewed-on: https://gerrit.instructure.com/120500
Tested-by: Jenkins
Reviewed-by: Rob Orton <rob@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
2017-07-26 00:18:20 +00:00
Cody Cutrer 75c7538888 drop rails 4.2
also, allow rails 5.1

Change-Id: If480c2a2c01a7578552dc70f4bdcf3a46df40e7b
Reviewed-on: https://gerrit.instructure.com/115654
Tested-by: Jenkins
Product-Review: Cody Cutrer <cody@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
Reviewed-by: Tyler Pickett <tpickett@instructure.com>
2017-06-27 15:29:51 +00:00
Tyler Pickett 823cda8924 Move MathMan to being configured by Consul
Fixes: CNVS-35833

There is a lot more than just moving to Consul going on here. The whole
PrefixProxy business wouldn't be required for this change, but it will
be really useful as we move to adding cluster awareness.

Test Plan:
- Have MathMan running
- Update config/consul.yml to enable use_for_svg and
  use_for_mml under the math-man init values key
- Start Canvas
- Build an equation with the rich content editor
- The equation should be rendered as usual.

Change-Id: I650527ebaecb6224c6ee6ba26346d27dee33b9d7
Reviewed-on: https://gerrit.instructure.com/111543
QA-Review: Tucker McKnight <tmcknight@instructure.com>
Tested-by: Jenkins
Reviewed-by: Brent Burgoyne <bburgoyne@instructure.com>
Product-Review: Tyler Pickett <tpickett@instructure.com>
2017-06-26 15:54:38 +00:00
Simon Williams 99f680cb8f support update_all with join and limit
test plan:
- ContentExport.joins(:attachment).where(id: 1).limit(1).
    update_all(updated_at: Time.now.utc) should do the right thing

Change-Id: Ibffb448205a823df23a81dae6200db8cd31baf7d
Reviewed-on: https://gerrit.instructure.com/115785
Reviewed-by: Cody Cutrer <cody@instructure.com>
Tested-by: Jenkins
Product-Review: Simon Williams <simon@instructure.com>
QA-Review: Simon Williams <simon@instructure.com>
2017-06-15 20:41:21 +00:00
Neil Gupta 1e052eae19 Update DueDateCacher to use EffectiveDueDates
fixes CNVS-33651

Test plan:
* Create a course
* Enroll 3 students
* Create 2 assignments with different due dates
* In rails console:
	* Submission.pluck(:assignment_id, :cached_due_date) should return
	  an array of 6 tuples of (assignment id, its due date)
* Create an override for one student on one assignment
* In rails console:
  * Submission.where(
  		assignment_id: <assignment picked above>,
  		user_id: <user picked above>
  	).cached_due_date should equal the override date
* Smoke test grading and viewing students in different places to make
  sure the new dummy submissions aren't breaking anything

Change-Id: Idc2721fd3f05214555db780b452ddf53e67ff404
Reviewed-on: https://gerrit.instructure.com/109027
Tested-by: Jenkins
Reviewed-by: Keith T. Garner <kgarner@instructure.com>
QA-Review: Anju Reddy <areddy@instructure.com>
Product-Review: Keith T. Garner <kgarner@instructure.com>
2017-05-11 20:54:44 +00:00
Landon Wilkins 0ce4a23f58 da licença part 46
add consistent license headers to all source files

Change-Id: If9d3b01addc4fd9c2977bf2402dda57ec622e72f
Reviewed-on: https://gerrit.instructure.com/110151
Tested-by: Jenkins
Reviewed-by: Jon Jensen <jon@instructure.com>
Product-Review: Jon Jensen <jon@instructure.com>
QA-Review: Jon Jensen <jon@instructure.com>
2017-04-28 17:56:22 +00:00
Cody Cutrer a99d2a3bdc spec: don't allow raise_error with no arguments
most of these are simple fixes, but there are a few where the spec has
actually been broken due to underlying API changes, that were masked
due to the generic raise_error matcher

fixes CNVS-35542

Change-Id: I982e7ab9af59101b79fdf6b2e0816b374a6a6d5b
Reviewed-on: https://gerrit.instructure.com/104750
Reviewed-by: Rob Orton <rob@instructure.com>
Tested-by: Jenkins
Product-Review: Jon Jensen <jon@instructure.com>
QA-Review: Jon Jensen <jon@instructure.com>
2017-03-10 21:34:37 +00:00
Cody Cutrer 40aa1e36d8 define json serialization for ActiveSupport::TimeZone
to avoid serializing massive amounts of tz data into audit logs

Change-Id: If9959f461c3e5f992b29e014900bc845b2dcc4a0
Reviewed-on: https://gerrit.instructure.com/104314
Tested-by: Jenkins
Reviewed-by: Simon Williams <simon@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
2017-03-08 16:05:46 +00:00
Cody Cutrer 87375fc3dd rails 5: fix initializer specs
in particular, completely dump the quoting monkeypatch and specs -
we no longer know what column it's quoting for at this level, and
the float problems have long been fixed in rails proper

Change-Id: I9bbd214e6c866fcae1222f368f544f4805aac1cf
Reviewed-on: https://gerrit.instructure.com/103830
Tested-by: Jenkins
Reviewed-by: Simon Williams <simon@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
2017-03-03 15:54:36 +00:00
Jon Jensen c53d8daaa6 Automatically format interpolated numbers, part 2
Fixes CNVS-34757

On the back-end, automatically localize numbers that are part of a
localized string even if the developer has forgotten to do so
explicitly. We already did this for the %{count} placeholder, now
do it for any interpolated number. Any explicitly localized numbers
will be unaffected.

Test plan:
* Confirm localization works as per usual
* Confirm this new behavior works in places where we don't explicitly
  localize the number, e.g. upload a bigger file than is allowed by the
  quota and confirm the error message says something like "file size
  exceeds quota limits: 2,097,152 bytes" (instead of "2097152 bytes")

Change-Id: I6896a2c31b1f6debad96c974b1c8b95f653268d9
Reviewed-on: https://gerrit.instructure.com/101137
Reviewed-by: Simon Williams <simon@instructure.com>
Reviewed-by: Cody Cutrer <cody@instructure.com>
Tested-by: Jenkins
QA-Review: Cemal Aktas <caktas@instructure.com>
Product-Review: Jon Jensen <jon@instructure.com>
2017-02-25 15:00:11 +00:00
Jon Jensen 0c03f0d3f2 spec: fix flaky spec
especially since randomizing db sequences, account ids often have a "99"
in them somewhere, so make sure we're checking the right thing

Change-Id: I3089993ff3028b1c602e718150e31c98c11dee94
Reviewed-on: https://gerrit.instructure.com/103207
Tested-by: Jenkins
Reviewed-by: Landon Wilkins <lwilkins@instructure.com>
Product-Review: Landon Wilkins <lwilkins@instructure.com>
QA-Review: Landon Wilkins <lwilkins@instructure.com>
2017-02-24 21:22:32 +00:00
Brent Burgoyne 53d9788ec4 reduce default precision for I18n.n to 5
based on previous tests we though a default precision of 9 with
insignificant zeros striped was safe, but with large numbers it
breaks down in javascript. for example:

  50000000.12.toFixed(9) // => "50000000.119999997"

after more testing with large numbers a precision of 5 will be safe
and should be sufficient. anything needing more specify an explicit
precision.

fixes CNVS-34986

test plan:
- enter 50000000.12 and other large numbers with decimals in a rubric
- ensure the number gets displayed correctly

Change-Id: I10c115dbcd8232632d2822f5301c5eb161ee019d
Reviewed-on: https://gerrit.instructure.com/102292
Tested-by: Jenkins
Reviewed-by: Matt Berns <mberns@instructure.com>
QA-Review: Cemal Aktas <caktas@instructure.com>
Product-Review: Brent Burgoyne <bburgoyne@instructure.com>
2017-02-16 23:01:54 +00:00
Cody Cutrer e04667a89f rails 5: change alias_method_chain to prepended modules
fixes CNVS-33377, CNVS-33697, CNVS-33699, CNVS-33700, CNVS-33701

Change-Id: I4ed1340a3b1472200ac59ddc4c0f7111e9418db0
Reviewed-on: https://gerrit.instructure.com/101509
Reviewed-by: Simon Williams <simon@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
Tested-by: Jenkins
2017-02-10 19:42:29 +00:00
Jon Jensen 5b544a57cf spec: clean up spec_helper.rb a little bit
baby steps

Change-Id: I70220768acaea672f68c8f33801cd69e10328be5
Reviewed-on: https://gerrit.instructure.com/100276
Tested-by: Jenkins
Reviewed-by: Landon Wilkins <lwilkins@instructure.com>
Product-Review: Landon Wilkins <lwilkins@instructure.com>
QA-Review: Landon Wilkins <lwilkins@instructure.com>
2017-01-24 17:32:32 +00:00
Simon Williams 4a667321c3 spec: switch to regular rspec-mocks `anything`
closes CNVS-33864

test plan: specs pass

Change-Id: Ida6d8adfde3e4c59f40dd876d2f184dc7ae97256
Reviewed-on: https://gerrit.instructure.com/97641
Reviewed-by: Cody Cutrer <cody@instructure.com>
Tested-by: Jenkins
Product-Review: Simon Williams <simon@instructure.com>
QA-Review: Simon Williams <simon@instructure.com>
2017-01-21 04:00:12 +00:00
Simon Williams d3d10e7fd1 spec: convert some uses of `anything` to rspec-mocks
refs CNVS-33864

test plan: specs should pass

Change-Id: I27bb28b7f0076ea6ba01ad7e6a89dbf200b7886d
Reviewed-on: https://gerrit.instructure.com/97638
Tested-by: Jenkins
Reviewed-by: Jon Jensen <jon@instructure.com>
Product-Review: Simon Williams <simon@instructure.com>
QA-Review: Simon Williams <simon@instructure.com>
2017-01-20 21:24:32 +00:00
Simon Williams ece65b5a89 spec: rename the `user` helper to `user_factory`
closes CNVS-34042

test plan: specs should pass

Change-Id: I20709a69f0cb28fb55eba18ca81f89f4d7673b56
Reviewed-on: https://gerrit.instructure.com/98426
Tested-by: Jenkins
Reviewed-by: Landon Wilkins <lwilkins@instructure.com>
Product-Review: Landon Wilkins <lwilkins@instructure.com>
QA-Review: Landon Wilkins <lwilkins@instructure.com>
2016-12-27 20:25:25 +00:00
Cody Cutrer 31845b1e77 i18n numbers ruby backend
fixes CNVS-33187, CNVS-33546

switch existing usage of number_(to|with)_(delimiter|precision|rounded|percentage)
to the new helper, and simplifying local arguments

test plan:
 * have at least 1000 courses, and 1000 files
 * make sure jobs have run to generate the statistics
 * go to /accounts/x/statistics
 * the numbers for course and files should have a thousands delimiter
   (i.e. "1,000", not "1000")

Change-Id: Ica8ccccba478030f5b4712f739b3120192313386
Reviewed-on: https://gerrit.instructure.com/96127
Tested-by: Jenkins
Reviewed-by: Simon Williams <simon@instructure.com>
QA-Review: Benjamin Christian Nelson <bcnelson@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
2016-12-15 22:21:28 +00:00
Nathan Mills a709c8e978 add a class method for asset_string
fixes PLAT-2027

test plan:

specs should pass

Change-Id: I1045a5fc074c4c4a3701e93feb517edbe103ee8c
Reviewed-on: https://gerrit.instructure.com/96938
Tested-by: Jenkins
Reviewed-by: Brad Humphrey <brad@instructure.com>
Reviewed-by: Cody Cutrer <cody@instructure.com>
QA-Review: August Thornton <august@instructure.com>
Product-Review: Nathan Mills <nathanm@instructure.com>
2016-12-07 16:58:27 +00:00
James Williams f23f3b0ff2 remove rails 4.0 support
Change-Id: Id1900160375644ea33badaa9d9f9185fab6b81ac
Reviewed-on: https://gerrit.instructure.com/92726
Reviewed-by: Cody Cutrer <cody@instructure.com>
Tested-by: Jenkins
Product-Review: James Williams  <jamesw@instructure.com>
QA-Review: James Williams  <jamesw@instructure.com>
2016-10-25 17:17:22 +00:00
Jon Jensen 5fd9010263 spec: consistently require webmock
stub out external stuff in specs. once we do so in plugins, we can
change this to `WebMock.disable_net_connect! allow_localhost: true`

previously it would either allow or disallow requests across the board,
depending on which spec files were loaded, which caused flickering
failures.

Change-Id: I1da58596dc7b781710ed615dd700850d3fea555a
Reviewed-on: https://gerrit.instructure.com/92634
Tested-by: Jenkins
Reviewed-by: Landon Wilkins <lwilkins@instructure.com>
Product-Review: Landon Wilkins <lwilkins@instructure.com>
QA-Review: Landon Wilkins <lwilkins@instructure.com>
2016-10-12 21:20:25 +00:00
Cody Cutrer 1a8f9f4bbb centralize locale conversions to locales.yml
refs CNVS-28112

test plan:
 * translations should still be correct, especially check
   - date and time pickers
   - calendar
   - RCE

Change-Id: I283c7eb1ee24bca3878ae331b8419379bef434db
Reviewed-on: https://gerrit.instructure.com/74823
Tested-by: Jenkins
Reviewed-by: Jacob Fugal <jacob@instructure.com>
QA-Review: Jeremy Putnam <jeremyp@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
2016-04-25 22:46:30 +00:00
James Williams 264db4b1b1 remove unnecessary utf8 cleaning on serialized columns
they were all cleaned by the psych migration

closes #CNVS-28871

Change-Id: I788a68900e6e3fc6371331ab9f4bf37035a664c8
Reviewed-on: https://gerrit.instructure.com/77584
Tested-by: Jenkins
Reviewed-by: Cody Cutrer <cody@instructure.com>
Product-Review: James Williams  <jamesw@instructure.com>
QA-Review: James Williams  <jamesw@instructure.com>
2016-04-22 18:20:36 +00:00
Ethan Vizitei 728e91b5f7 allow a file consul fallback for OSS users
closes CNVS-28105

TEST PLAN:
 1) remove consul config file
 2) use a dynamic_settings.yml file
 3) Canvas::DynamicSettings calls should work from the console
    returning the data in the file

Change-Id: I90ee2a3fb3e660ef4f527f23bcf2d5b24db8fad4
Reviewed-on: https://gerrit.instructure.com/74782
Tested-by: Jenkins
Reviewed-by: Simon Williams <simon@instructure.com>
Reviewed-by: Cody Cutrer <cody@instructure.com>
Product-Review: Ethan Vizitei <evizitei@instructure.com>
QA-Review: Ethan Vizitei <evizitei@instructure.com>
2016-03-18 21:04:03 +00:00
Ethan Vizitei c9eae629ed consul caching
closes CNVS-27597

We need to not slam consul for rarely changing data.
the '#find' method still gets the value from consul everytime.
Cache can be infinite or with timeout.

TEST PLAN:
 1) have some data in consul for what the signing secret is for canvas
 2) Make sure to query it (Canvas::Security::ServicesJwt.signing_secret)
 3) change the consul data
 4) query it again, it should not have updated
 5) send a SIGHUP
 6) query it again, it should have changed

Change-Id: I5b923b8e44ab90692e87969c494a7c65fafcad72
Reviewed-on: https://gerrit.instructure.com/73198
Reviewed-by: Cody Cutrer <cody@instructure.com>
Reviewed-by: Brian Palmer <brianp@instructure.com>
Tested-by: Jenkins
Reviewed-by: David Adams <dadams@instructure.com>
QA-Review: Jeremy Putnam <jeremyp@instructure.com>
Product-Review: Simon Williams <simon@instructure.com>
2016-03-01 21:34:32 +00:00
Ethan Vizitei c1e99fe7ee don't swallow errors in temp table finds
before this patch, if you violate a foreign key
while in a temp table transaction, you just
would see the error generated when we fail to drop the
temp table in the ensure block

Change-Id: I7975c5c9cd7101b21452006abb2f30dbc855fa50
Reviewed-on: https://gerrit.instructure.com/72458
Reviewed-by: Ethan Vizitei <evizitei@instructure.com>
Reviewed-by: Cody Cutrer <cody@instructure.com>
Tested-by: Jenkins
Product-Review: Ethan Vizitei <evizitei@instructure.com>
QA-Review: Ethan Vizitei <evizitei@instructure.com>
2016-02-19 00:40:35 +00:00
Ethan Vizitei a0eb64221a yank annoying warning for missing consul config
TEST PLAN:
 1) start canvas with no consul config
 2) no error messages should be logged
Change-Id: I55898e1630b63ca5a96d1d178dba6db66c844fb5
Reviewed-on: https://gerrit.instructure.com/71009
Reviewed-by: Simon Williams <simon@instructure.com>
Reviewed-by: Cody Cutrer <cody@instructure.com>
Tested-by: Jenkins
Product-Review: Ethan Vizitei <evizitei@instructure.com>
QA-Review: Ethan Vizitei <evizitei@instructure.com>
2016-01-27 19:48:24 +00:00
James Williams f62911d1d2 rails 4.2: fix initializer specs
refs #CNVS-26056

Change-Id: I6bd8f15c375afc1bbb49d156949c1a92bd1c01d3
Reviewed-on: https://gerrit.instructure.com/70497
Reviewed-by: Cody Cutrer <cody@instructure.com>
Tested-by: Jenkins
Product-Review: James Williams  <jamesw@instructure.com>
QA-Review: James Williams  <jamesw@instructure.com>
2016-01-20 15:18:12 +00:00
Cody Cutrer ea258aa523 try to catch misuse of find_in_batches_with_temp_table
in Canvas production, pgbouncer uses transaction isolation level
(except when running migrations), so temp tables don't work
(unless you're in a transaction)

Change-Id: Ib87ac3c68ce4c733ca668d26116f0b3bee3ffe7a
Reviewed-on: https://gerrit.instructure.com/69300
Reviewed-by: Rob Orton <rob@instructure.com>
Tested-by: Jenkins
Product-Review: Cody Cutrer <cody@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
2016-01-15 16:46:26 +00:00
James Williams 8a41991d74 rails4.2: replace Relation#scoped
either with Relation#all or Association#scope

refs #CNVS-26056

Change-Id: Ie370a3c47c575007ce3b0ba75a122d854e6f8fbc
Reviewed-on: https://gerrit.instructure.com/69497
Reviewed-by: Cody Cutrer <cody@instructure.com>
Tested-by: Jenkins
Product-Review: James Williams  <jamesw@instructure.com>
QA-Review: James Williams  <jamesw@instructure.com>
2015-12-30 18:42:04 +00:00
James Williams d2833299d7 remove rails 3 support
also add initial rails 4.2 scaffold

refs #CNVS-25988

Change-Id: Ifd7aecaffb6cfc8a3e41bc3fb011fb6ce0664ea6
Reviewed-on: https://gerrit.instructure.com/69129
Tested-by: Jenkins
Reviewed-by: Cody Cutrer <cody@instructure.com>
Product-Review: James Williams  <jamesw@instructure.com>
QA-Review: James Williams  <jamesw@instructure.com>
2015-12-23 21:36:43 +00:00
Jon Jensen 2ffa2075f5 spec: disallow record creation outside spec lifecycle
fixes various brittle specs

Change-Id: Ia595df0865efb3cdfcdd73d62adba9c40cf6f737
Reviewed-on: https://gerrit.instructure.com/68684
Tested-by: Jenkins
Reviewed-by: Jeremy Stanley <jeremy@instructure.com>
Product-Review: Jon Jensen <jon@instructure.com>
QA-Review: Jon Jensen <jon@instructure.com>
2015-12-11 16:36:00 +00:00
Ethan Vizitei be9244a47c add feature flag and dynamic config for RCE service
refs CNVS-24816

create the feature flag and expose it in
the Eportfolios controller

Add a consul docker container to docker-compose.yml,
and a class for consuming settings in consul.

Also, add the ability to init config values
into consul from the consul.yml file

TEST PLAN:
1) edit your consul.yml to look kinda like this:

development:
  host: consul
  port: 8500
  ssl: false
  init_values:
    rich-content-service:
      app-host: rce.docker
      cdn-host: rce.docker

2) go to edit an eportfolio as a logged in user
3) check in js console "ENV.RICH_CONTENT_SERVICE_ENABLED"
4) should be "true" or "false" depending on the feature
flag state for that user's root account
5) with the feature flag on, refresh and check the env
6) should have values in the env for
RICH_CONTENT_APP_HOST and RICH_CONTENT_CDN_HOST

Change-Id: Ic138e24416b2aadd965ce4811d3c56538de391bc
Reviewed-on: https://gerrit.instructure.com/66614
Tested-by: Jenkins
Reviewed-by: Simon Williams <simon@instructure.com>
QA-Review: August Thornton <august@instructure.com>
Product-Review: Ethan Vizitei <evizitei@instructure.com>
2015-12-02 20:32:42 +00:00
Brian Palmer c9973bfa65 spec to prevent libxml-ruby from returning
refs CNVS-22298

Change-Id: I81d37f69ea613c4ca3b1abbfac50d55249c6b4d8
Reviewed-on: https://gerrit.instructure.com/60079
Reviewed-by: Cody Cutrer <cody@instructure.com>
QA-Review: August Thornton <august@instructure.com>
Tested-by: Jenkins
Product-Review: Brian Palmer <brianp@instructure.com>
2015-08-10 20:20:55 +00:00
James Williams 024b81d5f8 rails4: helper/initializer/presenter/misc spec fixes
refs #CNVS-21596

Change-Id: I430704d1f40aa8bcd54072a13ef55aa6a5332dd1
Reviewed-on: https://gerrit.instructure.com/58955
Tested-by: Jenkins
Reviewed-by: Cody Cutrer <cody@instructure.com>
Product-Review: James Williams  <jamesw@instructure.com>
QA-Review: James Williams  <jamesw@instructure.com>
2015-07-22 20:21:09 +00:00
Cody Cutrer 9e353116ce quote table names in joins
refs CNVS-21900

Change-Id: I260c8dbae3c4abd7fe436f2051e1cc852ef1675f
Reviewed-on: https://gerrit.instructure.com/58554
Tested-by: Jenkins
Reviewed-by: Rob Orton <rob@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
2015-07-16 16:35:31 +00:00
Ethan Vizitei c6887533fe Fix linkedin initialization
closes CNVS-21340

this initializer was producing the right keys, but not
 with indifferent access, so string access wasn't working and the
linkedin registered service would just die.

Also fixed a problem in the twitter connector which has the same
issue with running a find at initialization time.

TEST PLAN:
 1) linked in as a registered service should not break horribly
 2) twitter as a registered service should not break horribly

Change-Id: Iaa3a5c7f3f0ac5561079a334493d215399d45d76
Reviewed-on: https://gerrit.instructure.com/57186
Reviewed-by: Cody Cutrer <cody@instructure.com>
QA-Review: August Thornton <august@instructure.com>
Product-Review: Ethan Vizitei <evizitei@instructure.com>
Tested-by: Jenkins
2015-06-25 20:03:49 +00:00
Ethan Vizitei b9fd1bce1c Fix twitter migration for settings
closes CNVS-21297

These settings are referenced everywhere else with "consumer"
prefixes rather than "client" prefixes, this fixes that typo.

Also makes the config hash with indifferent access,
wraps the configuration in a testable object, and
relaxes the twitter gems' requirement for a Proc,
letting it be satisfied with a callable object.

(also started unit tests on that object
since I was touching it anyway and it had none)

TEST PLAN:
 1) twitter as a registered service works

Change-Id: I9daf03547c3e60b99bdd6c24a4c632b0f8b6b091
Reviewed-on: https://gerrit.instructure.com/57074
Tested-by: Jenkins
Reviewed-by: Cody Cutrer <cody@instructure.com>
QA-Review: August Thornton <august@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
2015-06-24 20:22:11 +00:00
Cody Cutrer f23278deb5 backport json encoding patch to rails 3
Change-Id: Ib67ac303727099c686e17e67c8a571f4bd1ec24a
Reviewed-on: https://gerrit.instructure.com/56592
Reviewed-by: Brian Palmer <brianp@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
Tested-by: Jenkins
2015-06-16 19:39:03 +00:00
Cody Cutrer fccbddd9a8 monkeypatch rack fix into rack 1.4.5 on rails 3
Change-Id: Ie69af9d83b28c1aa3704087bee52e1a9fd196801
Reviewed-on: https://gerrit.instructure.com/56591
Tested-by: Jenkins
Reviewed-by: Brian Palmer <brianp@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
2015-06-16 19:11:48 +00:00
Ethan Vizitei a98e2a497e abstract locks for postgres 9.3 specific exclusive locks
closes CNVS-20176

in several places we check the postgresql version to see
if we can use the NO KEY UPDATE lock style.  This abstracts
those checks into one place in our active record initializer.

TEST PLAN:
 1) make sure course enrollments still works, enrolling in a course
   makes use of this directly.
 2) make sure importing a CSV for SIS still works.

Change-Id: Ifc3fe364058e22c75b4fb035695da0a2e5cf066d
Reviewed-on: https://gerrit.instructure.com/53861
Tested-by: Jenkins
Reviewed-by: Cody Cutrer <cody@instructure.com>
QA-Review: August Thornton <august@instructure.com>
Product-Review: Ethan Vizitei <evizitei@instructure.com>
2015-05-12 15:31:13 +00:00
Jeremy Stanley 791ed6205a fix parse_asset_string to work with namespaces
and make module prerequisites endpoint use this function.

test plan:
 - have a quiz in a module that is locked by preceding module
   items with incomplete requirements in a module that requires
   sequential progress
 - navigate to the quiz via the module sequence footer
 - completion prerequisites should be shown

fixes CNVS-20114

Change-Id: I390bc41c2df0d11909502dbba0b9a2b0fa1c96d3
Reviewed-on: https://gerrit.instructure.com/53219
Tested-by: Jenkins
Reviewed-by: James Williams  <jamesw@instructure.com>
QA-Review: Jahnavi Yetukuri <jyetukuri@instructure.com>
Product-Review: Jeremy Stanley <jeremy@instructure.com>
2015-05-01 18:16:37 +00:00
Cody Cutrer 469cd7b7b0 bump i18n gem
Change-Id: Id4861909c0c1fb6a2e53c04ec5f6c1e315ed9595
Reviewed-on: https://gerrit.instructure.com/47747
Reviewed-by: Rob Orton <rob@instructure.com>
Tested-by: Jenkins
QA-Review: August Thornton <august@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
2015-04-17 19:49:17 +00:00
Ethan Vizitei 90aa600ed3 Improve primary key detection for batch finding
refs CNVS-16459

this logic was problematic for cases where we're doing more
manually-constructed select statements that DO indeed
have the primary key in them, but don't manifest them in the
select array the same way a symbol array does when you use
the higher level Model.select(:id, :name).

Here we try to account for cases where we're including the .* finder,
or where the primary key is part of one bigger string, or is prefixed
with the table name, and we need to not use a cursor (an
example would be when running long batch finds on a slave database
where the conflict/resolve cycle will kill any transactions that are
open too long, like very long cursors.)

TEST PLAN:
  ...general regression of finders that pull up many records? Make
  sure we didn't bork anything, but I can't think of an explicit case
  at the feature level that would leverage this correctly.
  We'll be making one such change over in account_reports for the same
  ticket that's ref'd above, so may verify them together?

Change-Id: I732fce10d6f2bbdc63be0d5776d5e05f9fcffcca
Reviewed-on: https://gerrit.instructure.com/50657
Reviewed-by: Cody Cutrer <cody@instructure.com>
Tested-by: Jenkins
Reviewed-by: Jacob Fugal <jacob@instructure.com>
QA-Review: August Thornton <august@instructure.com>
Product-Review: Ethan Vizitei <evizitei@instructure.com>
2015-03-20 22:16:03 +00:00
Jon Jensen 1133bcc4d4 fix runtime i18n scope inference in models
fixes CNVS-17179, CNVS-17182, CNVS-17183, CNVS-17184, CNVS-17195

this was a regression in the i18nliner commit. this fixes anywhere we are
doing I18n.t calls in a model (validations, role names, etc.)

test plan:
1. run canvas w/ optimized js and translations enabled
2. refer to listed tickets and confirm they are working now

Change-Id: Ic84244fef0419eaf6c9656e91f322bda1286dbd3
Reviewed-on: https://gerrit.instructure.com/47391
Reviewed-by: Clay Diffrient <cdiffrient@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
QA-Review: Clare Strong <clare@instructure.com>
Product-Review: Clay Diffrient <cdiffrient@instructure.com>
2015-01-19 22:12:48 +00:00
Michael Nomitch 57fa680652 DA - unions on content_tag and discussion_topic scopes
fixes CNVS-16816

test plan:
  - make sure that the following are properly filtered
    from modules with DA on/off
     - quizzes
     - assignments
     - graded discussions
     - ungraded discusisons
     - wiki pages
  - check for modules index & student progressions page
  - discussion topic index properly filters with DA
    ON and OFF

Change-Id: Id0e2e97d2d876dfb48968163bf140da42183a3c9
Reviewed-on: https://gerrit.instructure.com/45133
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Cody Cutrer <cody@instructure.com>
Reviewed-by: Cameron Sutter <csutter@instructure.com>
QA-Review: Sean Lewis <slewis@instructure.com>
Product-Review: Simon Williams <simon@instructure.com>
2014-12-11 19:05:02 +00:00
Brian Palmer f6900880bf extract delayed_job plugin into separate gem
closes CNVS-15881

This mostly involved adding hooks to the gem for things that we were
directly modifying in Canvas, then hooking into those points in the
canvas config/initializers/delayed_job.rb file.

Periodic jobs scheduling changed a bit as well -- there's no longer
support in the extracted gem for reading a special file under config/,
so I moved our periodic_jobs.rb file to a normal initializer.

test plan: delayed jobs should still work as before, including queuing
jobs, running the worker pool, and in tests.

Change-Id: I9ce57091d18f21f4355011fcb75230193d53facb
Reviewed-on: https://gerrit.instructure.com/42027
Reviewed-by: Cody Cutrer <cody@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
QA-Review: August Thornton <august@instructure.com>
Product-Review: Brian Palmer <brianp@instructure.com>
2014-10-24 20:46:00 +00:00
Cody Cutrer 26115c7423 rspec 3-ify spec/initializers
refs CNVS-16239

Change-Id: Ida6f59824f8171e67f0bf3a02ce88ec6c0b0e9ac
Reviewed-on: https://gerrit.instructure.com/42663
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Braden Anderson <braden@instructure.com>
Product-Review: Braden Anderson <braden@instructure.com>
QA-Review: Braden Anderson <braden@instructure.com>
2014-10-13 23:10:35 +00:00
Cody Cutrer 9d2a1786f6 fix encoding issue in spec for ruby 2.1.3
Change-Id: If2c4b22451272111577f03b891ac91e5a9c01d6b
Reviewed-on: https://gerrit.instructure.com/42283
Reviewed-by: Bryan Madsen <bryan@instructure.com>
Product-Review: Bryan Madsen <bryan@instructure.com>
QA-Review: Bryan Madsen <bryan@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Brian Palmer <brianp@instructure.com>
Reviewed-by: Nick Cloward <ncloward@instructure.com>
Reviewed-by: Rob Orton <rob@instructure.com>
2014-10-08 19:48:23 +00:00
Ethan Vizitei 537d9ff033 Make substring searches for courses more performant
fixes #CNVS-12711

Using three seperate trigram searches
when looking for courses by a name match
is taking more time than we'd like.
This builds an index for all 3 relevant
columns together and reworks the scope
that references them to build a search
clause that takes advantage of that index.

TEST PLAN:
 - no behavior changes, just performance improvements
 - regression test /users/x/manageable_courses api
     endpoint with a name parameter as that's what
     makes the primary use of this query.

Change-Id: Ia645da66f0df1a4cec9298f7fa941fa51de815f4
Reviewed-on: https://gerrit.instructure.com/40507
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Cody Cutrer <cody@instructure.com>
QA-Review: August Thornton <august@instructure.com>
Product-Review: Ethan Vizitei <evizitei@instructure.com>
2014-09-05 21:21:00 +00:00
James Williams 81558f728c remove rails 2 support
closes #CNVS-14261

Change-Id: I1b0e8a4438ab659ecd1ac8462bc3559d810989b3
Reviewed-on: https://gerrit.instructure.com/38744
Reviewed-by: Cody Cutrer <cody@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
2014-08-06 18:16:19 +00:00
Jon Jensen eef510c920 spec: stub test translations
fixes sporadic i18n failures (due to unexpected translations persisting
across tests)

Change-Id: Id7f4f13d8d789797b60c5492e5d37ae8e6aae34e
Reviewed-on: https://gerrit.instructure.com/38606
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Bryan Madsen <bryan@instructure.com>
Product-Review: Bryan Madsen <bryan@instructure.com>
QA-Review: Bryan Madsen <bryan@instructure.com>
2014-08-01 23:42:26 +00:00
Cody Cutrer 45bf5773f3 fix migrations for mysql
fixes CNVS-13306
fixes gh-453

MySQL refuses to change columns that have a foreign key on them

Test plan
- Run the polling migrations on MySQL
- They should migrate the database correctly.

Change-Id: Ib781c5237c0973b254043096e536ac094dd809cf
Reviewed-on: https://gerrit.instructure.com/35511
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Jacob Fugal <jacob@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
2014-07-17 20:38:10 +00:00
Cody Cutrer ed29d9a9cd use a temp table for find_in_batches when select does not include id
also add hash of query to temp table name. this fixes nested
queries, but also defeats query cache getting confused

fixes CNVS-13783

test plan:
 * *don't* have a slave configured in database.yml
 * run the last_user_access report
 * it should work

Change-Id: I6fba9826f6cfee5a2e651157fd898f42c0e1345e
Reviewed-on: https://gerrit.instructure.com/36911
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Rob Orton <rob@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
2014-07-10 18:18:38 +00:00
Brian Palmer 2e6f306172 backport rails4's nullifaction of association scopes on new records
fixes CNVS-13824

test plan:
- with rails3, you should be able to create new course modules without error

Change-Id: I02c38f6d50eff575fc4c7f3371735eaf5d33f332
Reviewed-on: https://gerrit.instructure.com/37165
Reviewed-by: Cody Cutrer <cody@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
QA-Review: Jeremy Putnam <jeremyp@instructure.com>
Product-Review: Brian Palmer <brianp@instructure.com>
2014-07-02 14:46:42 +00:00
Raphael Weiner 66e4ee8e66 create utf8_cleaner gem
test plan:
  * run specs

Change-Id: Ic2a76e3c6290c06f68f06796babbdc5ff3b405d9
Reviewed-on: https://gerrit.instructure.com/29733
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Jacob Fugal <jacob@instructure.com>
QA-Review: August Thornton <august@instructure.com>
Product-Review: Simon Williams <simon@instructure.com>
2014-03-25 21:56:33 +00:00
Jacob Fugal 269ea3ad15 add I18n.qualified_locale
gives a default region-qualified value for any canvas-supported locale.
e.g. if I18n.locale is :en, I18n.qualified_locale is 'en-US'.

Change-Id: Iac5697bde840385fe2d643da5cb80918585113a7
Reviewed-on: https://gerrit.instructure.com/24673
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Simon Williams <simon@instructure.com>
Reviewed-by: Jon Jensen <jon@instructure.com>
Product-Review: Jacob Fugal <jacob@instructure.com>
QA-Review: Jacob Fugal <jacob@instructure.com>
2014-03-08 18:23:02 +00:00
Cody Cutrer e5aa44f6fd fix postgres quoting in rails 3
already fixed, just need to move it out of the CANVAS_RAILS2 branch.

also, we don't care about quoting of money or binary columns, and the
default quoting of them changed from rails 2 to rails 3, so don't test
them

Change-Id: I26a556020ec672ff2818470b503aa9f0961a98e4
Reviewed-on: https://gerrit.instructure.com/30307
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: James Williams  <jamesw@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
2014-03-05 16:21:49 +00:00
James Williams eb6616e31d fix rails2_compatibility_spec for rails 3
still runs :after hooks even though it's pending

Change-Id: Ibb0909084a5f6cc279049d216485db779006b210
Reviewed-on: https://gerrit.instructure.com/30394
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Cody Cutrer <cody@instructure.com>
Product-Review: James Williams  <jamesw@instructure.com>
QA-Review: James Williams  <jamesw@instructure.com>
2014-02-21 19:07:51 +00:00
Cody Cutrer 428dae4e3a spec: quoting spec depends on postgresql
Change-Id: I80aae5323ea184e05e4f83d38c2b1e1936423a38
Reviewed-on: https://gerrit.instructure.com/29262
Reviewed-by: Simon Williams <simon@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
2014-01-24 17:23:19 +00:00
Anthus Williams 40c5c1f5f7 fix for rails3 refactoring of TestUploadedFile
in rails 3, ActionController::TestUploadedFile has
been moved to Rack::Test::UploadedFile. This commit
simply updates uses of TestUploadedFile to work
with this new structure

Change-Id: Ib31159c635f033a13908608dffeea88c8f719086
Reviewed-on: https://gerrit.instructure.com/28234
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Jacob Fugal <jacob@instructure.com>
Product-Review: Anthus Williams <awilliams@instructure.com>
QA-Review: Anthus Williams <awilliams@instructure.com>
2014-01-17 17:53:18 +00:00
Jeremy Stanley 6d22b1f738 fix "invalid byte sequence in US-ASCII" in topic attachment
test plan:
 - create a new discussion
 - attach a non-ASCII file
 - save the discussion
 - it shouldn't explode

Change-Id: I9ada9dbf2bf25e63baab22f6117171436d4808c6
Reviewed-on: https://gerrit.instructure.com/27832
Tested-by: Jenkins <jenkins@instructure.com>
QA-Review: Matt Fairbourn <mfairbourn@instructure.com>
Reviewed-by: Bracken Mosbacker <bracken@instructure.com>
Product-Review: Bracken Mosbacker <bracken@instructure.com>
2013-12-31 21:30:21 +00:00
Jeremy Stanley dd441d0269 patch Rack parse_multipart to fix mobile uploads
test plan:
 - have a Canvas instance that uses local file storage (not S3)
 - acquire an Android app that can talk to this instance
   (the Play Store build will not)
 - ensure the app can upload a file (such as a profile picture)
   to the Canvas instance

fixes CNVS-10065

Change-Id: I942cc60c5a408a064955e0c2f629d4a02d366a5e
Reviewed-on: https://gerrit.instructure.com/27698
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Mark Severson <markse@instructure.com>
Product-Review: Jeremy Stanley <jeremy@instructure.com>
QA-Review: Jeremy Stanley <jeremy@instructure.com>
2013-12-20 03:15:40 +00:00
Rob Orton 9cfd6dc9e1 allow delete all on inner join with aliased scope
test plan
 - specs should pass

Change-Id: I37857a560d3159c77706bfc737e71c7ac62c3428
Reviewed-on: https://gerrit.instructure.com/25771
Reviewed-by: Cody Cutrer <cody@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
Product-Review: Rob Orton <rob@instructure.com>
QA-Review: Rob Orton <rob@instructure.com>
2013-10-29 23:07:47 +00:00
Jacob Fugal 413a384e00 normalize use of Rails.env
fixes CNVS-8751

test-plan:
 - try loading the login form (exercises js_block)
 - try loading /users/<id>/messages

Change-Id: I179174f9686ff8494535a74222d0dbeb7813c563
Reviewed-on: https://gerrit.instructure.com/25008
Product-Review: Jacob Fugal <jacob@instructure.com>
QA-Review: Jacob Fugal <jacob@instructure.com>
Reviewed-by: Nick Cloward <ncloward@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
2013-10-14 20:18:41 +00:00
Jacob Fugal 4520f0043e use rails3 style validate/before_validation
rather than rails2.3 style validate_on_* and before_validation_on_*

fixes CNVS-8752

test-plan: (in script/console)
 - initialize a discussion entry (not yet saved)
 - set entry.depth to DiscussionEntry.max_depth + 1
 - try to save it; should raise an error about the maximum depth
 - set entry.depth to nil
 - save it; should not encounter an error
 - check entry.depth; should be 1
 [this next part seems weird to me, but follows the letter of the code]
 - with the same, no-longer-new entry, set entry.depth to nil
 - try to save it; should not encounter an error
 - check entry.depth; should still be nil

Change-Id: Ia56a7ab17d36698e59fda4b520b07352d61ce02e
Reviewed-on: https://gerrit.instructure.com/24997
Tested-by: Jenkins <jenkins@instructure.com>
QA-Review: Jeremy Putnam <jeremyp@instructure.com>
Reviewed-by: Nick Cloward <ncloward@instructure.com>
Product-Review: Jacob Fugal <jacob@instructure.com>
2013-10-14 19:28:28 +00:00
Brian Palmer 569a4b78ef disable query cache when iterating over the psql cursor
The query string is the same each time, so AR was returning the cached
results.

fixes CNVS-7117

test plan:
* in script/console on your dev box, run:
    User.connection.cache { User.transaction { User.find_each(batch_size: 1) { |u| puts u } } }
  it should print out each user, rather than getting stuck in an infinite loop

Change-Id: Ib30b085618917dad8bf8d6bcc04687e04ac12340
Reviewed-on: https://gerrit.instructure.com/22645
Reviewed-by: Cody Cutrer <cody@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
Product-Review: Brian Palmer <brianp@instructure.com>
QA-Review: Brian Palmer <brianp@instructure.com>
2013-07-25 16:29:15 +00:00
Jacob Fugal d7d25fae04 enforce quoting of values for integer columns
fixes CNVS-5852

if a value has a (approximate) integer representation that's *not* used
by rails' default quoting (e.g. a float, time, etc.) use that
representation rather than issuing an invalid query.

if a value has no appropriate integer representation that's not already
used by rails' default quoting (e.g. a symbol, class, object, etc.),
raise StatementInvalid immediately without actually issuing the invalid
query.

also restructures the Infinity/NaN patch to make it amenable to
"stacking" with this one. its behavior should be unchanged.

test-plan:
 - in script/console, try Course.find_by_id with non-integer values
 - should execute the query with an integer cast if available
   (examples: 1.2 -> 1, '1.2' -> 1, Time.now -> 1369087209, etc.)
 - should raise ActiveRecord::StatementInvalid *without* pinging the
   database if no integer cast is available
   (example: :foo, Course, Object.new)

Change-Id: I100cf6a290397cd56b0136e47e16d38ab075aeb4
Reviewed-on: https://gerrit.instructure.com/20775
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Cody Cutrer <cody@instructure.com>
QA-Review: Jeremy Putnam <jeremyp@instructure.com>
Product-Review: Jacob Fugal <jacob@instructure.com>
2013-05-22 15:44:54 +00:00
Brian Palmer 31f33164b5 remove 1.8 compatibility shims
- update the Gemfile to be 1.9 only, and raise an exception on wrong
  ruby version
- remove RUBY_VERSION checks, replacing with the applicable code
- remove the FasterCSV compatibility shim, just use CSV now

test plan: trying to bundle install on ruby 1.8 or 2.0 should raise an
exception, specs should pass, canvas should work as normal on 1.9

Change-Id: I49088e9d227c59c6d5d5acb417c2df971129474a
Reviewed-on: https://gerrit.instructure.com/19806
Reviewed-by: Cody Cutrer <cody@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
QA-Review: Clare Strong <clare@instructure.com>
Product-Review: Brian Palmer <brianp@instructure.com>
2013-05-03 01:43:52 +00:00
Brian Palmer e1a85c2f5f get rid of transliterate warnings in ruby 1.9
Rails 2.3 decided to warn every time this method is called when on Ruby
1.9 -- and this method is called lots of times every request. We don't
actually put non-ascii text in URLs but I switched to using
I18n.transliterate rather than a no-op anyway, since that's what Rails 3
does.

fixes CNVS-4864

test plan: generating urls from routes should still work (you can test
this by loading most any page in canvas), and you shouldn't see warnings
in the log: "Ruby 1.9 doesn't support Unicode normalization yet"

Change-Id: Ie99425bb04989c3d671e6761ee519f4cce66cd01
Reviewed-on: https://gerrit.instructure.com/18721
Reviewed-by: Cody Cutrer <cody@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
QA-Review: Clare Hetherington <clare@instructure.com>
Product-Review: Brian Palmer <brianp@instructure.com>
2013-03-22 23:03:47 +00:00
Brian Palmer 64741c61b8 patch ERB::Util.html_escape to not print warnings in ruby 1.9
This was spewing mad warnings every time the method was run, because
ruby doesn't like applying the //n regex option to utf-8 strings.

test plan: specs should pass, naming your user to something like "<&>'"
should escape properly on display, same as before.

Change-Id: I72c27fdc1ec025f0707c002f2e38d15cbdf2c61d
Reviewed-on: https://gerrit.instructure.com/18379
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Cody Cutrer <cody@instructure.com>
QA-Review: Brian Palmer <brianp@instructure.com>
2013-03-07 15:44:16 -07:00
Bryan Madsen cfa841e7e4 spec: pend utf8 spec in ruby 1.8
fixes #CNVS-4458

Change-Id: I36000bbabf9535df11e8df10bd106f012f6b35c2
Reviewed-on: https://gerrit.instructure.com/18372
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Brian Palmer <brianp@instructure.com>
QA-Review: Brian Palmer <brianp@instructure.com>
2013-03-06 22:20:03 -07:00
Brian Palmer 54f43dd81d don't raise an error if an uploaded file has no original filename
Browsers tend to send a filename, but some API clients don't.

fixes CNVS-4233

test plan: do a multipart file upload to an api endpoint, such as a sis
api, and leave out the filename=/original/filename component of the
parameter. the upload should still be accepted and no error raised.

Change-Id: I9be8d425693cfb9d8d44644e57358f5dc9cee4c1
Reviewed-on: https://gerrit.instructure.com/18114
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Cody Cutrer <cody@instructure.com>
Reviewed-by: Jacob Fugal <jacob@instructure.com>
QA-Review: Clare Hetherington <clare@instructure.com>
2013-02-28 10:36:39 -07:00
Brian Palmer d7bac4a190 fix for a ruby 1.9 warning message
Backported from ruby 2.0 (and possibly later 1.9 patchlevels) because it
was filling our logs with many millions of warnings. The code was
backported directly, the test was backported with conversion from
minitest -> rspec.

test plan: Delayed jobs that use ruby's net libraries should still work,
such as sending messages, taking web snapshots, etc. You shouldn't see
any further lines like this in the log:

net/protocol.rb:313: warning: regexp match /.../n against to UTF-8 string

Change-Id: Ic29daa4ee9f0587fb2a1ac2968cd08a2f68365a1
Reviewed-on: https://gerrit.instructure.com/17431
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Brian Palmer <brianp@instructure.com>
QA-Review: Brian Palmer <brianp@instructure.com>
2013-02-05 08:32:30 -07:00
Paul Hinze 4de8992575 Rails PG adapter: Properly quote Infinity and NaN
refs CNVS-1368

This backports a Rails 3.1 fix as a monkey patch to our Rails 2.3.X
installation. It should address unquoted instances of Infinity we are
seeing occasionally in web conference queries.

The test plan for this is not UI-based, since I was unable to reproduce
by poking around the BigBlueButton web conferences UI.

Test Plan:
 - Inside a ./script/console, choose a model with a column of type
   "float", like WebConference
 - Try to create it with 0.0/0 and 1.0/0 as the value of that column,
   like BigBlueButtonConference.new(:duration => 0.0/0).save(false)
 - Verify that no database exceptions are thrown

The official Rails commit with this fix is here:

06c23c4c7f

Change-Id: I41141054aa06c88ed121a33e6e2da578ff9be82d
Reviewed-on: https://gerrit.instructure.com/17317
Reviewed-by: Cody Cutrer <cody@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
QA-Review: Clare Hetherington <clare@instructure.com>
2013-01-31 16:07:03 -07:00
Ethan Vizitei b1d8f2ef3b user searching module
refs #CNVS-2326

Added a UserSearch module that provides
and interface for searching across the name,
the email, and the sis id (and the database id),
and added a trigram index on the columns
that will be searched against.

also made a slight refactor to the AR
initializer in order to expose
some of the behavior I wanted more granularly
and added some specs to cover it

fixed a small permissions bug in course.rb
and pulled some scoping out of the courses
controller down into the user search module

TEST PLAN:
  This is currently not accessible from
the site itself, this is just the ground
work for the eventual user search api endpoint.
The code is not called by anything currently in
production either so there is no need for
regression testing.  The one thing to check would
be the creation of new users (and pseudonyms and
communication channels).  There have been new
indexes added to columns on those tables
and there is some documentation indicating
that writing to these indexes can be time
consuming if the data set is quite large.  It
would be worth making sure that there have not
been any unacceptable performance regressions
in the creation of any of those record types in
a database that has a full load of data
(comparable to the production environment)

Change-Id: I8fb13a6ec714f27efc8012c5ed2bed4d963c24e6
Reviewed-on: https://gerrit.instructure.com/16459
Tested-by: Jenkins <jenkins@instructure.com>
QA-Review: Clare Hetherington <clare@instructure.com>
Reviewed-by: Brian Palmer <brianp@instructure.com>
2013-01-21 17:25:32 -07:00