public
Rubygem
Description: Take FogBugz offline with you
Clone URL: git://github.com/francois/fogbugz_offline.git
Search Repo:
FogbugzOffline::Commands::Login specifications.

Updated bin/ to call the command.
francois (author)
Thu May 15 13:51:13 -0700 2008
commit  044a17bdfbcc45cce9cd9bdc861b8719a23cbb90
tree    a85721a5b764576695fc3931f095bf388bef5190
parent  8ac223ce4e400667f391c217c4c8be1aa5ad8fab
...
22
23
24
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
25
...
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
0
@@ -22,5 +22,20 @@
0
       puts "Initialized #{url}"
0
     end
0
   end
0
+
0
+ mode("login") do
0
+ argument("url") { required; argument_required; cast :uri }
0
+ def url; params["url"].value; end
0
+
0
+ option("email") { required; argument_required }
0
+ def email; params["email"].value; end
0
+
0
+ option("password") { required; argument_required }
0
+ def password; params["password"].value; end
0
+
0
+ def run
0
+ FogbugzOffline::Commands.login(:url => url, :email => email, :password => password)
0
+ end
0
+ end
0
 }
...
5
6
7
 
 
 
 
8
9
...
5
6
7
8
9
10
11
12
13
0
@@ -5,6 +5,10 @@
0
     def self.init(*args)
0
       FogbugzOffline::Commands::Init.new.run(*args)
0
     end
0
+
0
+ def self.login(*args)
0
+ FogbugzOffline::Commands::Login.new.run(*args)
0
+ end
0
   end
0
 end
...
 
 
 
 
 
 
 
 
 
 
 
 
...
1
2
3
4
5
6
7
8
9
10
11
12
0
@@ -1 +1,13 @@
0
+module FogbugzOffline
0
+ module Commands
0
+ class Login
0
+ def run(args)
0
+ connection = FogbugzOffline.connection_to(args[:url])
0
+ token = connection.login(args[:email], args[:password])
0
+ FogbugzOffline.global.add_token(args[:url], token)
0
+ FogbugzOffline.global.write
0
+ end
0
+ end
0
+ end
0
+end
...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
0
@@ -1 +1,31 @@
0
+require File.dirname(__FILE__) + "/spec_helper"
0
+
0
+describe FogbugzOffline::Commands::Login do
0
+ before do
0
+ @login = FogbugzOffline::Commands::Login.new
0
+ FogbugzOffline.stub!(:global).and_return(@global = stub_everything("global"))
0
+ FogbugzOffline.stub!(:connection_to).and_return(@connection = stub_everything("connection"))
0
+ end
0
+
0
+ it "should grab a Connection from FogbugzOffline#connection_to" do
0
+ FogbugzOffline.should_receive(:connection_to).with("http://fogbugz.project.com/").and_return(@connection)
0
+ @login.run(:url => "http://fogbugz.project.com/", :email => "francois", :password => "my-password")
0
+ end
0
+
0
+ it "should call Connection#login" do
0
+ @connection.should_receive(:login).with("francois", "my-password").and_return("0123456")
0
+ @login.run(:url => "http://my.project.com", :email => "francois", :password => "my-password")
0
+ end
0
+
0
+ it "should record the token in the global configuration" do
0
+ @connection.stub!(:login).and_return("0123")
0
+ @global.should_receive(:add_token).with("http://your.project.com/", "0123")
0
+ @login.run(:url => "http://your.project.com/", :email => "francois", :password => "my-password")
0
+ end
0
+
0
+ it "should write the global configuration" do
0
+ @global.should_receive(:write)
0
+ @login.run(:url => "http://your.project.com/", :email => "francois", :password => "my-password")
0
+ end
0
+end

Comments

    No one has commented yet.