Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Adding ssl support
  • Loading branch information
jc00ke committed Dec 14, 2010
1 parent 0a6042a commit d863bd2
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 4 deletions.
3 changes: 1 addition & 2 deletions .rvmrc
@@ -1,2 +1 @@
rvm_gemset_create_on_use_flag=1
rvm gemset use slurper
rvm --create rbx-head@slurper
16 changes: 14 additions & 2 deletions lib/story.rb
Expand Up @@ -2,11 +2,23 @@

class Story < ActiveResource::Base

def self.yaml
YAML.load_file('slurper_config.yml')
end

def self.config
@@config ||= YAML.load_file('slurper_config.yml')
@@config = yaml
scheme = if !!@@config['ssl']
self.ssl_options = { :verify_mode => OpenSSL::SSL::VERIFY_PEER }
"https"
else
"http"
end
self.site = "#{scheme}://www.pivotaltracker.com/services/v3/projects/#{@@config['project_id']}"
@@config
end

self.site = "http://www.pivotaltracker.com/services/v3/projects/#{config['project_id']}"

headers['X-TrackerToken'] = config.delete("token")

def prepare
Expand Down
4 changes: 4 additions & 0 deletions slurper_config_https.yml
@@ -0,0 +1,4 @@
project_id: 12345 # found in the project settings or address bar in Tracker
token: 123abc123abc123abc123abc # found on your profile page in Tracker
requested_by: Johnny Hashrocket # must be a user on the project
ssl: true # set to true if the project has ssl required
13 changes: 13 additions & 0 deletions spec/story_spec.rb
Expand Up @@ -18,6 +18,19 @@
story.should_receive(:default_requested_by)
story.prepare
end

it "uses http by default" do
Story.site.scheme.should == "http"
Story.yaml['ssl'].should be_nil
end

it "uses https if set in the config" do
Story.stub!(:yaml).and_return(YAML.load_file('slurper_config_https.yml'))
Story.yaml['ssl'].should be_true
Story.config['ssl'].should be_true
Story.site.scheme.should == "https"
Story.ssl_options[:verify_mode].should == 1
end
end

context "requested_by attribute" do
Expand Down

0 comments on commit d863bd2

Please sign in to comment.