From 127515f033bc8de778fbb82fa3b51e8e185e2001 Mon Sep 17 00:00:00 2001 From: Nathan Amick Date: Sat, 7 Feb 2015 16:00:14 -0800 Subject: [PATCH] Add sqlite db for testing --- .gitignore | 1 - .travis.yml | 3 +-- README.md | 18 +++++++++--------- spec/dummy/.gitignore | 2 +- spec/dummy/db/test.sqlite3 | Bin 0 -> 28672 bytes 5 files changed, 11 insertions(+), 13 deletions(-) create mode 100644 spec/dummy/db/test.sqlite3 diff --git a/.gitignore b/.gitignore index 9b66bc8..dea279d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,6 @@ .bundle/ log/*.log pkg/ -spec/dummy/db/*.sqlite3 spec/dummy/log/*.log spec/dummy/tmp/ spec/dummy/.sass-cache diff --git a/.travis.yml b/.travis.yml index ec4c2b1..6f1fd69 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,4 @@ language: ruby rvm: - 1.9.3 -before_script: - - cd spec/dummy && bundle exec rake db:test:load && cd - + - 2.1.1 diff --git a/README.md b/README.md index 5e94f39..ee258f0 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ obfuscate_id turns a URL like this: into something like: http://example.com/users/2356513904 - + Sequential ActiveRecord ids become non-sequential, random looking, numeric ids. # post 7000 @@ -22,7 +22,7 @@ Sequential ActiveRecord ids become non-sequential, random looking, numeric ids. http://example.com/posts/7107163820 # post 7002 http://example.com/posts/3296163828 - + ## Why would you want this? If your site is scaling well, you might not want to leak that you are getting 50 new posts a minute. @@ -52,7 +52,7 @@ Run bundler. ## Usage -In your model, add a single line. +In your model, add a single line. class Post < ActiveRecord::Base obfuscate_id @@ -81,6 +81,12 @@ ActiveRecord reverses this obfuscated id back to the plain id before building th * This is not security. obfuscate_id was created to lightly mask record id numbers for the casual user. If you need to really secure your database ids (hint, you probably don't), you need to use real encryption like AES. * To properly generate obfuscated urls, make sure you trigger the model's `to_param` method by passing in the whole object rather than just the id; do this: `post_path(@post)` not this: `post_path(@post.id)`. +## Versions + +This is tested with Rails 4.2.0. For other versions of Rails, please see [the releases](https://github.com/namick/obfuscate_id/releases). + +If you are trying to get it to work with a different version of rails that is not tested, let me know in [the issues](https://github.com/namick/obfuscate_id/issues) + ## Development To run the tests, first clone the repo and run bundler: @@ -89,12 +95,6 @@ To run the tests, first clone the repo and run bundler: cd obfuscate_id bundle install -Change to the dummy rails app and load the test database - - cd spec/dummy - bundle exec rake db:test:load - cd - - Run the tests bundle exec rspec spec diff --git a/spec/dummy/.gitignore b/spec/dummy/.gitignore index 050c9d9..9c6a60a 100644 --- a/spec/dummy/.gitignore +++ b/spec/dummy/.gitignore @@ -8,7 +8,7 @@ /.bundle # Ignore the default SQLite database. -/db/*.sqlite3 +/db/development.sqlite3 /db/*.sqlite3-journal # Ignore all logfiles and tempfiles. diff --git a/spec/dummy/db/test.sqlite3 b/spec/dummy/db/test.sqlite3 new file mode 100644 index 0000000000000000000000000000000000000000..31f3ff06abcb6105ee0883c4f2f8e2f5f97790ba GIT binary patch literal 28672 zcmeI#QESss6bJC6X`3l_se$z3UoJr?~|ZxuYO-`7d{qtXn+O*2tWV=5P$## zAOHafK;VxBrgC0ZUzWsa$@Pc)!^C$_CVUV&N8Gaqo_iSBkvsOog@C->G3#BE^{mEz z&twg2$9%`M>t5Gb%VOHXBpTb$PI(a07c_m8lhqO>B1iVYh%Y?55XjFm=+<91&EHJU zPVK-svIAzdy3Fb|oBDJuE32w1o;^%HHwh_??{!-Zi(c9@Et-2a{}$7H+vD2&!!&jRZby7Lup^BPsTa8(r|{%B9;Czi^pSL# z-CB~}@i>gaT|g^YD$<9;*%F{dCFTkO%SF|BWNA z&8g@|g8&2|009U<00Izz00bZa0SG`~i3L#qFY)GLX%K(_1Rwwb2tWV=5P$##AOL}x z0P27I3J`z*1Rwwb2tWV=5P$##AOL~o7eM{L{CkWQLI45~fB*y_009U<00Izz00iRt zUs65`%7yZkE@%*d00bZa0SG_<0uX=z1Rwwb2;6FcqLk5%a>Xdqsa&f*tv)Gcu0*QF zvr4rn{){{~45L=7+@&>1%DJF?QO=c%TfIOe2LT8`00Izz00bZa0SG_<0ucD`1s+Jc Wn6Cb%R46I`GxsI^&g`jK{r>}OMmER* literal 0 HcmV?d00001