freelancer 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (205) hide show
  1. data/.gitignore +3 -0
  2. data/Gemfile +14 -0
  3. data/LICENSE +20 -0
  4. data/README.rdoc +56 -0
  5. data/Rakefile +34 -0
  6. data/VERSION +1 -0
  7. data/freelancer.gemspec +299 -0
  8. data/init.rb +2 -0
  9. data/lib/freelancer.rb +59 -0
  10. data/lib/freelancer/api.rb +20 -0
  11. data/lib/freelancer/api/common.rb +58 -0
  12. data/lib/freelancer/api/employer.rb +56 -0
  13. data/lib/freelancer/api/freelancer.rb +36 -0
  14. data/lib/freelancer/api/job.rb +46 -0
  15. data/lib/freelancer/api/message.rb +89 -0
  16. data/lib/freelancer/api/notification.rb +25 -0
  17. data/lib/freelancer/api/payment.rb +123 -0
  18. data/lib/freelancer/api/profile.rb +30 -0
  19. data/lib/freelancer/api/project.rb +133 -0
  20. data/lib/freelancer/api/user.rb +86 -0
  21. data/lib/freelancer/client.rb +152 -0
  22. data/lib/freelancer/extensions/hash.rb +11 -0
  23. data/lib/freelancer/models/address.rb +46 -0
  24. data/lib/freelancer/models/balance.rb +22 -0
  25. data/lib/freelancer/models/bid.rb +41 -0
  26. data/lib/freelancer/models/config_version.rb +21 -0
  27. data/lib/freelancer/models/eligibility.rb +23 -0
  28. data/lib/freelancer/models/job.rb +33 -0
  29. data/lib/freelancer/models/job_category.rb +18 -0
  30. data/lib/freelancer/models/message.rb +32 -0
  31. data/lib/freelancer/models/milestone.rb +57 -0
  32. data/lib/freelancer/models/news.rb +15 -0
  33. data/lib/freelancer/models/notification.rb +15 -0
  34. data/lib/freelancer/models/notification_status.rb +45 -0
  35. data/lib/freelancer/models/project.rb +116 -0
  36. data/lib/freelancer/models/project_budget.rb +21 -0
  37. data/lib/freelancer/models/project_fee.rb +18 -0
  38. data/lib/freelancer/models/project_options.rb +34 -0
  39. data/lib/freelancer/models/rating.rb +21 -0
  40. data/lib/freelancer/models/review.rb +87 -0
  41. data/lib/freelancer/models/transaction.rb +39 -0
  42. data/lib/freelancer/models/user.rb +225 -0
  43. data/lib/freelancer/models/withdrawal.rb +51 -0
  44. data/lib/freelancer/models/withdrawal_fee.rb +39 -0
  45. data/lib/freelancer/support/json_mapper.rb +95 -0
  46. data/test/fixtures/common/get_config_version.json +1 -0
  47. data/test/fixtures/common/get_config_version.xml +5 -0
  48. data/test/fixtures/common/get_pending_feedback.json +1 -0
  49. data/test/fixtures/common/get_pending_feedback.xml +20 -0
  50. data/test/fixtures/common/get_terms.json +1 -0
  51. data/test/fixtures/common/get_terms.xml +4 -0
  52. data/test/fixtures/common/post_feedback.json +1 -0
  53. data/test/fixtures/common/post_feedback.xml +4 -0
  54. data/test/fixtures/common/post_reply_for_feedback.json +1 -0
  55. data/test/fixtures/common/post_reply_for_feedback.xml +4 -0
  56. data/test/fixtures/common/request_cancel_project.json +1 -0
  57. data/test/fixtures/common/request_cancel_project.xml +4 -0
  58. data/test/fixtures/common/request_withdraw_feedback.json +1 -0
  59. data/test/fixtures/common/request_withdraw_feedback.xml +4 -0
  60. data/test/fixtures/employer/choose_winner_for_project.json +1 -0
  61. data/test/fixtures/employer/choose_winner_for_project.xml +3 -0
  62. data/test/fixtures/employer/delete_draft_project.json +1 -0
  63. data/test/fixtures/employer/delete_draft_project.xml +4 -0
  64. data/test/fixtures/employer/eligible_for_trial_project.json +1 -0
  65. data/test/fixtures/employer/eligible_for_trial_project.xml +5 -0
  66. data/test/fixtures/employer/get_posted_project_list.json +1 -0
  67. data/test/fixtures/employer/get_posted_project_list.xml +38 -0
  68. data/test/fixtures/employer/invite_user_for_project.json +1 -0
  69. data/test/fixtures/employer/invite_user_for_project.xml +4 -0
  70. data/test/fixtures/employer/post_new_draft_project.json +1 -0
  71. data/test/fixtures/employer/post_new_draft_project.xml +5 -0
  72. data/test/fixtures/employer/post_new_project.json +1 -0
  73. data/test/fixtures/employer/post_new_project.xml +5 -0
  74. data/test/fixtures/employer/post_new_trial_project.json +1 -0
  75. data/test/fixtures/employer/post_new_trial_project.xml +5 -0
  76. data/test/fixtures/employer/publish_draft_project.json +1 -0
  77. data/test/fixtures/employer/publish_draft_project.xml +4 -0
  78. data/test/fixtures/employer/update_project_details.json +1 -0
  79. data/test/fixtures/employer/update_project_details.xml +4 -0
  80. data/test/fixtures/employer/upgrade_trial_project.json +1 -0
  81. data/test/fixtures/employer/upgrade_trial_project.xml +4 -0
  82. data/test/fixtures/freelancer/accept_bid_won.json +1 -0
  83. data/test/fixtures/freelancer/accept_bid_won.xml +4 -0
  84. data/test/fixtures/freelancer/get_project_list_for_placed_bids.json +1 -0
  85. data/test/fixtures/freelancer/get_project_list_for_placed_bids.xml +16 -0
  86. data/test/fixtures/freelancer/place_bid_on_project.json +1 -0
  87. data/test/fixtures/freelancer/place_bid_on_project.xml +4 -0
  88. data/test/fixtures/freelancer/retract_bid_from_project.json +1 -0
  89. data/test/fixtures/freelancer/retract_bid_from_project.xml +4 -0
  90. data/test/fixtures/job/get_category_job_list.json +1 -0
  91. data/test/fixtures/job/get_category_job_list.xml +34 -0
  92. data/test/fixtures/job/get_job_list.json +1 -0
  93. data/test/fixtures/job/get_job_list.xml +17 -0
  94. data/test/fixtures/job/get_my_job_list.json +1 -0
  95. data/test/fixtures/job/get_my_job_list.xml +11 -0
  96. data/test/fixtures/message/get_inbox_messages.json +1 -0
  97. data/test/fixtures/message/get_inbox_messages.xml +22 -0
  98. data/test/fixtures/message/get_sent_messages.json +1 -0
  99. data/test/fixtures/message/get_sent_messages.xml +22 -0
  100. data/test/fixtures/message/get_unread_count.json +1 -0
  101. data/test/fixtures/message/get_unread_count.xml +4 -0
  102. data/test/fixtures/message/load_message_thread.json +1 -0
  103. data/test/fixtures/message/load_message_thread.xml +54 -0
  104. data/test/fixtures/message/mark_message_as_read.json +1 -0
  105. data/test/fixtures/message/mark_message_as_read.xml +4 -0
  106. data/test/fixtures/message/send_message.json +1 -0
  107. data/test/fixtures/message/send_message.xml +4 -0
  108. data/test/fixtures/notification/get_news.json +1 -0
  109. data/test/fixtures/notification/get_news.xml +14 -0
  110. data/test/fixtures/notification/get_notification.json +1 -0
  111. data/test/fixtures/notification/get_notification.xml +10 -0
  112. data/test/fixtures/payment/cancel_milestone.json +1 -0
  113. data/test/fixtures/payment/cancel_milestone.xml +4 -0
  114. data/test/fixtures/payment/create_milestone_payment.json +1 -0
  115. data/test/fixtures/payment/create_milestone_payment.xml +4 -0
  116. data/test/fixtures/payment/get_account_balance_status.json +1 -0
  117. data/test/fixtures/payment/get_account_balance_status.xml +12 -0
  118. data/test/fixtures/payment/get_account_milestone_list.json +1 -0
  119. data/test/fixtures/payment/get_account_milestone_list.xml +30 -0
  120. data/test/fixtures/payment/get_account_transaction_list.json +1 -0
  121. data/test/fixtures/payment/get_account_transaction_list.xml +57 -0
  122. data/test/fixtures/payment/get_account_withdrawal_list.json +1 -0
  123. data/test/fixtures/payment/get_account_withdrawal_list.xml +42 -0
  124. data/test/fixtures/payment/get_balance.json +1 -0
  125. data/test/fixtures/payment/get_balance.xml +4 -0
  126. data/test/fixtures/payment/get_project_list_for_transfer.json +1 -0
  127. data/test/fixtures/payment/get_project_list_for_transfer.xml +52 -0
  128. data/test/fixtures/payment/get_withdrawal_fees.json +1 -0
  129. data/test/fixtures/payment/get_withdrawal_fees.xml +41 -0
  130. data/test/fixtures/payment/prepare_transfer.json +1 -0
  131. data/test/fixtures/payment/prepare_transfer.xml +4 -0
  132. data/test/fixtures/payment/release_milestone.json +1 -0
  133. data/test/fixtures/payment/release_milestone.xml +4 -0
  134. data/test/fixtures/payment/request_cancel_withdrawal.json +1 -0
  135. data/test/fixtures/payment/request_cancel_withdrawal.xml +4 -0
  136. data/test/fixtures/payment/request_release_milestone.json +1 -0
  137. data/test/fixtures/payment/request_release_milestone.xml +4 -0
  138. data/test/fixtures/payment/request_withdrawal.json +1 -0
  139. data/test/fixtures/payment/request_withdrawal.xml +6 -0
  140. data/test/fixtures/payment/transfer_money.json +1 -0
  141. data/test/fixtures/payment/transfer_money.xml +4 -0
  142. data/test/fixtures/profile/get_account_details.json +1 -0
  143. data/test/fixtures/profile/get_account_details.xml +71 -0
  144. data/test/fixtures/profile/get_profile_info.json +1 -0
  145. data/test/fixtures/profile/get_profile_info.xml +53 -0
  146. data/test/fixtures/profile/set_profile_info.json +1 -0
  147. data/test/fixtures/profile/set_profile_info.xml +4 -0
  148. data/test/fixtures/project/get_bids_details.json +1 -0
  149. data/test/fixtures/project/get_bids_details.xml +19 -0
  150. data/test/fixtures/project/get_project_budget_config.json +1 -0
  151. data/test/fixtures/project/get_project_budget_config.xml +42 -0
  152. data/test/fixtures/project/get_project_details.json +1 -0
  153. data/test/fixtures/project/get_project_details.xml +78 -0
  154. data/test/fixtures/project/get_project_fees.json +1 -0
  155. data/test/fixtures/project/get_project_fees.xml +31 -0
  156. data/test/fixtures/project/get_public_messages.json +1 -0
  157. data/test/fixtures/project/get_public_messages.xml +27 -0
  158. data/test/fixtures/project/get_sent_messages.xml +22 -0
  159. data/test/fixtures/project/get_unread_count.xml +4 -0
  160. data/test/fixtures/project/load_message_thread.xml +54 -0
  161. data/test/fixtures/project/mark_message_as_read.xml +4 -0
  162. data/test/fixtures/project/post_public_message.json +1 -0
  163. data/test/fixtures/project/post_public_message.xml +4 -0
  164. data/test/fixtures/project/search_projects.json +1 -0
  165. data/test/fixtures/project/search_projects.xml +37 -0
  166. data/test/fixtures/project/send_message.xml +4 -0
  167. data/test/fixtures/user/get_user_details.json +1 -0
  168. data/test/fixtures/user/get_user_details.xml +32 -0
  169. data/test/fixtures/user/get_user_feedback.json +1 -0
  170. data/test/fixtures/user/get_user_feedback.xml +58 -0
  171. data/test/fixtures/user/get_users_by_search.json +1 -0
  172. data/test/fixtures/user/get_users_by_search.xml +26 -0
  173. data/test/freelancer/api/common_api_test.rb +82 -0
  174. data/test/freelancer/api/employer_api_test.rb +105 -0
  175. data/test/freelancer/api/freelancer_api_test.rb +72 -0
  176. data/test/freelancer/api/job_api_test.rb +76 -0
  177. data/test/freelancer/api/message_api_test.rb +144 -0
  178. data/test/freelancer/api/notification_api_test.rb +56 -0
  179. data/test/freelancer/api/payment_api_test.rb +225 -0
  180. data/test/freelancer/api/profile_api_test.rb +54 -0
  181. data/test/freelancer/api/project_api_test.rb +229 -0
  182. data/test/freelancer/api/user_api_test.rb +153 -0
  183. data/test/freelancer/client_test.rb +5 -0
  184. data/test/freelancer/models/balance_test.rb +24 -0
  185. data/test/freelancer/models/bid_test.rb +25 -0
  186. data/test/freelancer/models/config_version.rb +14 -0
  187. data/test/freelancer/models/eligibility_test.rb +14 -0
  188. data/test/freelancer/models/job_category_test.rb +16 -0
  189. data/test/freelancer/models/job_test.rb +19 -0
  190. data/test/freelancer/models/message_test.rb +42 -0
  191. data/test/freelancer/models/milestone_test.rb +21 -0
  192. data/test/freelancer/models/news_test.rb +15 -0
  193. data/test/freelancer/models/notification_test.rb +15 -0
  194. data/test/freelancer/models/project_budget_test.rb +18 -0
  195. data/test/freelancer/models/project_fee_test.rb +17 -0
  196. data/test/freelancer/models/project_test.rb +97 -0
  197. data/test/freelancer/models/review_test.rb +36 -0
  198. data/test/freelancer/models/transaction_test.rb +29 -0
  199. data/test/freelancer/models/user_test.rb +94 -0
  200. data/test/freelancer/models/withdrawal_fee_test.rb +19 -0
  201. data/test/freelancer/models/withdrawal_test.rb +20 -0
  202. data/test/freelancer/oauth_test.rb +112 -0
  203. data/test/freelancer_test.rb +1 -0
  204. data/test/test_helper.rb +42 -0
  205. metadata +427 -0
