Permalink
Browse files

Use explicit publisher ID

this avoids passing slashes in a URL segment, which has been causing problems when running Relish on apache.
  • Loading branch information...
1 parent ffafb37 commit e2019865a536761fd143be5e2780ddb308b2a8a4 @mattwynne mattwynne committed Jun 25, 2013
Showing with 49 additions and 7 deletions.
  1. +1 −1 Gemfile
  2. +15 −0 lib/relish/commands/handle.rb
  3. +8 −3 lib/relish/commands/projects.rb
  4. +1 −1 lib/relish/version.rb
  5. +1 −2 relish.gemspec
  6. +23 −0 spec/relish/commands/handle_spec.rb
View
@@ -1,4 +1,4 @@
-source :rubygems
+source 'https://rubygems.org'
gemspec
platforms :jruby do
@@ -0,0 +1,15 @@
+module Relish
+ module Commands
+ class Handle
+ def initialize(string)
+ @project_id, @publisher_id = *string.split('/').reverse
+ end
+
+ def resource_url
+ result = "projects/#{@project_id}"
+ result << "?publisher_id=#{@publisher_id}" if @publisher_id
+ result
+ end
+ end
+ end
+end
@@ -1,3 +1,5 @@
+require 'relish/commands/handle'
+
module Relish
module Command
class Projects < Base
@@ -18,14 +20,14 @@ class Projects < Base
usage 'projects:remove <project>'
desc 'remove a project'
command :remove do
- puts resource["projects/#{escape(handle_to_remove)}"].delete
+ puts resource[resource_url(handle_to_remove)].delete
end
usage 'projects:visibility <project>:<public or private>'
desc 'set the status of a project',
'example: relish projects:visibility rspec/rspec-core:private'
command :visibility do
- puts resource["projects/#{escape(handle_to_update)}"].put(
+ puts resource[resource_url(handle_to_update)].put(
:project => { :private => private? }
)
end
@@ -34,7 +36,7 @@ class Projects < Base
desc "rename a project's handle",
'example: relish projects:rename rspec/rspec-core:rspec-corez'
command :rename do
- puts resource["projects/#{escape(handle_to_update)}"].put(
+ puts resource[resource_url(handle_to_update)].put(
:project => { :handle => rename_handle }
)
end
@@ -70,6 +72,9 @@ def private?
@param.extract_option == 'private'
end
+ def resource_url(handle)
+ Commands::Handle.new(handle).resource_url
+ end
end
end
end
View
@@ -1,6 +1,6 @@
module Relish
module Version
- STRING = '0.6'
+ STRING = '0.7'
end
end
View
@@ -7,7 +7,6 @@ Gem::Specification.new do |s|
s.required_rubygems_version = '>= 1.3.5'
s.authors = ["Matt Wynne", "Justin Ko"]
- s.date = Date.today
s.description = %q{Client gem for http://relishapp.com}
s.email = "matt@mattwynne.net"
@@ -30,7 +29,7 @@ Gem::Specification.new do |s|
end
{
- 'bundler' => '~> 1.2.0.pre.1',
+ 'bundler' => '~> 1.3',
'rake' => '~> 0.8.7',
'rspec' => '~> 2.8.0',
'cucumber' => '~> 1.0.2',
@@ -0,0 +1,23 @@
+require 'relish/commands/handle'
+
+module Relish
+ module Commands
+ describe Handle do
+ context "converting to resource URL" do
+ context "with publisher and project id" do
+ handle = Handle.new('foo/bar')
+ it "converts to a URL with a querystring parameter" do
+ handle.resource_url.should == "projects/bar?publisher_id=foo"
+ end
+ end
+
+ context "with project id only" do
+ handle = Handle.new('bar')
+ it "converts to one querystring parameter" do
+ handle.resource_url.should == "projects/bar"
+ end
+ end
+ end
+ end
+ end
+end

0 comments on commit e201986

Please sign in to comment.