Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge branch 'feature/privatize-gists' of github.com:codebrawl/codebr…

…awl into develop
  • Loading branch information...
commit 9ae2e43261aa64a17311b1d7c911324f3134fd3d 2 parents 7d5bd1a + a83dec6
@jeffkreeftmeijer jeffkreeftmeijer authored
View
1  app/validators/gist_validator.rb
@@ -6,6 +6,7 @@ def validate(document)
gist = Gist.fetch(document.gist_id)
return document.errors[:gist_id] << "does not exist" unless gist.code == 200
return document.errors[:gist_id] << "can't be anonymous" unless gist['user']
+ return document.errors[:gist_id] << "can't be public" if gist['public']
document.errors[:gist_id] << "is not yours" unless document.user.github_id == gist['user']['id']
end
View
6 spec/fixtures/vcr_cassettes/anonymous_gist.yml
@@ -3,8 +3,8 @@
request: !ruby/struct:VCR::Request
method: :get
uri: https://api.github.com:443/gists/1193213
- body: !!null
- headers: !!null
+ body: !!null
+ headers: !!null
response: !ruby/struct:VCR::Response
status: !ruby/struct:VCR::ResponseStatus
code: 200
@@ -24,5 +24,5 @@
- '4993'
content-length:
- '788'
- body: ! '{"description":"","html_url":"https://gist.github.com/1193213","git_pull_url":"git://gist.github.com/1193213.git","forks":[],"user":null,"git_push_url":"git@gist.github.com:1193213.git","updated_at":"2011-09-04T17:48:03Z","public":true,"files":{"gistfile1.txt":{"filename":"gistfile1.txt","raw_url":"https://gist.github.com/raw/1193213/30d74d258442c7c65512eafab474568dd706c430/gistfile1.txt","content":"test","size":4}},"comments":0,"url":"https://api.github.com/gists/1193213","history":[{"version":"29accdac7783c23db83c79ac4439f2fe9d22f2bf","user":null,"url":"https://api.github.com/gists/1193213/29accdac7783c23db83c79ac4439f2fe9d22f2bf","change_status":{"deletions":0,"additions":1,"total":1},"committed_at":"2011-09-04T17:48:03Z"}],"created_at":"2011-09-04T17:48:03Z","id":"1193213"}'
+ body: ! '{"description":"","html_url":"https://gist.github.com/1193213","git_pull_url":"git://gist.github.com/1193213.git","forks":[],"user":null,"git_push_url":"git@gist.github.com:1193213.git","updated_at":"2011-09-04T17:48:03Z","public":false,"files":{"gistfile1.txt":{"filename":"gistfile1.txt","raw_url":"https://gist.github.com/raw/1193213/30d74d258442c7c65512eafab474568dd706c430/gistfile1.txt","content":"test","size":4}},"comments":0,"url":"https://api.github.com/gists/1193213","history":[{"version":"29accdac7783c23db83c79ac4439f2fe9d22f2bf","user":null,"url":"https://api.github.com/gists/1193213/29accdac7783c23db83c79ac4439f2fe9d22f2bf","change_status":{"deletions":0,"additions":1,"total":1},"committed_at":"2011-09-04T17:48:03Z"}],"created_at":"2011-09-04T17:48:03Z","id":"1193213"}'
http_version: '1.1'
View
62 spec/fixtures/vcr_cassettes/existing_gist.yml
@@ -1,55 +1,55 @@
----
-- !ruby/struct:VCR::HTTPInteraction
- request: !ruby/struct:VCR::Request
+---
+- !ruby/struct:VCR::HTTPInteraction
+ request: !ruby/struct:VCR::Request
method: :get
uri: https://api.github.com:443/gists/866948
- body:
- headers:
- response: !ruby/struct:VCR::Response
- status: !ruby/struct:VCR::ResponseStatus
+ body:
+ headers:
+ response: !ruby/struct:VCR::Response
+ status: !ruby/struct:VCR::ResponseStatus
code: 200
message: OK
- headers:
- x-ratelimit-limit:
+ headers:
+ x-ratelimit-limit:
- "5000"
- content-type:
+ content-type:
- application/json
- date:
+ date:
- Sat, 18 Jun 2011 09:39:43 GMT
- server:
+ server:
- nginx/0.7.67
- content-length:
+ content-length:
- "3106"
- x-ratelimit-remaining:
+ x-ratelimit-remaining:
- "4999"
- status:
+ status:
- 200 OK
- body: "{\"description\":\"\",\"html_url\":\"https://gist.github.com/866948\",\"git_push_url\":\"git@gist.github.com:866948.git\",\"comments\":0,\"public\":true,\"history\":[{\"version\":\"f872880cbe1fbc00d2f667a549fc718303ba8e47\",\"url\":\"https://api.github.com/gists/866948/f872880cbe1fbc00d2f667a549fc718303ba8e47\",\"change_status\":{\"deletions\":47,\"additions\":47,\"total\":94},\"committed_at\":\"2011-03-12T01:55:04Z\",\"user\":{\"avatar_url\":\"https://secure.gravatar.com/avatar/a9c5c1b094da12f51a66b43056493222?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png\",\"url\":\"https://api.github.com/users/charlie\",\"login\":\"charlie\",\"id\":1763}},{\"version\":\"cb28fa08d3be86fb95452083bba18e8900c61ff4\",\"url\":\"https://api.github.com/gists/866948/cb28fa08d3be86fb95452083bba18e8900c61ff4\",\"change_status\":{\"deletions\":0,\"additions\":47,\"total\":47},\"committed_at\":\"2011-03-12T01:54:50Z\",\"user\":{\"avatar_url\":\"https://secure.gravatar.com/avatar/a9c5c1b094da12f51a66b43056493222?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png\",\"url\":\"https://api.github.com/users/charlie\",\"login\":\"charlie\",\"id\":1763}}],\"forks\":[],\"url\":\"https://api.github.com/gists/866948\",\"user\":{\"avatar_url\":\"https://secure.gravatar.com/avatar/a9c5c1b094da12f51a66b43056493222?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png\",\"url\":\"https://api.github.com/users/charlie\",\"login\":\"charlie\",\"id\":1763},\"files\":{\"gistfile1.rb\":{\"content\":\"require 'rubygems'\\nrequire \\\"test/unit\\\"\\nrequire \\\"active_record\\\"\\nrequire \\\"sqlite3\\\"\\n\\nmodule Test::Unit\\n class TestCase\\n def setup\\n $VERBOSE = nil\\n ActiveRecord::Base.establish_connection(:adapter => \\\"sqlite3\\\", :database => \\\"./.test.sqlite3\\\")\\n ActiveRecord::Base.logger = Logger.new(File.join(File.dirname(__FILE__), \\\"test.log\\\"))\\n\\n ActiveRecord::Base.silence do\\n ActiveRecord::Migration.verbose = false\\n ActiveRecord::Schema.define :version => 0 do\\n create_table \\\"users\\\", :force => true do |t|\\n t.integer \\\"id\\\"\\n end\\n create_table \\\"toys\\\", :force => true do |t|\\n t.integer \\\"id\\\"\\n t.integer \\\"user_id\\\"\\n t.text \\\"name\\\"\\n t.text \\\"model\\\"\\n end\\n end\\n end\\n end\\n end\\nend\\n\\nclass User < ActiveRecord::Base\\n has_many :toys\\nend\\n\\nclass Toy < ActiveRecord::Base\\n belongs_to :user\\n attr_accessible :name, :model\\nend\\n\\nclass TheTest < Test::Unit::TestCase\\n def test_find_or_create_by_this_and_that\\n u = User.create\\n software_engineer_barbie = u.toys.create(:name => \\\"Barbie\\\", :model => \\\"Software Engineer\\\")\\n result = u.toys.find_or_create_by_name_and_model(\\\"Barbie\\\", \\\"Software Engineer\\\")\\n assert result.id == software_engineer_barbie.id\\n end\\nend\\n\",\"raw_url\":\"https://gist.github.com/raw/866948/c2df47e7228de05a3a2371f28c6bf804603a7ac6/gistfile1.rb\",\"size\":1280,\"filename\":\"gistfile1.rb\"}},\"id\":\"866948\",\"updated_at\":\"2011-03-12T01:55:07Z\",\"created_at\":\"2011-03-12T01:54:50Z\",\"git_pull_url\":\"git://gist.github.com/866948.git\"}"
+ body: "{\"description\":\"\",\"html_url\":\"https://gist.github.com/866948\",\"git_push_url\":\"git@gist.github.com:866948.git\",\"comments\":0,\"public\":false,\"history\":[{\"version\":\"f872880cbe1fbc00d2f667a549fc718303ba8e47\",\"url\":\"https://api.github.com/gists/866948/f872880cbe1fbc00d2f667a549fc718303ba8e47\",\"change_status\":{\"deletions\":47,\"additions\":47,\"total\":94},\"committed_at\":\"2011-03-12T01:55:04Z\",\"user\":{\"avatar_url\":\"https://secure.gravatar.com/avatar/a9c5c1b094da12f51a66b43056493222?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png\",\"url\":\"https://api.github.com/users/charlie\",\"login\":\"charlie\",\"id\":1763}},{\"version\":\"cb28fa08d3be86fb95452083bba18e8900c61ff4\",\"url\":\"https://api.github.com/gists/866948/cb28fa08d3be86fb95452083bba18e8900c61ff4\",\"change_status\":{\"deletions\":0,\"additions\":47,\"total\":47},\"committed_at\":\"2011-03-12T01:54:50Z\",\"user\":{\"avatar_url\":\"https://secure.gravatar.com/avatar/a9c5c1b094da12f51a66b43056493222?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png\",\"url\":\"https://api.github.com/users/charlie\",\"login\":\"charlie\",\"id\":1763}}],\"forks\":[],\"url\":\"https://api.github.com/gists/866948\",\"user\":{\"avatar_url\":\"https://secure.gravatar.com/avatar/a9c5c1b094da12f51a66b43056493222?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png\",\"url\":\"https://api.github.com/users/charlie\",\"login\":\"charlie\",\"id\":1763},\"files\":{\"gistfile1.rb\":{\"content\":\"require 'rubygems'\\nrequire \\\"test/unit\\\"\\nrequire \\\"active_record\\\"\\nrequire \\\"sqlite3\\\"\\n\\nmodule Test::Unit\\n class TestCase\\n def setup\\n $VERBOSE = nil\\n ActiveRecord::Base.establish_connection(:adapter => \\\"sqlite3\\\", :database => \\\"./.test.sqlite3\\\")\\n ActiveRecord::Base.logger = Logger.new(File.join(File.dirname(__FILE__), \\\"test.log\\\"))\\n\\n ActiveRecord::Base.silence do\\n ActiveRecord::Migration.verbose = false\\n ActiveRecord::Schema.define :version => 0 do\\n create_table \\\"users\\\", :force => true do |t|\\n t.integer \\\"id\\\"\\n end\\n create_table \\\"toys\\\", :force => true do |t|\\n t.integer \\\"id\\\"\\n t.integer \\\"user_id\\\"\\n t.text \\\"name\\\"\\n t.text \\\"model\\\"\\n end\\n end\\n end\\n end\\n end\\nend\\n\\nclass User < ActiveRecord::Base\\n has_many :toys\\nend\\n\\nclass Toy < ActiveRecord::Base\\n belongs_to :user\\n attr_accessible :name, :model\\nend\\n\\nclass TheTest < Test::Unit::TestCase\\n def test_find_or_create_by_this_and_that\\n u = User.create\\n software_engineer_barbie = u.toys.create(:name => \\\"Barbie\\\", :model => \\\"Software Engineer\\\")\\n result = u.toys.find_or_create_by_name_and_model(\\\"Barbie\\\", \\\"Software Engineer\\\")\\n assert result.id == software_engineer_barbie.id\\n end\\nend\\n\",\"raw_url\":\"https://gist.github.com/raw/866948/c2df47e7228de05a3a2371f28c6bf804603a7ac6/gistfile1.rb\",\"size\":1280,\"filename\":\"gistfile1.rb\"}},\"id\":\"866948\",\"updated_at\":\"2011-03-12T01:55:07Z\",\"created_at\":\"2011-03-12T01:54:50Z\",\"git_pull_url\":\"git://gist.github.com/866948.git\"}"
http_version: "1.1"
-- !ruby/struct:VCR::HTTPInteraction
- request: !ruby/struct:VCR::Request
+- !ruby/struct:VCR::HTTPInteraction
+ request: !ruby/struct:VCR::Request
method: :get
uri: https://api.github.com:443/gists/866948
- body:
- headers:
- response: !ruby/struct:VCR::Response
- status: !ruby/struct:VCR::ResponseStatus
+ body:
+ headers:
+ response: !ruby/struct:VCR::Response
+ status: !ruby/struct:VCR::ResponseStatus
code: 200
message: OK
- headers:
- x-ratelimit-limit:
+ headers:
+ x-ratelimit-limit:
- "5000"
- content-type:
+ content-type:
- application/json
- date:
+ date:
- Sat, 18 Jun 2011 09:39:44 GMT
- server:
+ server:
- nginx/0.7.67
- content-length:
+ content-length:
- "3106"
- x-ratelimit-remaining:
+ x-ratelimit-remaining:
- "4998"
- status:
+ status:
- 200 OK
- body: "{\"description\":\"\",\"comments\":0,\"public\":true,\"history\":[{\"change_status\":{\"deletions\":47,\"additions\":47,\"total\":94},\"committed_at\":\"2011-03-12T01:55:04Z\",\"version\":\"f872880cbe1fbc00d2f667a549fc718303ba8e47\",\"url\":\"https://api.github.com/gists/866948/f872880cbe1fbc00d2f667a549fc718303ba8e47\",\"user\":{\"url\":\"https://api.github.com/users/charlie\",\"avatar_url\":\"https://secure.gravatar.com/avatar/a9c5c1b094da12f51a66b43056493222?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png\",\"id\":1763,\"login\":\"charlie\"}},{\"change_status\":{\"deletions\":0,\"additions\":47,\"total\":47},\"committed_at\":\"2011-03-12T01:54:50Z\",\"version\":\"cb28fa08d3be86fb95452083bba18e8900c61ff4\",\"url\":\"https://api.github.com/gists/866948/cb28fa08d3be86fb95452083bba18e8900c61ff4\",\"user\":{\"url\":\"https://api.github.com/users/charlie\",\"avatar_url\":\"https://secure.gravatar.com/avatar/a9c5c1b094da12f51a66b43056493222?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png\",\"id\":1763,\"login\":\"charlie\"}}],\"forks\":[],\"html_url\":\"https://gist.github.com/866948\",\"url\":\"https://api.github.com/gists/866948\",\"git_pull_url\":\"git://gist.github.com/866948.git\",\"user\":{\"url\":\"https://api.github.com/users/charlie\",\"avatar_url\":\"https://secure.gravatar.com/avatar/a9c5c1b094da12f51a66b43056493222?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png\",\"id\":1763,\"login\":\"charlie\"},\"files\":{\"gistfile1.rb\":{\"content\":\"require 'rubygems'\\nrequire \\\"test/unit\\\"\\nrequire \\\"active_record\\\"\\nrequire \\\"sqlite3\\\"\\n\\nmodule Test::Unit\\n class TestCase\\n def setup\\n $VERBOSE = nil\\n ActiveRecord::Base.establish_connection(:adapter => \\\"sqlite3\\\", :database => \\\"./.test.sqlite3\\\")\\n ActiveRecord::Base.logger = Logger.new(File.join(File.dirname(__FILE__), \\\"test.log\\\"))\\n\\n ActiveRecord::Base.silence do\\n ActiveRecord::Migration.verbose = false\\n ActiveRecord::Schema.define :version => 0 do\\n create_table \\\"users\\\", :force => true do |t|\\n t.integer \\\"id\\\"\\n end\\n create_table \\\"toys\\\", :force => true do |t|\\n t.integer \\\"id\\\"\\n t.integer \\\"user_id\\\"\\n t.text \\\"name\\\"\\n t.text \\\"model\\\"\\n end\\n end\\n end\\n end\\n end\\nend\\n\\nclass User < ActiveRecord::Base\\n has_many :toys\\nend\\n\\nclass Toy < ActiveRecord::Base\\n belongs_to :user\\n attr_accessible :name, :model\\nend\\n\\nclass TheTest < Test::Unit::TestCase\\n def test_find_or_create_by_this_and_that\\n u = User.create\\n software_engineer_barbie = u.toys.create(:name => \\\"Barbie\\\", :model => \\\"Software Engineer\\\")\\n result = u.toys.find_or_create_by_name_and_model(\\\"Barbie\\\", \\\"Software Engineer\\\")\\n assert result.id == software_engineer_barbie.id\\n end\\nend\\n\",\"raw_url\":\"https://gist.github.com/raw/866948/c2df47e7228de05a3a2371f28c6bf804603a7ac6/gistfile1.rb\",\"size\":1280,\"filename\":\"gistfile1.rb\"}},\"git_push_url\":\"git@gist.github.com:866948.git\",\"id\":\"866948\",\"updated_at\":\"2011-03-12T01:55:07Z\",\"created_at\":\"2011-03-12T01:54:50Z\"}"
+ body: "{\"description\":\"\",\"comments\":0,\"public\":false,\"history\":[{\"change_status\":{\"deletions\":47,\"additions\":47,\"total\":94},\"committed_at\":\"2011-03-12T01:55:04Z\",\"version\":\"f872880cbe1fbc00d2f667a549fc718303ba8e47\",\"url\":\"https://api.github.com/gists/866948/f872880cbe1fbc00d2f667a549fc718303ba8e47\",\"user\":{\"url\":\"https://api.github.com/users/charlie\",\"avatar_url\":\"https://secure.gravatar.com/avatar/a9c5c1b094da12f51a66b43056493222?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png\",\"id\":1763,\"login\":\"charlie\"}},{\"change_status\":{\"deletions\":0,\"additions\":47,\"total\":47},\"committed_at\":\"2011-03-12T01:54:50Z\",\"version\":\"cb28fa08d3be86fb95452083bba18e8900c61ff4\",\"url\":\"https://api.github.com/gists/866948/cb28fa08d3be86fb95452083bba18e8900c61ff4\",\"user\":{\"url\":\"https://api.github.com/users/charlie\",\"avatar_url\":\"https://secure.gravatar.com/avatar/a9c5c1b094da12f51a66b43056493222?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png\",\"id\":1763,\"login\":\"charlie\"}}],\"forks\":[],\"html_url\":\"https://gist.github.com/866948\",\"url\":\"https://api.github.com/gists/866948\",\"git_pull_url\":\"git://gist.github.com/866948.git\",\"user\":{\"url\":\"https://api.github.com/users/charlie\",\"avatar_url\":\"https://secure.gravatar.com/avatar/a9c5c1b094da12f51a66b43056493222?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png\",\"id\":1763,\"login\":\"charlie\"},\"files\":{\"gistfile1.rb\":{\"content\":\"require 'rubygems'\\nrequire \\\"test/unit\\\"\\nrequire \\\"active_record\\\"\\nrequire \\\"sqlite3\\\"\\n\\nmodule Test::Unit\\n class TestCase\\n def setup\\n $VERBOSE = nil\\n ActiveRecord::Base.establish_connection(:adapter => \\\"sqlite3\\\", :database => \\\"./.test.sqlite3\\\")\\n ActiveRecord::Base.logger = Logger.new(File.join(File.dirname(__FILE__), \\\"test.log\\\"))\\n\\n ActiveRecord::Base.silence do\\n ActiveRecord::Migration.verbose = false\\n ActiveRecord::Schema.define :version => 0 do\\n create_table \\\"users\\\", :force => true do |t|\\n t.integer \\\"id\\\"\\n end\\n create_table \\\"toys\\\", :force => true do |t|\\n t.integer \\\"id\\\"\\n t.integer \\\"user_id\\\"\\n t.text \\\"name\\\"\\n t.text \\\"model\\\"\\n end\\n end\\n end\\n end\\n end\\nend\\n\\nclass User < ActiveRecord::Base\\n has_many :toys\\nend\\n\\nclass Toy < ActiveRecord::Base\\n belongs_to :user\\n attr_accessible :name, :model\\nend\\n\\nclass TheTest < Test::Unit::TestCase\\n def test_find_or_create_by_this_and_that\\n u = User.create\\n software_engineer_barbie = u.toys.create(:name => \\\"Barbie\\\", :model => \\\"Software Engineer\\\")\\n result = u.toys.find_or_create_by_name_and_model(\\\"Barbie\\\", \\\"Software Engineer\\\")\\n assert result.id == software_engineer_barbie.id\\n end\\nend\\n\",\"raw_url\":\"https://gist.github.com/raw/866948/c2df47e7228de05a3a2371f28c6bf804603a7ac6/gistfile1.rb\",\"size\":1280,\"filename\":\"gistfile1.rb\"}},\"git_push_url\":\"git@gist.github.com:866948.git\",\"id\":\"866948\",\"updated_at\":\"2011-03-12T01:55:07Z\",\"created_at\":\"2011-03-12T01:54:50Z\"}"
http_version: "1.1"
View
6 spec/fixtures/vcr_cassettes/random_gist.yml
@@ -3,8 +3,8 @@
request: !ruby/struct:VCR::Request
method: :get
uri: https://api.github.com:443/gists/12345
- body: !!null
- headers: !!null
+ body: !!null
+ headers: !!null
response: !ruby/struct:VCR::Response
status: !ruby/struct:VCR::ResponseStatus
code: 200
@@ -32,5 +32,5 @@
block.\r\n ~ No database.yml file found in /Users/jdempsey/testbed/dm_test/config,
assuming database connection(s) established in the environment file in /Users/jdempsey/testbed/dm_test/config/environments\r\n
~ Checking if we need to use DataMapper sessions\r\n ~ Merb::Orms::DataMapper::Connect
- complete\r\n ~ Compiling routes...\r\n ~ Starting Merb server listening at 0.0.0.0:4000\r\n","size":734,"raw_url":"https://gist.github.com/raw/12345/1380168c2b5ea8616f09eeb50e8c3417e24453a8/gistfile1.txt"}},"html_url":"https://gist.github.com/12345","user":{"url":"https://api.github.com/users/jackdempsey","avatar_url":"https://secure.gravatar.com/avatar/1ccb5123d1af92e24b32cec62abcf9a8?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","login":"jackdempsey","id":479},"public":true,"comments":0,"description":null,"history":[{"version":"a714a381787af0f56e86d12be63e0336bf0eea19","url":"https://api.github.com/gists/12345/a714a381787af0f56e86d12be63e0336bf0eea19","user":null,"change_status":{"deletions":0,"additions":13,"total":13},"committed_at":"2008-09-23T17:13:04Z"}],"id":"12345","updated_at":"2009-10-14T11:53:04Z","created_at":"2008-09-23T17:13:04Z"}'
+ complete\r\n ~ Compiling routes...\r\n ~ Starting Merb server listening at 0.0.0.0:4000\r\n","size":734,"raw_url":"https://gist.github.com/raw/12345/1380168c2b5ea8616f09eeb50e8c3417e24453a8/gistfile1.txt"}},"html_url":"https://gist.github.com/12345","user":{"url":"https://api.github.com/users/jackdempsey","avatar_url":"https://secure.gravatar.com/avatar/1ccb5123d1af92e24b32cec62abcf9a8?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","login":"jackdempsey","id":479},"public":false,"comments":0,"description":null,"history":[{"version":"a714a381787af0f56e86d12be63e0336bf0eea19","url":"https://api.github.com/gists/12345/a714a381787af0f56e86d12be63e0336bf0eea19","user":null,"change_status":{"deletions":0,"additions":13,"total":13},"committed_at":"2008-09-23T17:13:04Z"}],"id":"12345","updated_at":"2009-10-14T11:53:04Z","created_at":"2008-09-23T17:13:04Z"}'
http_version: '1.1'
View
2  spec/lib/gist_spec.rb
@@ -53,7 +53,7 @@
subject{ VCR.use_cassette('random_gist') { Gist.fetch('12345').body } }
it 'should contain the raw response body' do
- should == "{\"git_pull_url\":\"git://gist.github.com/12345.git\",\"url\":\"https://api.github.com/gists/12345\",\"forks\":[],\"git_push_url\":\"git@gist.github.com:12345.git\",\"files\":{\"gistfile1.txt\":{\"filename\":\"gistfile1.txt\",\"content\":\"~/testbed/dm_test $ rake dm:db:database_yaml\\r\\n(in /Users/jdempsey/testbed/dm_test)\\r\\n/Users/jdempsey/testbed/dm_test/config/init.rb:1: warning: already initialized constant KCODE\\r\\n ~ Loaded DEVELOPMENT Environment...\\r\\n ~ loading gem 'merb_datamapper' ...\\r\\n ~ loading gem 'dm-core' ...\\r\\n ~ loading gem 'merb_datamapper' ...\\r\\n ~ Merb::Orms::DataMapper::Connect block.\\r\\n ~ No database.yml file found in /Users/jdempsey/testbed/dm_test/config, assuming database connection(s) established in the environment file in /Users/jdempsey/testbed/dm_test/config/environments\\r\\n ~ Checking if we need to use DataMapper sessions\\r\\n ~ Merb::Orms::DataMapper::Connect complete\\r\\n ~ Compiling routes...\\r\\n ~ Starting Merb server listening at 0.0.0.0:4000\\r\\n\",\"size\":734,\"raw_url\":\"https://gist.github.com/raw/12345/1380168c2b5ea8616f09eeb50e8c3417e24453a8/gistfile1.txt\"}},\"html_url\":\"https://gist.github.com/12345\",\"user\":{\"url\":\"https://api.github.com/users/jackdempsey\",\"avatar_url\":\"https://secure.gravatar.com/avatar/1ccb5123d1af92e24b32cec62abcf9a8?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png\",\"login\":\"jackdempsey\",\"id\":479},\"public\":true,\"comments\":0,\"description\":null,\"history\":[{\"version\":\"a714a381787af0f56e86d12be63e0336bf0eea19\",\"url\":\"https://api.github.com/gists/12345/a714a381787af0f56e86d12be63e0336bf0eea19\",\"user\":null,\"change_status\":{\"deletions\":0,\"additions\":13,\"total\":13},\"committed_at\":\"2008-09-23T17:13:04Z\"}],\"id\":\"12345\",\"updated_at\":\"2009-10-14T11:53:04Z\",\"created_at\":\"2008-09-23T17:13:04Z\"}"
+ should == "{\"git_pull_url\":\"git://gist.github.com/12345.git\",\"url\":\"https://api.github.com/gists/12345\",\"forks\":[],\"git_push_url\":\"git@gist.github.com:12345.git\",\"files\":{\"gistfile1.txt\":{\"filename\":\"gistfile1.txt\",\"content\":\"~/testbed/dm_test $ rake dm:db:database_yaml\\r\\n(in /Users/jdempsey/testbed/dm_test)\\r\\n/Users/jdempsey/testbed/dm_test/config/init.rb:1: warning: already initialized constant KCODE\\r\\n ~ Loaded DEVELOPMENT Environment...\\r\\n ~ loading gem 'merb_datamapper' ...\\r\\n ~ loading gem 'dm-core' ...\\r\\n ~ loading gem 'merb_datamapper' ...\\r\\n ~ Merb::Orms::DataMapper::Connect block.\\r\\n ~ No database.yml file found in /Users/jdempsey/testbed/dm_test/config, assuming database connection(s) established in the environment file in /Users/jdempsey/testbed/dm_test/config/environments\\r\\n ~ Checking if we need to use DataMapper sessions\\r\\n ~ Merb::Orms::DataMapper::Connect complete\\r\\n ~ Compiling routes...\\r\\n ~ Starting Merb server listening at 0.0.0.0:4000\\r\\n\",\"size\":734,\"raw_url\":\"https://gist.github.com/raw/12345/1380168c2b5ea8616f09eeb50e8c3417e24453a8/gistfile1.txt\"}},\"html_url\":\"https://gist.github.com/12345\",\"user\":{\"url\":\"https://api.github.com/users/jackdempsey\",\"avatar_url\":\"https://secure.gravatar.com/avatar/1ccb5123d1af92e24b32cec62abcf9a8?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png\",\"login\":\"jackdempsey\",\"id\":479},\"public\":false,\"comments\":0,\"description\":null,\"history\":[{\"version\":\"a714a381787af0f56e86d12be63e0336bf0eea19\",\"url\":\"https://api.github.com/gists/12345/a714a381787af0f56e86d12be63e0336bf0eea19\",\"user\":null,\"change_status\":{\"deletions\":0,\"additions\":13,\"total\":13},\"committed_at\":\"2008-09-23T17:13:04Z\"}],\"id\":\"12345\",\"updated_at\":\"2009-10-14T11:53:04Z\",\"created_at\":\"2008-09-23T17:13:04Z\"}"
end
end
View
19 spec/validators/gist_validator_spec.rb
@@ -13,7 +13,7 @@ class ObjectWithGist
before do
Gist.stubs(:fetch).returns(
- Gist.new(200, '{"user": {"id": 12345}}')
+ Gist.new(200, '{"public":false, "user": {"id": 12345}}')
)
end
@@ -70,11 +70,26 @@ class ObjectWithGist
end
+ context 'with a public gist' do
+ before do
+ Gist.stubs(:fetch).returns(Gist.new(200, '{"public":true, "user": {"id": 54321}}'))
+ object.valid?
+ end
+
+ it { should have(1).error_on(:gist_id) }
+
+ context 'the error' do
+ subject { object.errors[:gist_id].first }
+
+ it { should == "can't be public" }
+ end
+ end
+
context 'with a gist that does not belong to the user' do
before do
- Gist.stubs(:fetch).returns(Gist.new(200, '{"user": {"id": 54321}}'))
+ Gist.stubs(:fetch).returns(Gist.new(200, '{"public":false, "user": {"id": 54321}}'))
object.valid?
end
Please sign in to comment.
Something went wrong with that request. Please try again.