@@ -0,0 +1,25 @@
1
+ class BidTest < Test::Unit::TestCase
2
+
3
+ context "bid model" do
4
+
5
+ should "create bid list based on json" do
6
+
7
+ bids = Freelancer::Models::Bid.parse_collection(fixture_file("project/get_bids_details.json"), :shift => [ :"json-result", :items ])
8
+ bids.size.should == 1
9
+ bids.first.provider.id.should == 123456
10
+ bids.first.provider.username.should == "test-username"
11
+ bids.first.provider_rating.should == 0
12
+ bids.first.amount.should == 250
13
+ bids.first.milestone.should == "-"
14
+ bids.first.highlighted?.should == false
15
+ bids.first.days.should == 1
16
+ bids.first.description.should == "Test, ignore"
17
+ bids.first.submitted_at.should == Date.parse("2010-08-09 12:28:57")
18
+ bids.first.total_messages.should == 0
19
+ bids.first.unread_messages.should == 0
20
+
21
+ end
22
+
23
+ end
24
+
25
+ end
@@ -0,0 +1,14 @@
1
+ class ConfigVersionTest < Test::Unit::TestCase
2
+
3
+ context "config version model" do
4
+
5
+ should "create config version instance based on JSON" do
6
+
7
+ version = Freelancer::Models::ConfigVersion.parse(fixture_file("common/get_config_version.json"), :shift => :"json-result")
8
+ version.function.should == "withdrawalfee"
9
+ version.version.should == 1
10
+
11
+ end
12
+
13
+ end
14
+ end
@@ -0,0 +1,14 @@
1
+ class EligibilityTest < Test::Unit::TestCase
2
+
3
+ context "eligibility model" do
4
+
5
+ should "create eligibility instance based on JSON" do
6
+
7
+ eligibility = Freelancer::Models::Eligibility.parse(fixture_file("employer/eligible_for_trial_project.json"), :shift => :"json-result")
8
+ eligibility.eligible.should == false
9
+ eligibility.bonus_points.should == 0
10
+
11
+ end
12
+
13
+ end
14
+ end
@@ -0,0 +1,16 @@
1
+ class JobCategoryTest < Test::Unit::TestCase
2
+
3
+ context "job category model" do
4
+
5
+ should "create collection of categories based on JSON" do
6
+
7
+ categories = Freelancer::Models::JobCategory.parse_collection(fixture_file("job/get_category_job_list.json"), :shift => [ :"json-result", :items, :category ])
8
+ categories.size.should == 10
9
+ categories.first.id.should == 1
10
+ categories.first.name.should == "Websites, IT & Software"
11
+ categories.first.jobs.size.should > 0
12
+
13
+ end
14
+
15
+ end
16
+ end
@@ -0,0 +1,19 @@
1
+ class JobTest < Test::Unit::TestCase
2
+
3
+ context "job model" do
4
+
5
+ should "create job list based on JSON" do
6
+
7
+ jobs = Freelancer::Models::Job.parse_collection(fixture_file("job/get_job_list.json"), :shift => [ :"json-result", :items ])
8
+ jobs.size.should == 325
9
+
10
+ jobs.first.id.should == 15
11
+ jobs.first.name.should == ".NET"
12
+ jobs.first.project_count.should == 16
13
+ jobs.first.seo_url.should == "NET"
14
+
15
+ end
16
+
17
+ end
18
+
19
+ end
@@ -0,0 +1,42 @@
1
+ class MessageTest < Test::Unit::TestCase
2
+
3
+ context "message model" do
4
+
5
+ should "create message instances based on json" do
6
+
7
+ messages = Freelancer::Models::Message.parse_collection(fixture_file("project/get_public_messages.json"), :shift => [ :"json-result", :items ])
8
+ messages.size.should == 1
9
+ messages.first.user.id.should == 123456
10
+ messages.first.user.username.should == "test-username"
11
+ messages.first.sent_at.should == Date.parse("2010-08-08 02:14:57")
12
+ messages.first.text.should == "Test"
13
+ messages.first.attachment_url.should == nil
14
+
15
+ end
16
+
17
+ should "create messages based on sent messages json" do
18
+
19
+ messages = Freelancer::Models::Message.parse_collection(fixture_file("message/get_sent_messages.json"), :shift => [ :"json-result", :items ])
20
+ messages.size.should == 2
21
+ messages.first.project_id.should == 281
22
+ messages.first.user.id.should == 123456
23
+ messages.first.user.username.should == "test-username"
24
+ messages.first.text.should == "Test"
25
+
26
+ end
27
+
28
+
29
+ should "create messages based on inbox messages" do
30
+
31
+ messages = Freelancer::Models::Message.parse_collection(fixture_file("message/get_inbox_messages.json"), :shift => [ :"json-result", :items ])
32
+ messages.size.should == 1
33
+ messages.first.id.should == 203
34
+ messages.first.project_id.should == 281
35
+ messages.first.user.username.should == "test-username"
36
+ messages.first.text.should == "Test"
37
+ messages.first.new?.should == true
38
+
39
+ end
40
+
41
+ end
42
+ end
@@ -0,0 +1,21 @@
1
+ class MilestoneTest < Test::Unit::TestCase
2
+
3
+ context "milestone model" do
4
+
5
+ should "create milestone instances based on account milestones" do
6
+
7
+ milestones = Freelancer::Models::Milestone.parse_collection(fixture_file("payment/get_account_milestone_list.json"), :shift => [ :"json-result", :items ])
8
+ milestones.size.should == 1
9
+ milestones.first.id.should == 988
10
+ milestones.first.username.should == "test-username"
11
+ milestones.first.user_id.should == 123456
12
+ milestones.first.made_at.should == Date.parse("2010-08-08 02:00:42")
13
+ milestones.first.project_id.should == 148
14
+ milestones.first.project_name.should == "Test project to get some reviews on my account"
15
+ milestones.first.description.should == "Full payment for completed project"
16
+ milestones.first.amount.should == 25
17
+
18
+ end
19
+
20
+ end
21
+ end
@@ -0,0 +1,15 @@
1
+ class NewsTest < Test::Unit::TestCase
2
+
3
+ context "news model" do
4
+
5
+ should "create news list based on json" do
6
+
7
+ news = Freelancer::Models::News.parse_collection(fixture_file("notification/get_news.json"), :shift => [ :"json-result", :items ])
8
+ news.size.should == 8
9
+ news.first.id.should == 177
10
+ news.first.text.size.should > 10
11
+
12
+ end
13
+
14
+ end
15
+ end
@@ -0,0 +1,15 @@
1
+ class NotificationTest < Test::Unit::TestCase
2
+
3
+ context "notification models" do
4
+
5
+ should "create notification instances based on json" do
6
+
7
+ notifications = Freelancer::Models::Notification.parse_collection(fixture_file("notification/get_notification.json"), :shift => [ :"json-result", :items, :notification ])
8
+ notifications.size.should == 1
9
+ notifications.first.description.should == "Test notification"
10
+ notifications.first.url.should == "http://www.sandbox.freelancer.com/"
11
+
12
+ end
13
+
14
+ end
15
+ end
@@ -0,0 +1,18 @@
1
+ class ProjectBudgetTest < Test::Unit::TestCase
2
+
3
+ context "project budget model" do
4
+
5
+ should "create project budgets based on JSON" do
6
+
7
+ budgets = Freelancer::Models::ProjectBudget.parse_collection(fixture_file("project/get_project_budget_config.json"), :shift => [ :"json-result", :items ])
8
+ budgets.size.should == 6
9
+ budgets.first.id.should == 5
10
+ budgets.first.minimum_budget.should == 30
11
+ budgets.first.maximum_budget.should == 250
12
+ budgets.first.name.should == "simple project"
13
+
14
+ end
15
+
16
+ end
17
+
18
+ end
@@ -0,0 +1,17 @@
1
+ class ProjectFeeTest < Test::Unit::TestCase
2
+
3
+ context "project fee model" do
4
+
5
+ should "create list of project fee instances based on json" do
6
+
7
+ fees = Freelancer::Models::ProjectFee.parse_collection(fixture_file("project/get_project_fees.json"), :shift => [ :"json-result", :items ])
8
+ fees.size.should == 5
9
+ fees.first.project_type.should == "featured_create"
10
+ fees.first.project_description.size.should > 10
11
+ fees.first.fee.should == 19
12
+
13
+ end
14
+
15
+ end
16
+
17
+ end
@@ -0,0 +1,97 @@
1
+ class ProjectTest < Test::Unit::TestCase
2
+
3
+ context "project model" do
4
+
5
+ should "create project instances based on posted project list" do
6
+
7
+ projects = Freelancer::Models::Project.parse_collection(fixture_file("employer/get_posted_project_list.json"), :shift => [ :"json-result", :items ])
8
+ projects.size.should == 2
9
+ projects.first.id.should == 279
10
+ projects.first.name.should == "Test project name"
11
+
12
+ end
13
+
14
+ should "create project instances basd on bid project list" do
15
+
16
+ projects = Freelancer::Models::Project.parse_collection(fixture_file("freelancer/get_project_list_for_placed_bids.json"), :shift => [ :"json-result", :items ])
17
+ projects.size.should == 1
18
+ projects.first.id.should == 191
19
+ projects.first.name.should == "Project for testing"
20
+ projects.first.url.should == "http://www.sandbox.freelancer.com/projects/PHP-NET/Project-for-testing.html"
21
+ projects.first.bids.should == 1
22
+ projects.first.average_bid.should == 250
23
+ projects.first.status.should == "A"
24
+ projects.first.additional_status.should == "Open"
25
+ projects.first.ends_at.should == Date.parse("2010-07-18 00:07:43")
26
+
27
+ end
28
+
29
+ should "create project instances based on project list for transfer" do
30
+
31
+ projects = Freelancer::Models::Project.parse_collection(fixture_file("payment/get_project_list_for_transfer.json"), :shift => [ :"json-result", :items, :project ])
32
+ projects.size.should == 1
33
+ projects.first.id.should == 148
34
+ projects.first.name.should == "Test project to get some reviews on my account"
35
+ projects.first.selected_freelancers.size.should == 1
36
+ projects.first.selected_freelancers.first.id.should == 123456
37
+ projects.first.selected_freelancers.first.username.should == "test-username"
38
+ projects.first.selected_freelancers.first.bid_amount.should == 500
39
+ projects.first.selected_freelancers.first.paid_amount.should == 500
40
+
41
+ end
42
+
43
+ should "create project instances based on search result" do
44
+
45
+ projects = Freelancer::Models::Project.parse_collection(fixture_file("project/search_projects.json"), :shift => [ :"json-result", :items ])
46
+ projects.size.should == 2
47
+ projects.first.id.should == 150
48
+ projects.first.name.should == "Test Freelancer API2"
49
+ projects.first.bids.should == 0
50
+ projects.first.average_bid.should == nil
51
+ projects.first.jobs.should == [ ".NET" ]
52
+ projects.first.starts_at.should == Date.parse("2010-06-06 19:08:32")
53
+ projects.first.time_left.should == "-3 days and -4 hours"
54
+ projects.first.url.should == "http://www.sandbox.freelancer.com/projects/150.html"
55
+
56
+ end
57
+
58
+ should "create project instance based json" do
59
+
60
+ project = Freelancer::Models::Project.parse(fixture_file("project/get_project_details.json"), :shift => [ :"json-result" ])
61
+ project.id.should == 280
62
+ project.name.should == "Test project"
63
+ project.url.should == "http://www.sandbox.freelancer.com/projects/PHP-NET/Test-project.html"
64
+ project.starts_at.should == Date.parse("2010-08-07 21:51:06")
65
+ project.ends_at.should == Date.parse("2010-08-12 21:51:06")
66
+
67
+ project.buyer.id.should == 123456
68
+ project.buyer.username.should == "test-username"
69
+ project.buyer.url.should == "http://www.sandbox.freelancer.com/users/123456.html"
70
+
71
+ project.status.should == "C"
72
+ project.short_description.should == "This is just a test project."
73
+
74
+ project.options.featured?.should == false
75
+ project.options.non_public?.should == false
76
+ project.options.trial?.should == false
77
+ project.options.full_time?.should == false
78
+ project.options.gold_members_only?.should == true
79
+ project.options.hidden_bids?.should == false
80
+
81
+ project.minimum_budget.should == 250
82
+ project.maximum_budget.should == 750
83
+
84
+ project.jobs.should == [ ".NET", "PHP" ]
85
+
86
+ project.bids.should == 1
87
+ project.average_bid.should == 250
88
+
89
+ project.sellers.size.should == 1
90
+ project.sellers.first.id.should == 123456
91
+ project.sellers.first.username.should == "test-username"
92
+ project.sellers.first.award_status.should == "awarded"
93
+
94
+ end
95
+
96
+ end
97
+ end
@@ -0,0 +1,36 @@
1
+ class ReviewTest < Test::Unit::TestCase
2
+
3
+ context "review model" do
4
+
5
+ should "create review instance based on JSON" do
6
+
7
+ reviews = Freelancer::Models::Review.parse_collection(fixture_file("user/get_user_feedback.json"), :shift => [ :user, :totalreviews, :items ])
8
+ reviews.size.should == 1
9
+
10
+ reviews.first.reviewer_username.should == "test-username"
11
+ reviews.first.reviewer_id.should == 123456
12
+ reviews.first.project_name.should == "Test project name"
13
+ reviews.first.project_id.should == 123
14
+ reviews.first.winning_bid.should == 300
15
+ reviews.first.reviewed_at.should == Date.parse("2010-05-24 07:23:18")
16
+ reviews.first.rating.should == 9
17
+ reviews.first.comment.should == "Test comment"
18
+ reviews.first.reply.should == "Test reply"
19
+
20
+ end
21
+
22
+ should "create a list of reviews based on pending feedbacks" do
23
+
24
+ reviews = Freelancer::Models::Review.parse_collection(fixture_file("common/get_pending_feedback.json"), :shift => [ :"json-result", :items ])
25
+ reviews.size.should == 1
26
+ reviews.first.project_id == 280
27
+ reviews.first.user_id.should == 123456
28
+ reviews.first.username.should == "test-username"
29
+ reviews.first.rateable_until.should == Date.parse("2010-11-06 01:53:34")
30
+ reviews.first.status.should == "Paid"
31
+
32
+ end
33
+
34
+ end
35
+
36
+ end
@@ -0,0 +1,29 @@
1
+ class TransactionTest < Test::Unit::TestCase
2
+
3
+ context "transaction model" do
4
+
5
+ should "create a transaction based on account balance JSON" do
6
+
7
+ balance = Freelancer::Models::Transaction.parse(fixture_file("payment/get_account_balance_status.json"), :shift => :"json-result")
8
+ balance.id.should == 987
9
+ balance.user_id.should == 123456
10
+ balance.balance.should == 9717.55
11
+ balance.description.should == "Transfer from test-username for project Test project (Full payment for completed project)"
12
+ balance.made_at.should == Date.parse("08/08/2010 at 1:53 EDT")
13
+
14
+ end
15
+
16
+ should "create list of transaction based on JSON" do
17
+
18
+ transactions = Freelancer::Models::Transaction.parse_collection(fixture_file("payment/get_account_transaction_list.json"), :shift => [ :"json-result", :items ])
19
+ transactions.size.should == 8
20
+
21
+ transactions.first.id.should == 987
22
+ transactions.first.balance.should == 250
23
+ transactions.first.made_at.should == Date.parse("2010-08-08 01:53:33")
24
+ transactions.first.description.should == "Transfer from test-username for project Test project (Full payment for completed project)"
25
+
26
+ end
27
+
28
+ end
29
+ end
@@ -0,0 +1,94 @@
1
+ class UserTest < Test::Unit::TestCase
2
+
3
+ context "user model" do
4
+
5
+ should "create user instance based on JSON" do
6
+
7
+ user = Freelancer::Models::User.parse(fixture_file("user/get_user_details.json"), :shift => :user)
8
+ user.id.should == 123456
9
+ user.username.should == "test-user"
10
+ user.url.should == "http://www.sandbox.freelancer.com/users/123456.html"
11
+ user.logo_url.should == "false"
12
+ user.profile_logo_url.should == "../../img/unknown.png"
13
+ user.registered_at.should == Date.parse("Fri, 04 Jun 2010 17:37:24 -0400")
14
+ user.company.should == "Test Company"
15
+ user.hourly_rate.should == 20
16
+ user.job_types.should == [ "JSP", "Perl", "PHP", "Ruby &amp; Ruby on Rails" ]
17
+ user.gold_status.should == true
18
+
19
+ user.address.country.should == "Norway"
20
+ user.address.city.should == "Oslo"
21
+
22
+ user.rating.average.should == 0
23
+ user.rating.count.should == 0
24
+
25
+ user.provider_rating.average.should == 0
26
+ user.provider_rating.count.should == 0
27
+
28
+ user.buyer_rating.average.should == 0
29
+ user.buyer_rating.count.should == 0
30
+
31
+ end
32
+
33
+ should "create collection of users based on search result" do
34
+
35
+ users = Freelancer::Models::User.parse_collection(fixture_file("user/get_users_by_search.json"), :shift => [ :"json-result", :items ])
36
+ users.size.should == 1
37
+
38
+ users.first.id.should == 123456
39
+ users.first.username.should == "test-username"
40
+ users.first.company.should == nil
41
+ users.first.address.country.should == nil
42
+ users.first.address.city.should == nil
43
+ users.first.average_pricing.should == nil
44
+
45
+ end
46
+
47
+ should "create profile instance based on JSON" do
48
+
49
+ user = Freelancer::Models::User.parse(fixture_file("profile/get_account_details.json"), :shift => :"json-result")
50
+
51
+ user.username.should == "test-username"
52
+ user.id.should == 123456
53
+ user.name.should == "Test User"
54
+ user.company.should == "Test Company"
55
+ user.type_of_work.should == "Both"
56
+ user.picture_url.should == nil
57
+ user.phone_number.should == "4712345678"
58
+ user.fax_number.should == ""
59
+ user.profile_text.should == "Sample profile text"
60
+ user.vision.should == "Sample vision text"
61
+ user.keywords.should == "Sample keyword text"
62
+ user.hourly_rate.should == 20
63
+ user.skills.should == [ "Sample skill 1", "Sample skill 2", "Sample skill 3", "Sample skill 4" ]
64
+ user.qualifications.should == [ "PHP", "Perl", "JSP", "Ruby &amp; Ruby on Rails" ]
65
+
66
+ user.address.street_name.should == "Some Street"
67
+ user.address.street_name_2.should == ""
68
+ user.address.city.should == "Oslo"
69
+ user.address.state.should == ""
70
+ user.address.country.should == "Norway"
71
+ user.address.postal_code.should == "0123"
72
+
73
+ user.notifications.notification_format.should == "text/html"
74
+ user.notifications.email.should == false
75
+ user.notifications.news.should == false
76
+ user.notifications.bid_won.should == true
77
+ user.notifications.bid_placed.should == false
78
+ user.notifications.new_private_message.should == true
79
+
80
+ user.open_buyer_projects.size.should == 0
81
+ user.closed_buyer_projects.size.should == 0
82
+ user.frozen_buyer_projects.size.should == 1
83
+ user.bid_seller_projects.size.should == 0
84
+ user.won_seller_projects.size.should == 0
85
+ user.lost_seller_projects.size.should == 0
86
+ user.frozen_buyer_projects.first.id.should == 123
87
+ user.frozen_buyer_projects.first.name.should == "Test project"
88
+ user.frozen_buyer_projects.first.url.should == "http://www.sandbox.freelancer.com/NET/Test-project.html"
89
+
90
+ end
91
+
92
+ end
93
+
94
+ end