Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

post-into-group #11

Merged
merged 2 commits into from Apr 27, 2012
Jump to file or symbol
Failed to load files and symbols.
+31 −2
Split
View
@@ -13,6 +13,20 @@
require 'builder'
require 'net/ldap'
+# uncomment to debug HTTP traffic
+# class ActiveResource::Connection
+# def configure_http(http)
+# http = apply_ssl_options(http)
+# # Net::HTTP timeouts default to 60 seconds.
+# if @timeout
+# http.open_timeout = @timeout
+# http.read_timeout = @timeout
+# end
+# http.set_debug_output STDOUT
+# http
+# end
+# end
+
module Socialcast
class CLI < Thor
include Thor::Actions
@@ -49,6 +63,7 @@ def authenticate
method_option :url, :type => :string, :desc => '(optional) url to associate to the message'
method_option :message_type, :type => :string, :desc => '(optional) force an alternate message_type'
method_option :attachments, :type => :array, :default => []
+ method_option :group_id, :type => :numeric, :desc => "(optional) ID of group to post into"
def share(message = nil)
message ||= $stdin.read_nonblock(100_000) rescue nil
@@ -67,8 +82,9 @@ def share(message = nil)
end
end
+ ActiveResource::Base.logger = Logger.new(STDOUT) if options[:trace]
Socialcast::Message.configure_from_credentials
- Socialcast::Message.create :body => message, :url => options[:url], :message_type => options[:message_type], :attachment_ids => attachment_ids
+ Socialcast::Message.create :body => message, :url => options[:url], :message_type => options[:message_type], :attachment_ids => attachment_ids, :group_id => options[:group_id]
say "Message has been shared"
end
@@ -1,3 +1,3 @@
module Socialcast
- VERSION = "1.1.1"
+ VERSION = "1.1.2"
end
View
@@ -32,6 +32,19 @@
# See expectations
end
end
+ context 'with a group_id param' do
+ before do
+ Socialcast.stub(:credentials).and_return(YAML.load_file(File.join(File.dirname(__FILE__), 'fixtures', 'credentials.yml')))
+ stub_request(:post, "https://ryan%40socialcast.com:foo@test.staging.socialcast.com/api/messages.json").
+ with(:body => /group\_id\"\:123/).
+ to_return(:status => 200, :body => "", :headers => {})
+
+ Socialcast::CLI.start ['share', 'hi', '--group_id=123']
+ end
+ it 'should send a POST with group_id param == 123' do
+ # See expectations
+ end
+ end
context "with a proxy" do
before do
Socialcast.stub(:credentials).and_return(YAML.load_file(File.join(File.dirname(__FILE__), 'fixtures', 'credentials_with_proxy.yml')))