Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

cure this test suite's FactoryGirl-itis

  • Loading branch information...
commit 990b3e72a13d56565df32f86b7e331418103ad73 1 parent 1733fcd
@qrush qrush authored
Showing with 483 additions and 481 deletions.
  1. +2 −2 features/step_definitions/clearance/clearance_steps.rb
  2. +2 −2 features/step_definitions/dependency_steps.rb
  3. +4 −4 features/step_definitions/gem_steps.rb
  4. +1 −0  features/support/gemcutter.rb
  5. +14 −14 test/functional/api/v1/activities_controller_test.rb
  6. +4 −4 test/functional/api/v1/api_keys_controller_test.rb
  7. +2 −2 test/functional/api/v1/dependencies_controller_test.rb
  8. +17 −17 test/functional/api/v1/downloads_controller_test.rb
  9. +2 −2 test/functional/api/v1/owners_controller_test.rb
  10. +35 −35 test/functional/api/v1/rubygems_controller_test.rb
  11. +4 −4 test/functional/api/v1/searches_controller_test.rb
  12. +5 −5 test/functional/api/v1/versions/downloads_controller_test.rb
  13. +10 −10 test/functional/api/v1/versions_controller_test.rb
  14. +14 −14 test/functional/api/v1/web_hooks_controller_test.rb
  15. +8 −8 test/functional/dashboards_controller_test.rb
  16. +1 −1  test/functional/home_controller_test.rb
  17. +4 −4 test/functional/profiles_controller_test.rb
  18. +38 −38 test/functional/rubygems_controller_test.rb
  19. +7 −7 test/functional/searches_controller_test.rb
  20. +11 −11 test/functional/stats_controller_test.rb
  21. +11 −11 test/functional/subscriptions_controller_test.rb
  22. +4 −4 test/functional/versions_controller_test.rb
  23. +1 −1  test/shoulda_macros/security.rb
  24. +3 −2 test/test_helper.rb
  25. +12 −12 test/unit/dependency_test.rb
  26. +33 −33 test/unit/download_test.rb
  27. +8 −8 test/unit/helpers/rubygems_helper_test.rb
  28. +6 −6 test/unit/hostess_test.rb
  29. +2 −2 test/unit/linkset_test.rb
  30. +6 −6 test/unit/ownership_test.rb
  31. +5 −5 test/unit/pusher_test.rb
  32. +3 −3 test/unit/rubyforger_test.rb
  33. +68 −68 test/unit/rubygem_test.rb
  34. +1 −1  test/unit/subscription_test.rb
  35. +29 −29 test/unit/user_test.rb
  36. +81 −81 test/unit/version_test.rb
  37. +25 −25 test/unit/web_hook_test.rb
View
4 features/step_definitions/clearance/clearance_steps.rb
@@ -35,11 +35,11 @@
end
Given /^(?:I am|I have|I) signed up (?:as|with) "(.*)"$/ do |email|
- @me = FactoryGirl.create(:user, :email => email)
+ @me = create(:user, :email => email)
end
Given /^a user "([^"]*)" exists without a salt, remember token, or password$/ do |email|
- @me = user = FactoryGirl.create(:user, :email => email)
+ @me = user = create(:user, :email => email)
sql = "update users set salt = NULL, encrypted_password = NULL, remember_token = NULL where id = #{user.id}"
ActiveRecord::Base.connection.update(sql)
end
View
4 features/step_definitions/dependency_steps.rb
@@ -1,10 +1,10 @@
And /the following gem dependencies exist:/ do |table|
table.hashes.each do |hash|
version = Version.find_by_full_name!(hash['Version'])
- rubygem = FactoryGirl.create(:rubygem, :name => hash['Rubygem'])
+ rubygem = create(:rubygem, :name => hash['Rubygem'])
gem_dependency = Gem::Dependency.new(rubygem.name, hash['Requirements'])
- FactoryGirl.create(:dependency, :version => version, :rubygem => rubygem, :gem_dependency => gem_dependency)
+ create(:dependency, :version => version, :rubygem => rubygem, :gem_dependency => gem_dependency)
end
end
View
8 features/step_definitions/gem_steps.rb
@@ -11,8 +11,8 @@
end
Given /^a rubygem exists with name "([^\"]*)" and version "([^\"]*)"$/ do |name, version_number|
- rubygem = FactoryGirl.create(:rubygem, :name => name)
- FactoryGirl.create(:version, :rubygem => rubygem, :number => version_number)
+ rubygem = create(:rubygem, :name => name)
+ create(:version, :rubygem => rubygem, :number => version_number)
end
Given /^I have a gem "([^\"]*)" with version "([^\"]*)" and homepage "([^\"]*)"$/ do |name, version, homepage|
@@ -46,8 +46,8 @@
Given 'the following rubygems exist for "$email":' do |email, table|
user = User.find_by_email! email
table.hashes.each do |row|
- rubygem = FactoryGirl.create(:rubygem, :name => row['name'], :downloads => row['downloads'])
- version = FactoryGirl.create(:version, :rubygem => rubygem)
+ rubygem = create(:rubygem, :name => row['name'], :downloads => row['downloads'])
+ version = create(:version, :rubygem => rubygem)
row['downloads'].to_i.times { Download.incr(rubygem.name, version.full_name) }
rubygem.ownerships.create :user => user
View
1  features/support/gemcutter.rb
@@ -6,6 +6,7 @@
TEST_DIR = File.join('/', 'tmp', 'gemcutter')
require 'factory_girl/step_definitions'
+World(FactoryGirl::Syntax::Methods)
Before do
WebMock.reset!
View
28 test/functional/api/v1/activities_controller_test.rb
@@ -20,15 +20,15 @@ def should_return_just_updated_gems(gems)
context "No signed in-user" do
context "On GET to latest" do
setup do
- @rubygem_1 = FactoryGirl.create(:rubygem)
- @version_1 = FactoryGirl.create(:version, :rubygem => @rubygem_1)
- @version_2 = FactoryGirl.create(:version, :rubygem => @rubygem_1)
+ @rubygem_1 = create(:rubygem)
+ @version_1 = create(:version, :rubygem => @rubygem_1)
+ @version_2 = create(:version, :rubygem => @rubygem_1)
- @rubygem_2 = FactoryGirl.create(:rubygem)
- @version_3 = FactoryGirl.create(:version, :rubygem => @rubygem_2)
+ @rubygem_2 = create(:rubygem)
+ @version_3 = create(:version, :rubygem => @rubygem_2)
- @rubygem_3 = FactoryGirl.create(:rubygem)
- @version_4 = FactoryGirl.create(:version, :rubygem => @rubygem_3)
+ @rubygem_3 = create(:rubygem)
+ @version_4 = create(:version, :rubygem => @rubygem_3)
stub(Rubygem).latest(50){ [@rubygem_2, @rubygem_3] }
end
@@ -52,15 +52,15 @@ def should_return_just_updated_gems(gems)
context "On GET to just_updated" do
setup do
- @rubygem_1 = FactoryGirl.create(:rubygem)
- @version_1 = FactoryGirl.create(:version, :rubygem => @rubygem_1)
- @version_2 = FactoryGirl.create(:version, :rubygem => @rubygem_1)
+ @rubygem_1 = create(:rubygem)
+ @version_1 = create(:version, :rubygem => @rubygem_1)
+ @version_2 = create(:version, :rubygem => @rubygem_1)
- @rubygem_2 = FactoryGirl.create(:rubygem)
- @version_3 = FactoryGirl.create(:version, :rubygem => @rubygem_2)
+ @rubygem_2 = create(:rubygem)
+ @version_3 = create(:version, :rubygem => @rubygem_2)
- @rubygem_3 = FactoryGirl.create(:rubygem)
- @version_4 = FactoryGirl.create(:version, :rubygem => @rubygem_3)
+ @rubygem_3 = create(:rubygem)
+ @version_4 = create(:version, :rubygem => @rubygem_3)
stub(Version).just_updated(50){ [@version_2, @version_3, @version_4] }
end
View
8 test/functional/api/v1/api_keys_controller_test.rb
@@ -28,7 +28,7 @@ def authorize_with(str)
context "on GET to show with bad credentials" do
setup do
- @user = FactoryGirl.create(:user)
+ @user = create(:user)
authorize_with("bad:creds")
get :show
end
@@ -41,7 +41,7 @@ def authorize_with(str)
# this endpoint is used by rubygems
context "on GET to show with TEXT and with confirmed user" do
setup do
- @user = FactoryGirl.create(:user)
+ @user = create(:user)
authorize_with("#{@user.email}:#{@user.password}")
get :show, :format => 'text'
end
@@ -54,7 +54,7 @@ def authorize_with(str)
def self.should_respond_to(format, to_meth = :to_s)
context "with #{format.to_s.upcase} and with confirmed user" do
setup do
- @user = FactoryGirl.create(:user)
+ @user = create(:user)
authorize_with("#{@user.email}:#{@user.password}")
get :show, :format => format
end
@@ -84,7 +84,7 @@ def self.should_respond_to(format, to_meth = :to_s)
context "on PUT to reset with signed in user" do
setup do
- @user = FactoryGirl.create(:user)
+ @user = create(:user)
sign_in_as(@user)
end
should "reset the user's api key" do
View
4 test/functional/api/v1/dependencies_controller_test.rb
@@ -3,8 +3,8 @@
class Api::V1::DependenciesControllerTest < ActionController::TestCase
context "on GET to index" do
setup do
- @versions = [FactoryGirl.create(:version), FactoryGirl.create(:version)].each do |version|
- FactoryGirl.create(:dependency, :version => version)
+ @versions = [create(:version), create(:version)].each do |version|
+ create(:dependency, :version => version)
end
get :index, :gems => @versions.map(&:rubygem).map(&:name).join(',')
end
View
34 test/functional/api/v1/downloads_controller_test.rb
@@ -65,9 +65,9 @@ def self.should_respond_to(format, to_meth = :to_s)
context "on GET to show" do
setup do
- rubygem = FactoryGirl.create(:rubygem_with_downloads)
- @version1 = FactoryGirl.create(:version, :rubygem => rubygem, :number => '1.0.0')
- @version2 = FactoryGirl.create(:version, :rubygem => rubygem, :number => '2.0.0')
+ rubygem = create(:rubygem_with_downloads)
+ @version1 = create(:version, :rubygem => rubygem, :number => '1.0.0')
+ @version2 = create(:version, :rubygem => rubygem, :number => '2.0.0')
Download.incr(rubygem.name, @version1.full_name)
Download.incr(rubygem.name, @version2.full_name)
@@ -128,15 +128,15 @@ def self.should_respond_to(format)
context "On GET to top" do
setup do
- @rubygem_1 = FactoryGirl.create(:rubygem)
- @version_1 = FactoryGirl.create(:version, :rubygem => @rubygem_1)
- @version_2 = FactoryGirl.create(:version, :rubygem => @rubygem_1)
+ @rubygem_1 = create(:rubygem)
+ @version_1 = create(:version, :rubygem => @rubygem_1)
+ @version_2 = create(:version, :rubygem => @rubygem_1)
- @rubygem_2 = FactoryGirl.create(:rubygem)
- @version_3 = FactoryGirl.create(:version, :rubygem => @rubygem_2)
+ @rubygem_2 = create(:rubygem)
+ @version_3 = create(:version, :rubygem => @rubygem_2)
- @rubygem_3 = FactoryGirl.create(:rubygem)
- @version_4 = FactoryGirl.create(:version, :rubygem => @rubygem_3)
+ @rubygem_3 = create(:rubygem)
+ @version_4 = create(:version, :rubygem => @rubygem_3)
3.times { Download.incr(@rubygem_1.name, @version_1.full_name) }
2.times { Download.incr(@rubygem_1.name, @version_2.full_name) }
@@ -160,15 +160,15 @@ def self.should_respond_to(format)
context "On GET to all" do
setup do
- @rubygem_1 = FactoryGirl.create(:rubygem)
- @version_1 = FactoryGirl.create(:version, :rubygem => @rubygem_1)
- @version_2 = FactoryGirl.create(:version, :rubygem => @rubygem_1)
+ @rubygem_1 = create(:rubygem)
+ @version_1 = create(:version, :rubygem => @rubygem_1)
+ @version_2 = create(:version, :rubygem => @rubygem_1)
- @rubygem_2 = FactoryGirl.create(:rubygem)
- @version_3 = FactoryGirl.create(:version, :rubygem => @rubygem_2)
+ @rubygem_2 = create(:rubygem)
+ @version_3 = create(:version, :rubygem => @rubygem_2)
- @rubygem_3 = FactoryGirl.create(:rubygem)
- @version_4 = FactoryGirl.create(:version, :rubygem => @rubygem_3)
+ @rubygem_3 = create(:rubygem)
+ @version_4 = create(:version, :rubygem => @rubygem_3)
3.times { Download.incr(@rubygem_1.name, @version_1.full_name) }
2.times { Download.incr(@rubygem_1.name, @version_2.full_name) }
View
4 test/functional/api/v1/owners_controller_test.rb
@@ -12,8 +12,8 @@ def self.should_respond_to(format)
context "on GET to show with #{format.to_s.upcase}" do
setup do
- @rubygem = FactoryGirl.create(:rubygem)
- @user = FactoryGirl.create(:user)
+ @rubygem = create(:rubygem)
+ @user = create(:user)
@rubygem.ownerships.create(:user => @user)
@request.env["HTTP_AUTHORIZATION"] = @user.api_key
View
70 test/functional/api/v1/rubygems_controller_test.rb
@@ -22,8 +22,8 @@ def self.should_respond_to_show(format, &block)
def self.should_respond_to(format, &block)
context "with #{format.to_s.upcase} for a hosted gem" do
setup do
- @rubygem = FactoryGirl.create(:rubygem)
- FactoryGirl.create(:version, :rubygem => @rubygem)
+ @rubygem = create(:rubygem)
+ create(:version, :rubygem => @rubygem)
get :show, :id => @rubygem.to_param, :format => format
end
@@ -32,8 +32,8 @@ def self.should_respond_to(format, &block)
context "with #{format.to_s.upcase} for a hosted gem with a period in its name" do
setup do
- @rubygem = FactoryGirl.create(:rubygem, :name => 'foo.rb')
- FactoryGirl.create(:version, :rubygem => @rubygem)
+ @rubygem = create(:rubygem, :name => 'foo.rb')
+ create(:version, :rubygem => @rubygem)
get :show, :id => @rubygem.to_param, :format => format
end
@@ -42,8 +42,8 @@ def self.should_respond_to(format, &block)
context "with #{format.to_s.upcase} for a gem that doesn't match the slug" do
setup do
- @rubygem = FactoryGirl.create(:rubygem, :name => "ZenTest", :slug => "zentest")
- FactoryGirl.create(:version, :rubygem => @rubygem)
+ @rubygem = create(:rubygem, :name => "ZenTest", :slug => "zentest")
+ create(:version, :rubygem => @rubygem)
get :show, :id => "ZenTest", :format => format
end
@@ -53,7 +53,7 @@ def self.should_respond_to(format, &block)
context "When logged in" do
setup do
- @user = FactoryGirl.create(:user)
+ @user = create(:user)
sign_in_as(@user)
end
@@ -73,7 +73,7 @@ def self.should_respond_to(format, &block)
context "On GET to show for a gem that not hosted" do
setup do
- @rubygem = FactoryGirl.create(:rubygem)
+ @rubygem = create(:rubygem)
assert @rubygem.versions.count.zero?
get :show, :id => @rubygem.to_param, :format => "json"
end
@@ -87,7 +87,7 @@ def self.should_respond_to(format, &block)
context "On GET to show for a gem that doesn't exist" do
setup do
- @name = FactoryGirl.generate(:name)
+ @name = generate(:name)
assert ! Rubygem.exists?(:name => @name)
get :show, :id => @name, :format => "json"
end
@@ -102,16 +102,16 @@ def self.should_respond_to(format, &block)
def self.should_respond_to(format)
context "with #{format.to_s.upcase} for a list of gems" do
setup do
- @mygems = [ FactoryGirl.create(:rubygem, :name => "SomeGem"), FactoryGirl.create(:rubygem, :name => "AnotherGem") ]
+ @mygems = [ create(:rubygem, :name => "SomeGem"), create(:rubygem, :name => "AnotherGem") ]
@mygems.each do |rubygem|
- FactoryGirl.create(:version, :rubygem => rubygem)
- FactoryGirl.create(:ownership, :user => @user, :rubygem => rubygem)
+ create(:version, :rubygem => rubygem)
+ create(:ownership, :user => @user, :rubygem => rubygem)
end
- @other_user = FactoryGirl.create(:user)
- @not_my_rubygem = FactoryGirl.create(:rubygem, :name => "NotMyGem")
- FactoryGirl.create(:version, :rubygem => @not_my_rubygem)
- FactoryGirl.create(:ownership, :user => @other_user, :rubygem => @not_my_rubygem)
+ @other_user = create(:user)
+ @not_my_rubygem = create(:rubygem, :name => "NotMyGem")
+ create(:version, :rubygem => @not_my_rubygem)
+ create(:ownership, :user => @other_user, :rubygem => @not_my_rubygem)
get :index, :format => format
end
@@ -130,7 +130,7 @@ def self.should_respond_to(format)
context "with a confirmed user authenticated" do
setup do
- @user = FactoryGirl.create(:user)
+ @user = create(:user)
@request.env["HTTP_AUTHORIZATION"] = @user.api_key
end
@@ -164,9 +164,9 @@ def self.should_respond_to(format)
context "On POST to create for existing gem" do
setup do
- rubygem = FactoryGirl.create(:rubygem, :name => "test")
- FactoryGirl.create(:ownership, :rubygem => rubygem, :user => @user)
- FactoryGirl.create(:version, :rubygem => rubygem, :number => "0.0.0", :updated_at => 1.year.ago, :created_at => 1.year.ago)
+ rubygem = create(:rubygem, :name => "test")
+ create(:ownership, :rubygem => rubygem, :user => @user)
+ create(:version, :rubygem => rubygem, :number => "0.0.0", :updated_at => 1.year.ago, :created_at => 1.year.ago)
@request.env["RAW_POST_DATA"] = gem_file("test-1.0.0.gem").read
post :create
end
@@ -182,12 +182,12 @@ def self.should_respond_to(format)
context "On POST to create for a repush" do
setup do
- rubygem = FactoryGirl.create(:rubygem,
+ rubygem = create(:rubygem,
:name => "test")
- FactoryGirl.create(:ownership, :rubygem => rubygem, :user => @user)
+ create(:ownership, :rubygem => rubygem, :user => @user)
@date = 1.year.ago
- @version = FactoryGirl.create(:version,
+ @version = create(:version,
:rubygem => rubygem,
:number => "0.0.0",
:updated_at => @date,
@@ -222,7 +222,7 @@ def self.should_respond_to(format)
context "On POST to create for someone else's gem" do
setup do
- @other_user = FactoryGirl.create(:user)
+ @other_user = create(:user)
create_gem(@other_user, :name => "test")
@rubygem.reload
@@ -241,9 +241,9 @@ def self.should_respond_to(format)
context "for a gem SomeGem with a version 0.1.0" do
setup do
- @rubygem = FactoryGirl.create(:rubygem, :name => "SomeGem")
- @v1 = FactoryGirl.create(:version, :rubygem => @rubygem, :number => "0.1.0", :platform => "ruby")
- FactoryGirl.create(:ownership, :user => @user, :rubygem => @rubygem)
+ @rubygem = create(:rubygem, :name => "SomeGem")
+ @v1 = create(:version, :rubygem => @rubygem, :number => "0.1.0", :platform => "ruby")
+ create(:ownership, :user => @user, :rubygem => @rubygem)
end
context "ON DELETE to yank for existing gem version" do
@@ -260,7 +260,7 @@ def self.should_respond_to(format)
context "and a version 0.1.1" do
setup do
- @v2 = FactoryGirl.create(:version, :rubygem => @rubygem, :number => "0.1.1", :platform => "ruby")
+ @v2 = create(:version, :rubygem => @rubygem, :number => "0.1.1", :platform => "ruby")
end
context "ON DELETE to yank for version 0.1.1" do
@@ -278,7 +278,7 @@ def self.should_respond_to(format)
context "and a version 0.1.1 and platform x86-darwin-10" do
setup do
- @v2 = FactoryGirl.create(:version, :rubygem => @rubygem, :number => "0.1.1", :platform => "x86-darwin-10")
+ @v2 = create(:version, :rubygem => @rubygem, :number => "0.1.1", :platform => "x86-darwin-10")
end
context "ON DELETE to yank for version 0.1.1 and x86-darwin-10" do
@@ -310,7 +310,7 @@ def self.should_respond_to(format)
context "ON DELETE to yank for someone else's gem" do
setup do
- @other_user = FactoryGirl.create(:user)
+ @other_user = create(:user)
@request.env["HTTP_AUTHORIZATION"] = @other_user.api_key
delete :yank, :gem_name => @rubygem.to_param, :version => '0.1.0'
end
@@ -328,11 +328,11 @@ def self.should_respond_to(format)
context "for a gem SomeGem with a yanked version 0.1.0 and unyanked version 0.1.1" do
setup do
- @rubygem = FactoryGirl.create(:rubygem, :name => "SomeGem")
- @v1 = FactoryGirl.create(:version, :rubygem => @rubygem, :number => "0.1.0", :platform => "ruby", :indexed => false)
- @v2 = FactoryGirl.create(:version, :rubygem => @rubygem, :number => "0.1.1", :platform => "ruby")
- @v3 = FactoryGirl.create(:version, :rubygem => @rubygem, :number => "0.1.2", :platform => "x86-darwin-10", :indexed => false)
- FactoryGirl.create(:ownership, :user => @user, :rubygem => @rubygem)
+ @rubygem = create(:rubygem, :name => "SomeGem")
+ @v1 = create(:version, :rubygem => @rubygem, :number => "0.1.0", :platform => "ruby", :indexed => false)
+ @v2 = create(:version, :rubygem => @rubygem, :number => "0.1.1", :platform => "ruby")
+ @v3 = create(:version, :rubygem => @rubygem, :number => "0.1.2", :platform => "x86-darwin-10", :indexed => false)
+ create(:ownership, :user => @user, :rubygem => @rubygem)
end
context "ON PUT to unyank for version 0.1.0" do
View
8 test/functional/api/v1/searches_controller_test.rb
@@ -32,10 +32,10 @@ def self.should_respond_to(format)
context "on GET to show" do
setup do
- @match = FactoryGirl.create(:rubygem, :name => "match")
- @other = FactoryGirl.create(:rubygem, :name => "other")
- FactoryGirl.create(:version, :rubygem => @match)
- FactoryGirl.create(:version, :rubygem => @other)
+ @match = create(:rubygem, :name => "match")
+ @other = create(:rubygem, :name => "other")
+ create(:version, :rubygem => @match)
+ create(:version, :rubygem => @other)
end
should_respond_to(:json) do |body|
View
10 test/functional/api/v1/versions/downloads_controller_test.rb
@@ -32,7 +32,7 @@ def self.should_respond_to(format)
context "on GET to index" do
setup do
- @version = FactoryGirl.create(:version)
+ @version = create(:version)
@eight_nine_days_ago = 89.days.ago.to_date.to_s
@one_day_ago = 1.day.ago.to_date.to_s
@@ -67,7 +67,7 @@ def self.should_respond_to(format)
context "on GET to index for a yanked gem" do
setup do
- version = FactoryGirl.create(:version, :indexed => false)
+ version = create(:version, :indexed => false)
get_index(version)
end
@@ -82,7 +82,7 @@ def self.should_respond_to(format)
context "on GET to search for a yanked gem" do
setup do
- version = FactoryGirl.create(:version, :indexed => false)
+ version = create(:version, :indexed => false)
get_search(version, 2.days.ago, 1.day.ago)
end
@@ -97,7 +97,7 @@ def self.should_respond_to(format)
context "on GET to search with missing params" do
setup do
- version = FactoryGirl.create(:version, :indexed => false)
+ version = create(:version, :indexed => false)
get :search, :version_id => version.full_name, :format => 'json'
end
@@ -148,7 +148,7 @@ def self.should_respond_to(format)
context "happy path" do
setup do
- @version = FactoryGirl.create(:version)
+ @version = create(:version)
$redis.hincrby Download.history_key(@version), @one_hundred_ninety_days_ago, 41
$redis.hincrby Download.history_key(@version), @one_hundred_eighty_nine_days_ago, 42
View
20 test/functional/api/v1/versions_controller_test.rb
@@ -36,15 +36,15 @@ def self.should_respond_to(format)
context "on GET to show" do
setup do
- @rubygem = FactoryGirl.create(:rubygem)
- FactoryGirl.create(:version, :rubygem => @rubygem, :number => '2.0.0')
- FactoryGirl.create(:version, :rubygem => @rubygem, :number => '1.0.0.pre', :prerelease => true)
- FactoryGirl.create(:version, :rubygem => @rubygem, :number => '3.0.0', :indexed => false)
+ @rubygem = create(:rubygem)
+ create(:version, :rubygem => @rubygem, :number => '2.0.0')
+ create(:version, :rubygem => @rubygem, :number => '1.0.0.pre', :prerelease => true)
+ create(:version, :rubygem => @rubygem, :number => '3.0.0', :indexed => false)
- @rubygem2 = FactoryGirl.create(:rubygem)
- FactoryGirl.create(:version, :rubygem => @rubygem2, :number => '3.0.0')
- FactoryGirl.create(:version, :rubygem => @rubygem2, :number => '2.0.0')
- FactoryGirl.create(:version, :rubygem => @rubygem2, :number => '1.0.0')
+ @rubygem2 = create(:rubygem)
+ create(:version, :rubygem => @rubygem2, :number => '3.0.0')
+ create(:version, :rubygem => @rubygem2, :number => '2.0.0')
+ create(:version, :rubygem => @rubygem2, :number => '1.0.0')
end
should_respond_to(:json) do |body|
@@ -76,9 +76,9 @@ def self.should_respond_to(format)
context "on GET to show with lots of gems" do
setup do
- @rubygem = FactoryGirl.create(:rubygem)
+ @rubygem = create(:rubygem)
12.times do |n|
- FactoryGirl.create(:version, :rubygem => @rubygem, :number => "#{n}.0.0")
+ create(:version, :rubygem => @rubygem, :number => "#{n}.0.0")
end
end
View
28 test/functional/api/v1/web_hooks_controller_test.rb
@@ -10,7 +10,7 @@ def self.should_not_find_it
context "When not logged in" do
should "forbid access when creating a web hook" do
- rubygem = FactoryGirl.create(:rubygem)
+ rubygem = create(:rubygem)
post :create, :gem_name => rubygem.name, :url => "http://example.com"
assert @response.body =~ /Access Denied/
assert WebHook.count.zero?
@@ -27,7 +27,7 @@ def self.should_not_find_it
end
should "forbid access when removing a web hook" do
- hook = FactoryGirl.create(:web_hook)
+ hook = create(:web_hook)
delete :remove, :gem_name => hook.rubygem.name, :url => hook.url
assert @response.body =~ /Access Denied/
assert_equal 1, WebHook.count
@@ -51,14 +51,14 @@ def self.should_respond_to(format)
context "When logged in" do
setup do
@url = "http://example.org"
- @user = FactoryGirl.create(:user)
+ @user = create(:user)
@request.env["Authorization"] = @user.api_key
end
context "with the gemcutter gem" do
setup do
- @gemcutter = FactoryGirl.create(:rubygem, :name => "gemcutter")
- FactoryGirl.create(:version, :rubygem => @gemcutter)
+ @gemcutter = create(:rubygem, :name => "gemcutter")
+ create(:version, :rubygem => @gemcutter)
end
context "On POST to fire for all gems" do
@@ -90,8 +90,8 @@ def self.should_respond_to(format)
context "with a rubygem" do
setup do
- @rubygem = FactoryGirl.create(:rubygem)
- FactoryGirl.create(:version, :rubygem => @rubygem)
+ @rubygem = create(:rubygem)
+ create(:version, :rubygem => @rubygem)
end
context "On POST to fire for a specific gem" do
@@ -122,10 +122,10 @@ def self.should_respond_to(format)
context "On GET to index with some owned hooks" do
setup do
- @rubygem_hook = FactoryGirl.create(:web_hook,
+ @rubygem_hook = create(:web_hook,
:user => @user,
:rubygem => @rubygem)
- @global_hook = FactoryGirl.create(:global_web_hook,
+ @global_hook = create(:global_web_hook,
:user => @user)
end
@@ -183,11 +183,11 @@ def self.should_respond_to(format)
context "with some unowned hooks" do
setup do
- @other_user = FactoryGirl.create(:user)
- @rubygem_hook = FactoryGirl.create(:web_hook,
+ @other_user = create(:user)
+ @rubygem_hook = create(:web_hook,
:user => @other_user,
:rubygem => @rubygem)
- @global_hook = FactoryGirl.create(:global_web_hook,
+ @global_hook = create(:global_web_hook,
:user => @other_user)
end
@@ -241,7 +241,7 @@ def self.should_respond_to(format)
context "on POST to create hook that already exists" do
setup do
- FactoryGirl.create(:web_hook, :rubygem => @rubygem, :url => @url, :user => @user)
+ create(:web_hook, :rubygem => @rubygem, :url => @url, :user => @user)
post :create, :gem_name => @rubygem.name, :url => @url
end
@@ -286,7 +286,7 @@ def self.should_respond_to(format)
context "on POST to global web hook that already exists" do
setup do
- FactoryGirl.create(:global_web_hook, :url => @url, :user => @user)
+ create(:global_web_hook, :url => @url, :user => @user)
post :create, :gem_name => WebHook::GLOBAL_PATTERN, :url => @url
end
View
16 test/functional/dashboards_controller_test.rb
@@ -3,17 +3,17 @@
class DashboardsControllerTest < ActionController::TestCase
context "When logged in" do
setup do
- @user = FactoryGirl.create(:user)
+ @user = create(:user)
sign_in_as(@user)
end
context "on GET to show" do
setup do
- 3.times { FactoryGirl.create(:rubygem) }
+ 3.times { create(:rubygem) }
@gems = (1..3).map do
- rubygem = FactoryGirl.create(:rubygem)
+ rubygem = create(:rubygem)
rubygem.ownerships.create(:user => @user)
- FactoryGirl.create(:version, :rubygem => rubygem)
+ create(:version, :rubygem => rubygem)
rubygem
end
get :show
@@ -32,11 +32,11 @@ class DashboardsControllerTest < ActionController::TestCase
context "On GET to show as an atom feed" do
setup do
- @subscribed_versions = (1..2).map { |n| FactoryGirl.create(:version, :created_at => n.hours.ago) }
+ @subscribed_versions = (1..2).map { |n| create(:version, :created_at => n.hours.ago) }
# just to make sure one has a different platform and a summary
- @subscribed_versions << FactoryGirl.create(:version, :created_at => 3.hours.ago, :platform => "win32", :summary => "&")
- @subscribed_versions.each { |v| FactoryGirl.create(:subscription, :rubygem => v.rubygem, :user => @user)}
- @unsubscribed_versions = (1..3).map { |n| FactoryGirl.create(:version, :created_at => n.hours.ago) }
+ @subscribed_versions << create(:version, :created_at => 3.hours.ago, :platform => "win32", :summary => "&")
+ @subscribed_versions.each { |v| create(:subscription, :rubygem => v.rubygem, :user => @user)}
+ @unsubscribed_versions = (1..3).map { |n| create(:version, :created_at => n.hours.ago) }
@request.env["Authorization"] = @user.api_key
get :show, :format => "atom"
View
2  test/functional/home_controller_test.rb
@@ -54,7 +54,7 @@ class HomeControllerTest < ActionController::TestCase
context "on GET to index with a non-ssl request when signed in" do
setup do
- sign_in_as(FactoryGirl.create(:user))
+ sign_in_as(create(:user))
@request.env['HTTPS'] = nil
get :index
end
View
8 test/functional/profiles_controller_test.rb
@@ -12,15 +12,15 @@ class ProfilesControllerTest < ActionController::TestCase
context "when logged in" do
setup do
- @user = FactoryGirl.create(:user)
+ @user = create(:user)
sign_in_as(@user)
end
context "on GET to show" do
setup do
@rubygems = (0..10).map do |n|
- FactoryGirl.create(:rubygem, :downloads => n * 100).tap do |rubygem|
- FactoryGirl.create(:ownership, :rubygem => rubygem, :user => @user)
+ create(:rubygem, :downloads => n * 100).tap do |rubygem|
+ create(:ownership, :rubygem => rubygem, :user => @user)
end
end.reverse
@@ -67,7 +67,7 @@ class ProfilesControllerTest < ActionController::TestCase
context "updating handle" do
setup do
@handle = "john_m_doe"
- @user = FactoryGirl.create(:user, :handle => "johndoe")
+ @user = create(:user, :handle => "johndoe")
sign_in_as(@user)
put :update, :user => {:handle => @handle}
end
View
76 test/functional/rubygems_controller_test.rb
@@ -3,13 +3,13 @@
class RubygemsControllerTest < ActionController::TestCase
context "When logged in" do
setup do
- @user = FactoryGirl.create(:user)
+ @user = create(:user)
sign_in_as(@user)
end
context "On GET to show for any gem" do
setup do
- @owners = [@user, FactoryGirl.create(:user)]
+ @owners = [@user, create(:user)]
create_gem(*@owners)
get :show, :id => @rubygem.to_param
end
@@ -26,7 +26,7 @@ class RubygemsControllerTest < ActionController::TestCase
context "On GET to show for any gem without a linkset" do
setup do
- @owners = [@user, FactoryGirl.create(:user)]
+ @owners = [@user, create(:user)]
create_gem(*@owners)
@rubygem.linkset = nil
get :show, :id => @rubygem.to_param
@@ -40,7 +40,7 @@ class RubygemsControllerTest < ActionController::TestCase
context "On GET to show for another user's gem" do
setup do
- @rubygem = FactoryGirl.create(:rubygem)
+ @rubygem = create(:rubygem)
get :show, :id => @rubygem.to_param
end
@@ -68,9 +68,9 @@ class RubygemsControllerTest < ActionController::TestCase
context "On GET to show for a gem that the user is subscribed to" do
setup do
- @rubygem = FactoryGirl.create(:rubygem)
- FactoryGirl.create(:version, :rubygem => @rubygem)
- FactoryGirl.create(:subscription, :rubygem => @rubygem, :user => @user)
+ @rubygem = create(:rubygem)
+ create(:version, :rubygem => @rubygem)
+ create(:subscription, :rubygem => @rubygem, :user => @user)
get :show, :id => @rubygem.to_param
end
@@ -86,8 +86,8 @@ class RubygemsControllerTest < ActionController::TestCase
context "On GET to show for a gem that the user is not subscribed to" do
setup do
- @rubygem = FactoryGirl.create(:rubygem)
- FactoryGirl.create(:version, :rubygem => @rubygem)
+ @rubygem = create(:rubygem)
+ create(:version, :rubygem => @rubygem)
get :show, :id => @rubygem.to_param
end
@@ -123,7 +123,7 @@ class RubygemsControllerTest < ActionController::TestCase
context "On GET to edit for another user's gem" do
setup do
- @other_user = FactoryGirl.create(:user)
+ @other_user = create(:user)
create_gem(@other_user)
get :edit, :id => @rubygem.to_param
end
@@ -169,11 +169,11 @@ class RubygemsControllerTest < ActionController::TestCase
context "On GET to index with no parameters" do
setup do
@gems = (1..3).map do |n|
- gem = FactoryGirl.create(:rubygem, :name => "agem#{n}")
- FactoryGirl.create(:version, :rubygem => gem)
+ gem = create(:rubygem, :name => "agem#{n}")
+ create(:version, :rubygem => gem)
gem
end
- FactoryGirl.create(:rubygem, :name => "zeta")
+ create(:rubygem, :name => "zeta")
get :index
end
@@ -193,9 +193,9 @@ class RubygemsControllerTest < ActionController::TestCase
context "On GET to index as an atom feed" do
setup do
- @versions = (1..2).map { |n| FactoryGirl.create(:version, :created_at => n.hours.ago) }
+ @versions = (1..2).map { |n| create(:version, :created_at => n.hours.ago) }
# just to make sure one has a different platform and a summary
- @versions << FactoryGirl.create(:version, :created_at => 3.hours.ago, :platform => "win32", :summary => "&")
+ @versions << create(:version, :created_at => 3.hours.ago, :platform => "win32", :summary => "&")
get :index, :format => "atom"
end
@@ -226,9 +226,9 @@ class RubygemsControllerTest < ActionController::TestCase
context "On GET to index with a letter" do
setup do
- @gems = (1..3).map { |n| FactoryGirl.create(:rubygem, :name => "agem#{n}") }
- @zgem = FactoryGirl.create(:rubygem, :name => "zeta")
- FactoryGirl.create(:version, :rubygem => @zgem)
+ @gems = (1..3).map { |n| create(:rubygem, :name => "agem#{n}") }
+ @zgem = create(:rubygem, :name => "zeta")
+ create(:version, :rubygem => @zgem)
get :index, :letter => "z"
end
should respond_with :success
@@ -246,11 +246,11 @@ class RubygemsControllerTest < ActionController::TestCase
context "On GET to index with a bad letter" do
setup do
@gems = (1..3).map do |n|
- gem = FactoryGirl.create(:rubygem, :name => "agem#{n}")
- FactoryGirl.create(:version, :rubygem => gem)
+ gem = create(:rubygem, :name => "agem#{n}")
+ create(:version, :rubygem => gem)
gem
end
- FactoryGirl.create(:rubygem, :name => "zeta")
+ create(:rubygem, :name => "zeta")
get :index, :letter => "asdf"
end
@@ -272,7 +272,7 @@ class RubygemsControllerTest < ActionController::TestCase
context "On GET to show" do
setup do
- @latest_version = FactoryGirl.create(:version, :created_at => 1.minute.ago)
+ @latest_version = create(:version, :created_at => 1.minute.ago)
@rubygem = @latest_version.rubygem
get :show, :id => @rubygem.to_param
end
@@ -291,9 +291,9 @@ class RubygemsControllerTest < ActionController::TestCase
context "On GET to show with a gem that has multiple versions" do
setup do
- @rubygem = FactoryGirl.create(:rubygem)
- @older_version = FactoryGirl.create(:version, :number => "1.0.0", :rubygem => @rubygem, :created_at => 2.days.ago)
- @latest_version = FactoryGirl.create(:version, :number => "2.0.0", :rubygem => @rubygem, :created_at => 1.minute.ago)
+ @rubygem = create(:rubygem)
+ @older_version = create(:version, :number => "1.0.0", :rubygem => @rubygem, :created_at => 2.days.ago)
+ @latest_version = create(:version, :number => "2.0.0", :rubygem => @rubygem, :created_at => 1.minute.ago)
get :show, :id => @rubygem.to_param
end
@@ -313,7 +313,7 @@ class RubygemsControllerTest < ActionController::TestCase
context "On GET to show for a yanked gem with no versions" do
setup do
- version = FactoryGirl.create(:version, :created_at => 1.minute.ago)
+ version = create(:version, :created_at => 1.minute.ago)
@rubygem = version.rubygem
@rubygem.yank!(version)
end
@@ -329,9 +329,9 @@ class RubygemsControllerTest < ActionController::TestCase
end
context 'with a signed in user subscribed to the gem' do
setup do
- @user = FactoryGirl.create(:user)
+ @user = create(:user)
sign_in_as @user
- FactoryGirl.create(:subscription, :user => @user, :rubygem => @rubygem)
+ create(:subscription, :user => @user, :rubygem => @rubygem)
get :show, :id => @rubygem.to_param
end
should "have a visible unsubscribe link" do
@@ -342,7 +342,7 @@ class RubygemsControllerTest < ActionController::TestCase
context "On GET to show for a gem with no versions" do
setup do
- @rubygem = FactoryGirl.create(:rubygem)
+ @rubygem = create(:rubygem)
get :show, :id => @rubygem.to_param
end
should respond_with :success
@@ -355,10 +355,10 @@ class RubygemsControllerTest < ActionController::TestCase
context "On GET to show for a gem with both runtime and development dependencies" do
setup do
- @version = FactoryGirl.create(:version)
+ @version = create(:version)
- @development = FactoryGirl.create(:development_dependency, :version => @version)
- @runtime = FactoryGirl.create(:runtime_dependency, :version => @version)
+ @development = create(:development_dependency, :version => @version)
+ @runtime = create(:runtime_dependency, :version => @version)
get :show, :id => @version.rubygem.to_param
end
@@ -374,9 +374,9 @@ class RubygemsControllerTest < ActionController::TestCase
context "On GET to show for a gem with dependencies that are unresolved" do
setup do
- @version = FactoryGirl.create(:version)
+ @version = create(:version)
- @unresolved = FactoryGirl.create(:unresolved_dependency, :version => @version)
+ @unresolved = create(:unresolved_dependency, :version => @version)
get :show, :id => @version.rubygem.to_param
end
@@ -400,8 +400,8 @@ class RubygemsControllerTest < ActionController::TestCase
context "When not logged in" do
context "On GET to show for a gem" do
setup do
- @rubygem = FactoryGirl.create(:rubygem)
- FactoryGirl.create(:version, :rubygem => @rubygem)
+ @rubygem = create(:rubygem)
+ create(:version, :rubygem => @rubygem)
get :show, :id => @rubygem.to_param
end
@@ -417,7 +417,7 @@ class RubygemsControllerTest < ActionController::TestCase
context "On GET to edit" do
setup do
- @rubygem = FactoryGirl.create(:rubygem)
+ @rubygem = create(:rubygem)
get :edit, :id => @rubygem.to_param
end
should respond_with :redirect
@@ -426,7 +426,7 @@ class RubygemsControllerTest < ActionController::TestCase
context "On PUT to update" do
setup do
- @rubygem = FactoryGirl.create(:rubygem)
+ @rubygem = create(:rubygem)
put :update, :id => @rubygem.to_param, :linkset => {}
end
should respond_with :redirect
View
14 test/functional/searches_controller_test.rb
@@ -14,7 +14,7 @@ class SearchesControllerTest < ActionController::TestCase
context 'on GET to show with search parameters for a rubygem without versions' do
setup do
- @sinatra = FactoryGirl.create(:rubygem, :name => "sinatra")
+ @sinatra = create(:rubygem, :name => "sinatra")
assert_nil @sinatra.versions.most_recent
assert @sinatra.reload.versions.count.zero?
get :show, :query => "sinatra"
@@ -26,12 +26,12 @@ class SearchesControllerTest < ActionController::TestCase
context 'on GET to show with search parameters' do
setup do
- @sinatra = FactoryGirl.create(:rubygem, :name => "sinatra")
- @sinatra_redux = FactoryGirl.create(:rubygem, :name => "sinatra-redux")
- @brando = FactoryGirl.create(:rubygem, :name => "brando")
- FactoryGirl.create(:version, :rubygem => @sinatra)
- FactoryGirl.create(:version, :rubygem => @sinatra_redux)
- FactoryGirl.create(:version, :rubygem => @brando)
+ @sinatra = create(:rubygem, :name => "sinatra")
+ @sinatra_redux = create(:rubygem, :name => "sinatra-redux")
+ @brando = create(:rubygem, :name => "brando")
+ create(:version, :rubygem => @sinatra)
+ create(:version, :rubygem => @sinatra_redux)
+ create(:version, :rubygem => @brando)
get :show, :query => "sinatra"
end
View
22 test/functional/stats_controller_test.rb
@@ -6,7 +6,7 @@ class StatsControllerTest < ActionController::TestCase
@number_of_gems = 1337
@number_of_users = 101
@number_of_downloads = 42
- @most_downloaded = [FactoryGirl.create(:rubygem)]
+ @most_downloaded = [create(:rubygem)]
stub(Rubygem).total_count { @number_of_gems }
stub(Download).count { @number_of_downloads }
@@ -45,7 +45,7 @@ class StatsControllerTest < ActionController::TestCase
context "On GET to stats" do
setup do
- @version = FactoryGirl.create(:version)
+ @version = create(:version)
@rubygem = @version.rubygem
@versions = @versions = @rubygem.versions.limit(5)
get :show, :rubygem_id => @rubygem.to_param
@@ -69,9 +69,9 @@ class StatsControllerTest < ActionController::TestCase
context "On GET to stats with a gem that has multiple versions" do
setup do
- @rubygem = FactoryGirl.create(:rubygem)
- @older_version = FactoryGirl.create(:version, :number => "1.0.0", :rubygem => @rubygem)
- @latest_version = FactoryGirl.create(:version, :number => "2.0.0", :rubygem => @rubygem)
+ @rubygem = create(:rubygem)
+ @older_version = create(:version, :number => "1.0.0", :rubygem => @rubygem)
+ @latest_version = create(:version, :number => "2.0.0", :rubygem => @rubygem)
get :show, :rubygem_id => @rubygem.to_param
end
@@ -87,10 +87,10 @@ class StatsControllerTest < ActionController::TestCase
context "On GET to stats" do
setup do
- @version = FactoryGirl.create(:version)
+ @version = create(:version)
rubygem = @version.rubygem
- @other_version = FactoryGirl.create(:version)
- @latest_version = FactoryGirl.create(:version, :rubygem => rubygem)
+ @other_version = create(:version)
+ @latest_version = create(:version, :rubygem => rubygem)
Timecop.freeze(1.day.ago) do
Download.incr(rubygem.name, @version.full_name)
@@ -140,7 +140,7 @@ class StatsControllerTest < ActionController::TestCase
context "On GET to stats for a gem with no versions" do
setup do
- @rubygem = FactoryGirl.create(:rubygem)
+ @rubygem = create(:rubygem)
get :show, :rubygem_id => @rubygem.to_param
end
@@ -157,9 +157,9 @@ class StatsControllerTest < ActionController::TestCase
context "On GET to stats for a specific version" do
setup do
- @version = FactoryGirl.create(:version, :number => "0.0.1")
+ @version = create(:version, :number => "0.0.1")
@rubygem = @version.rubygem
- @latest_version = FactoryGirl.create(:version, :rubygem => @rubygem, :number => "0.0.2")
+ @latest_version = create(:version, :rubygem => @rubygem, :number => "0.0.2")
get :show, :rubygem_id => @rubygem.name, :version_id => @version.slug
end
View
22 test/functional/subscriptions_controller_test.rb
@@ -3,15 +3,15 @@
class SubscriptionsControllerTest < ActionController::TestCase
context "When logged in" do
setup do
- @user = FactoryGirl.create(:user)
+ @user = create(:user)
sign_in_as(@user)
end
end
context "On POST to create for a gem that the user is not subscribed to" do
setup do
- @rubygem = FactoryGirl.create(:rubygem)
- FactoryGirl.create(:version, :rubygem => @rubygem)
+ @rubygem = create(:rubygem)
+ create(:version, :rubygem => @rubygem)
post :create, :rubygem_id => @rubygem.to_param, :format => 'js'
end
@@ -24,9 +24,9 @@ class SubscriptionsControllerTest < ActionController::TestCase
context "On POST to create for a gem that the user is subscribed to" do
setup do
- @rubygem = FactoryGirl.create(:rubygem)
- FactoryGirl.create(:version, :rubygem => @rubygem)
- FactoryGirl.create(:subscription, :rubygem => @rubygem, :user => @user)
+ @rubygem = create(:rubygem)
+ create(:version, :rubygem => @rubygem)
+ create(:subscription, :rubygem => @rubygem, :user => @user)
post :create, :rubygem_id => @rubygem.to_param, :format => 'js'
end
@@ -36,8 +36,8 @@ class SubscriptionsControllerTest < ActionController::TestCase
context "On DELETE to destroy for a gem that the user is not subscribed to" do
setup do
- @rubygem = FactoryGirl.create(:rubygem)
- FactoryGirl.create(:version, :rubygem => @rubygem)
+ @rubygem = create(:rubygem)
+ create(:version, :rubygem => @rubygem)
delete :destroy, :rubygem_id => @rubygem.to_param, :format => 'js'
end
@@ -47,9 +47,9 @@ class SubscriptionsControllerTest < ActionController::TestCase
context "On DELETE to destroy for a gem that the user is subscribed to" do
setup do
- @rubygem = FactoryGirl.create(:rubygem)
- FactoryGirl.create(:version, :rubygem => @rubygem)
- FactoryGirl.create(:subscription, :rubygem => @rubygem, :user => @user)
+ @rubygem = create(:rubygem)
+ create(:version, :rubygem => @rubygem)
+ create(:subscription, :rubygem => @rubygem, :user => @user)
delete :destroy, :rubygem_id => @rubygem.to_param, :format => 'js'
end
View
8 test/functional/versions_controller_test.rb
@@ -3,9 +3,9 @@
class VersionsControllerTest < ActionController::TestCase
context 'GET to index' do
setup do
- @rubygem = FactoryGirl.create(:rubygem)
+ @rubygem = create(:rubygem)
@versions = (1..5).map do |version|
- FactoryGirl.create(:version, :rubygem => @rubygem)
+ create(:version, :rubygem => @rubygem)
end
get :index, :rubygem_id => @rubygem.name
@@ -25,7 +25,7 @@ class VersionsControllerTest < ActionController::TestCase
context "GET to index for gem with no versions" do
setup do
- @rubygem = FactoryGirl.create(:rubygem)
+ @rubygem = create(:rubygem)
get :index, :rubygem_id => @rubygem.name
end
@@ -38,7 +38,7 @@ class VersionsControllerTest < ActionController::TestCase
context "On GET to show" do
setup do
- @latest_version = FactoryGirl.create(:version, :built_at => 1.week.ago, :created_at => 1.day.ago)
+ @latest_version = create(:version, :built_at => 1.week.ago, :created_at => 1.day.ago)
@rubygem = @latest_version.rubygem
get :show, :rubygem_id => @rubygem.name, :id => @latest_version.number
end
View
2  test/shoulda_macros/security.rb
@@ -12,7 +12,7 @@ def self.should_forbid_access_when(action, &block)
context "On #{action} with unconfirmed user" do
setup do
- @user = FactoryGirl.create(:user)
+ @user = create(:user)
@request.env["HTTP_AUTHORIZATION"] = @user.api_key
instance_eval(&block)
end
View
5 test/test_helper.rb
@@ -14,6 +14,7 @@ class Test::Unit::TestCase
include Rack::Test::Methods
include RR::Adapters::TestUnit unless include?(RR::Adapters::TestUnit)
include WebMock::API
+ include FactoryGirl::Syntax::Methods
def setup
RR.reset
@@ -45,8 +46,8 @@ def regenerate_index
def create_gem(*owners_and_or_opts)
opts, owners = owners_and_or_opts.extract_options!, owners_and_or_opts
- @rubygem = FactoryGirl.create(:rubygem, :name => opts[:name] || FactoryGirl.generate(:name))
- FactoryGirl.create(:version, :rubygem => @rubygem)
+ @rubygem = create(:rubygem, :name => opts[:name] || generate(:name))
+ create(:version, :rubygem => @rubygem)
owners.each { |owner| @rubygem.ownerships.create(:user => owner) }
end
View
24 test/unit/dependency_test.rb
@@ -6,8 +6,8 @@ class DependencyTest < ActiveSupport::TestCase
context "with dependency" do
setup do
- @version = FactoryGirl.create(:version)
- @dependency = FactoryGirl.build(:dependency, :version => @version)
+ @version = create(:version)
+ @dependency = build(:dependency, :version => @version)
end
should "be valid with factory" do
@@ -49,7 +49,7 @@ class DependencyTest < ActiveSupport::TestCase
end
should "not push development dependency onto the redis list" do
- @dependency = FactoryGirl.create(:development_dependency)
+ @dependency = create(:development_dependency)
assert !$redis.exists(Dependency.runtime_key(@dependency.version.full_name))
end
@@ -58,21 +58,21 @@ class DependencyTest < ActiveSupport::TestCase
context "with a Gem::Dependency" do
context "that refers to a Rubygem that exists with a malformed dependency" do
setup do
- @rubygem = FactoryGirl.create(:rubygem)
+ @rubygem = create(:rubygem)
@requirements = ['= 0.0.0']
@gem_dependency = Gem::Dependency.new(@rubygem.name, @requirements)
end
should "correctly create a Dependency referring to the existing Rubygem" do
stub(@gem_dependency).requirements_list { ['#<YAML::Syck::DefaultKey:0x0000000> 0.0.0'] }
- @dependency = FactoryGirl.create(:dependency, :rubygem => @rubygem, :gem_dependency => @gem_dependency)
+ @dependency = create(:dependency, :rubygem => @rubygem, :gem_dependency => @gem_dependency)
assert_equal @rubygem, @dependency.rubygem
assert_equal @requirements[0].to_s, @dependency.requirements
end
should "correctly display a malformed Dependency referring to the existing Rubygem" do
- @dependency = FactoryGirl.create(:dependency, :rubygem => @rubygem, :gem_dependency => @gem_dependency)
+ @dependency = create(:dependency, :rubygem => @rubygem, :gem_dependency => @gem_dependency)
stub(@dependency).requirements { '#<YAML::Syck::DefaultKey:0x0000000> 0.0.0' }
assert_equal @rubygem, @dependency.rubygem
@@ -82,10 +82,10 @@ class DependencyTest < ActiveSupport::TestCase
context "that refers to a Rubygem that exists" do
setup do
- @rubygem = FactoryGirl.create(:rubygem)
+ @rubygem = create(:rubygem)
@requirements = ['>= 0.0.0']
@gem_dependency = Gem::Dependency.new(@rubygem.name, @requirements)
- @dependency = FactoryGirl.create(:dependency, :rubygem => @rubygem, :gem_dependency => @gem_dependency)
+ @dependency = create(:dependency, :rubygem => @rubygem, :gem_dependency => @gem_dependency)
end
should "create a Dependency referring to the existing Rubygem" do
@@ -96,10 +96,10 @@ class DependencyTest < ActiveSupport::TestCase
context "that refers to a Rubygem that exists and has multiple requirements" do
setup do
- @rubygem = FactoryGirl.create(:rubygem)
+ @rubygem = create(:rubygem)
@requirements = ['< 1.0.0', '>= 0.0.0']
@gem_dependency = Gem::Dependency.new(@rubygem.name, @requirements)
- @dependency = FactoryGirl.create(:dependency, :rubygem => @rubygem, :gem_dependency => @gem_dependency)
+ @dependency = create(:dependency, :rubygem => @rubygem, :gem_dependency => @gem_dependency)
end
should "create a Dependency referring to the existing Rubygem" do
@@ -155,8 +155,8 @@ class DependencyTest < ActiveSupport::TestCase
context "yaml" do
setup do
- FactoryGirl.create(:rubygem)
- @dependency = FactoryGirl.create(:dependency)
+ create(:rubygem)
+ @dependency = create(:dependency)
end
should "return its payload" do
View
66 test/unit/download_test.rb
@@ -2,8 +2,8 @@
class DownloadTest < ActiveSupport::TestCase
should "load up all downloads with just raw strings and process them" do
- rubygem = FactoryGirl.create(:rubygem, :name => "some-stupid13-gem42-9000")
- version = FactoryGirl.create(:version, :rubygem => rubygem)
+ rubygem = create(:rubygem, :name => "some-stupid13-gem42-9000")
+ version = create(:version, :rubygem => rubygem)
3.times do
Download.incr(rubygem.name, version.full_name)
@@ -16,9 +16,9 @@ class DownloadTest < ActiveSupport::TestCase
end
should "track platform gem downloads correctly" do
- rubygem = FactoryGirl.create(:rubygem)
- version = FactoryGirl.create(:version, :rubygem => rubygem, :platform => "mswin32-60")
- other_platform_version = FactoryGirl.create(:version, :rubygem => rubygem, :platform => "mswin32")
+ rubygem = create(:rubygem)
+ version = create(:version, :rubygem => rubygem, :platform => "mswin32-60")
+ other_platform_version = create(:version, :rubygem => rubygem, :platform => "mswin32")
Download.incr(rubygem.name, version.full_name)
@@ -32,15 +32,15 @@ class DownloadTest < ActiveSupport::TestCase
end
should "find most downloaded today" do
- @rubygem_1 = FactoryGirl.create(:rubygem)
- @version_1 = FactoryGirl.create(:version, :rubygem => @rubygem_1)
- @version_2 = FactoryGirl.create(:version, :rubygem => @rubygem_1)
+ @rubygem_1 = create(:rubygem)
+ @version_1 = create(:version, :rubygem => @rubygem_1)
+ @version_2 = create(:version, :rubygem => @rubygem_1)
- @rubygem_2 = FactoryGirl.create(:rubygem)
- @version_3 = FactoryGirl.create(:version, :rubygem => @rubygem_2)
+ @rubygem_2 = create(:rubygem)
+ @version_3 = create(:version, :rubygem => @rubygem_2)
- @rubygem_3 = FactoryGirl.create(:rubygem)
- @version_4 = FactoryGirl.create(:version, :rubygem => @rubygem_3)
+ @rubygem_3 = create(:rubygem)
+ @version_4 = create(:version, :rubygem => @rubygem_3)
Timecop.freeze(Date.today - 1) do
Download.incr(@rubygem_1.name, @version_1.full_name)
@@ -70,15 +70,15 @@ class DownloadTest < ActiveSupport::TestCase
end
should "find most downloaded all time" do
- @rubygem_1 = FactoryGirl.create(:rubygem)
- @version_1 = FactoryGirl.create(:version, :rubygem => @rubygem_1)
- @version_2 = FactoryGirl.create(:version, :rubygem => @rubygem_1)
+ @rubygem_1 = create(:rubygem)
+ @version_1 = create(:version, :rubygem => @rubygem_1)
+ @version_2 = create(:version, :rubygem => @rubygem_1)
- @rubygem_2 = FactoryGirl.create(:rubygem)
- @version_3 = FactoryGirl.create(:version, :rubygem => @rubygem_2)
+ @rubygem_2 = create(:rubygem)
+ @version_3 = create(:version, :rubygem => @rubygem_2)
- @rubygem_3 = FactoryGirl.create(:rubygem)
- @version_4 = FactoryGirl.create(:version, :rubygem => @rubygem_3)
+ @rubygem_3 = create(:rubygem)
+ @version_4 = create(:version, :rubygem => @rubygem_3)
Download.incr(@rubygem_1.name, @version_1.full_name)
Download.incr(@rubygem_1.name, @version_2.full_name)
@@ -101,15 +101,15 @@ class DownloadTest < ActiveSupport::TestCase
end
should "find counts per day for versions" do
- @rubygem_1 = FactoryGirl.create(:rubygem)
- @version_1 = FactoryGirl.create(:version, :rubygem => @rubygem_1)
- @version_2 = FactoryGirl.create(:version, :rubygem => @rubygem_1)
+ @rubygem_1 = create(:rubygem)
+ @version_1 = create(:version, :rubygem => @rubygem_1)
+ @version_2 = create(:version, :rubygem => @rubygem_1)
- @rubygem_2 = FactoryGirl.create(:rubygem)
- @version_3 = FactoryGirl.create(:version, :rubygem => @rubygem_2)
+ @rubygem_2 = create(:rubygem)
+ @version_3 = create(:version, :rubygem => @rubygem_2)
- @rubygem_3 = FactoryGirl.create(:rubygem)
- @version_4 = FactoryGirl.create(:version, :rubygem => @rubygem_3)
+ @rubygem_3 = create(:rubygem)
+ @version_4 = create(:version, :rubygem => @rubygem_3)
Timecop.freeze(1.day.ago) do
Download.incr(@rubygem_1, @version_1.full_name)
@@ -133,9 +133,9 @@ class DownloadTest < ActiveSupport::TestCase
end
should "find download count by gem name" do
- rubygem = FactoryGirl.create(:rubygem)
- version1 = FactoryGirl.create(:version, :rubygem => rubygem)
- version2 = FactoryGirl.create(:version, :rubygem => rubygem)
+ rubygem = create(:rubygem)
+ version1 = create(:version, :rubygem => rubygem)
+ version2 = create(:version, :rubygem => rubygem)
3.times { Download.incr(rubygem.name, version1.full_name) }
2.times { Download.incr(rubygem.name, version2.full_name) }
@@ -146,16 +146,16 @@ class DownloadTest < ActiveSupport::TestCase
end
should "return zero for rank if no downloads exist" do
- assert_equal 0, Download.rank(FactoryGirl.build(:version))
+ assert_equal 0, Download.rank(build(:version))
end
should "return zero for highest rank the given versions have zero downloads" do
- assert_equal 0, Download.highest_rank([FactoryGirl.build(:version), FactoryGirl.build(:version)])
+ assert_equal 0, Download.highest_rank([build(:version), build(:version)])
end
should "delete all old today keys except the current" do
- rubygem = FactoryGirl.create(:rubygem)
- version = FactoryGirl.create(:version, :rubygem => rubygem)
+ rubygem = create(:rubygem)
+ version = create(:version, :rubygem => rubygem)
10.times do |n|
Timecop.freeze(n.days.ago) do
3.times { Download.incr(rubygem.name, version.full_name) }
View
16 test/unit/helpers/rubygems_helper_test.rb
@@ -30,16 +30,16 @@ class RubygemsHelperTest < ActionView::TestCase
end
should "link to docs if no docs link is set" do
- version = FactoryGirl.build(:version)
- linkset = FactoryGirl.build(:linkset, :docs => nil)
+ version = build(:version)
+ linkset = build(:linkset, :docs => nil)
link = documentation_link(version, linkset)
assert link.include?(documentation_path(version))
end
should "not link to docs if docs link is set" do
- version = FactoryGirl.build(:version)
- linkset = FactoryGirl.build(:linkset)
+ version = build(:version)
+ linkset = build(:linkset)
link = documentation_link(version, linkset)
assert link.blank?
@@ -47,7 +47,7 @@ class RubygemsHelperTest < ActionView::TestCase
context "creating linkset links" do
setup do
- @linkset = FactoryGirl.build(:linkset)
+ @linkset = build(:linkset)
@linkset.wiki = nil
@linkset.code = ""
end
@@ -71,8 +71,8 @@ class RubygemsHelperTest < ActionView::TestCase
context "options for individual stats" do
setup do
- @rubygem = FactoryGirl.create(:rubygem)
- @versions = (1..3).map { FactoryGirl.create(:version, :rubygem => @rubygem) }
+ @rubygem = create(:rubygem)
+ @versions = (1..3).map { create(:version, :rubygem => @rubygem) }
end
should "show the overview link first" do
@@ -97,7 +97,7 @@ class RubygemsHelperTest < ActionView::TestCase
end
should "create links to owners gem overviews" do
- users = Array.new(2) { FactoryGirl.create(:user) }
+ users = Array.new(2) { create(:user) }
create_gem(*users)
expected_links = users.sort_by(&:id).map { |u|
link_to gravatar(48, "gravatar-#{u.id}", u), profile_path(u.display_id), :alt => u.display_handle,
View
12 test/unit/hostess_test.rb
@@ -52,8 +52,8 @@ def touch(path, local = true)
setup do
@download_count = Download.count
@file = "/gems/test-0.0.0.gem"
- @rubygem = FactoryGirl.create(:rubygem, :name => "test")
- @version = FactoryGirl.create(:version, :rubygem => @rubygem, :number => "0.0.0")
+ @rubygem = create(:rubygem, :name => "test")
+ @version = create(:version, :rubygem => @rubygem, :number => "0.0.0")
end
should "increase download count" do
@@ -78,8 +78,8 @@ def touch(path, local = true)
end
should "find gemspec if loaded in redis" do
- rubygem = FactoryGirl.create(:rubygem, :name => "rails")
- version = FactoryGirl.create(:version, :number => "4.0.0", :rubygem => rubygem)
+ rubygem = create(:rubygem, :name => "rails")
+ version = create(:version, :number => "4.0.0", :rubygem => rubygem)
path = "/quick/Marshal.4.8/#{version.full_name}.gemspec.rz"
touch path, false
@@ -99,8 +99,8 @@ def touch(path, local = true)
file = "/gems/test-0.0.0.gem"
FileUtils.cp gem_file.path, Pusher.server_path("gems")
- rubygem = FactoryGirl.create(:rubygem, :name => "test")
- version = FactoryGirl.create(:version, :rubygem => rubygem, :number => "0.0.0")
+ rubygem = create(:rubygem, :name => "test")
+ version = create(:version, :rubygem => rubygem, :number => "0.0.0")
get file
assert_equal 200, last_response.status
View
4 test/unit/linkset_test.rb
@@ -6,7 +6,7 @@ class LinksetTest < ActiveSupport::TestCase
context "with a linkset" do
setup do
- @linkset = FactoryGirl.build(:linkset)
+ @linkset = build(:linkset)
end
should "be valid with factory" do
@@ -28,7 +28,7 @@ class LinksetTest < ActiveSupport::TestCase
context "with a Gem::Specification" do
setup do
@spec = gem_specification_from_gem_fixture('test-0.0.0')
- @linkset = FactoryGirl.create(:linkset)
+ @linkset = create(:linkset)
@linkset.update_attributes_from_gem_specification!(@spec)
end
View
12 test/unit/ownership_test.rb
@@ -2,7 +2,7 @@
class OwnershipTest < ActiveSupport::TestCase
should "be valid with factory" do
- assert FactoryGirl.build(:ownership).valid?
+ assert build(:ownership).valid?
end
should belong_to :rubygem
@@ -12,8 +12,8 @@ class OwnershipTest < ActiveSupport::TestCase
context "with ownership" do
setup do
- @ownership = FactoryGirl.create(:ownership)
- FactoryGirl.create(:version, :rubygem => @ownership.rubygem)
+ @ownership = create(:ownership)
+ create(:version, :rubygem => @ownership.rubygem)
end
subject { @ownership }
@@ -23,9 +23,9 @@ class OwnershipTest < ActiveSupport::TestCase
context "with multiple ownerships on the same rubygem" do
setup do
- @rubygem = FactoryGirl.create(:rubygem)
- @ownership_one = FactoryGirl.create(:ownership, :rubygem => @rubygem)
- @ownership_two = FactoryGirl.create(:ownership, :rubygem => @rubygem)
+ @rubygem = create(:rubygem)
+ @ownership_one = create(:ownership, :rubygem => @rubygem)
+ @ownership_two = create(:ownership, :rubygem => @rubygem)
end
should "allow deletion of one ownership" do
View
10 test/unit/pusher_test.rb
@@ -17,7 +17,7 @@ class PusherTest < ActiveSupport::TestCase
context "creating a new gemcutter" do
setup do
- @user = FactoryGirl.create(:user)
+ @user = create(:user)
@gem = gem_file
@cutter = Pusher.new(@user, @gem)
end
@@ -94,7 +94,7 @@ class PusherTest < ActiveSupport::TestCase
end
should "bring up existing gem with matching spec" do
- @rubygem = FactoryGirl.create(:rubygem)
+ @rubygem = create(:rubygem)
spec = "spec"
stub(spec).name { @rubygem.name }
stub(spec).version { "1.3.3.7" }
@@ -115,7 +115,7 @@ class PusherTest < ActiveSupport::TestCase
context "with a existing rubygem" do
setup do
- @rubygem = FactoryGirl.create(:rubygem)
+ @rubygem = create(:rubygem)
stub(@cutter).rubygem { @rubygem }
end
@@ -129,14 +129,14 @@ class PusherTest < ActiveSupport::TestCase
end
should "be false if not owned by user and an indexed version exists" do
- FactoryGirl.create(:version, :rubygem => @rubygem, :number => '0.1.1')
+ create(:version, :rubygem => @rubygem, :number => '0.1.1')
assert ! @cutter.authorize
assert_equal "You do not have permission to push to this gem.", @cutter.message
assert_equal 403, @cutter.code
end
should "be true if not owned by user but no indexed versions exist" do
- FactoryGirl.create(:version, :rubygem => @rubygem, :number => '0.1.1', :indexed => false)
+ create(:version, :rubygem => @rubygem, :number => '0.1.1', :indexed => false)
assert @cutter.authorize
end
end
View
6 test/unit/rubyforger_test.rb
@@ -5,7 +5,7 @@ class RubyforgerTest < ActiveSupport::TestCase
setup do
@email = "blah@blah.com"
@password = "secret"
- @rubyforger = FactoryGirl.create(:rubyforger, :email => @email,
+ @rubyforger = create(:rubyforger, :email => @email,
:encrypted_password => Digest::MD5.hexdigest(@password))
end
@@ -23,7 +23,7 @@ class RubyforgerTest < ActiveSupport::TestCase
end
should "transfer over with valid password" do
- user = FactoryGirl.create(:user, :email => @email)
+ user = create(:user, :email => @email)
assert_equal user, Rubyforger.transfer(@email, @password)
assert User.authenticate(@email, @password)
@@ -31,7 +31,7 @@ class RubyforgerTest < ActiveSupport::TestCase
end
should "fail transfer when password is wrong" do
- FactoryGirl.create(:user, :email => @email)
+ create(:user, :email => @email)
assert_nil Rubyforger.transfer(@email, "trogdor")
assert Rubyforger.exists?(@rubyforger.id)
View
136 test/unit/rubygem_test.rb
@@ -3,7 +3,7 @@
class RubygemTest < ActiveSupport::TestCase
context "with a saved rubygem" do
setup do
- @rubygem = FactoryGirl.create(:rubygem, :name => "SomeGem")
+ @rubygem = create(:rubygem, :name => "SomeGem")
end
subject { @rubygem }
@@ -22,10 +22,10 @@ class RubygemTest < ActiveSupport::TestCase
should_not allow_value("\342\230\203").for(:name)
should "reorder versions with platforms properly" do
- version3_ruby = FactoryGirl.create(:version, :rubygem => @rubygem, :number => "3.0.0", :platform => "ruby")
- version3_mswin = FactoryGirl.create(:version, :rubygem => @rubygem, :number => "3.0.0", :platform => "mswin")
- version2_ruby = FactoryGirl.create(:version, :rubygem => @rubygem, :number => "2.0.0", :platform => "ruby")
- version1_linux = FactoryGirl.create(:version, :rubygem => @rubygem, :number => "1.0.0", :platform => "linux")
+ version3_ruby = create(:version, :rubygem => @rubygem, :number => "3.0.0", :platform => "ruby")
+ version3_mswin = create(:version, :rubygem => @rubygem, :number => "3.0.0", :platform => "mswin")
+ version2_ruby = create(:version, :rubygem => @rubygem, :number => "2.0.0", :platform => "ruby")
+ version1_linux = create(:version, :rubygem => @rubygem, :number => "1.0.0", :platform => "linux")
@rubygem.reorder_versions
@@ -42,12 +42,12 @@ class RubygemTest < ActiveSupport::TestCase
end
should "order latest platform gems with latest uniquely" do
- pre = FactoryGirl.create(:version, :rubygem => @rubygem, :number => "1.5.0.pre", :platform => "ruby", :prerelease => true)
- ming = FactoryGirl.create(:version, :rubygem => @rubygem, :number => "1.4.2.1", :platform => "x86-mingw32")
- win = FactoryGirl.create(:version, :rubygem => @rubygem, :number => "1.4.2.1", :platform => "x86-mswin32")
- ruby = FactoryGirl.create(:version, :rubygem => @rubygem, :number => "1.4.2", :platform => "ruby")
- java = FactoryGirl.create(:version, :rubygem => @rubygem, :number => "1.4.2", :platform => "java")
- old = FactoryGirl.create(:version, :rubygem => @rubygem, :number => "1.4.1", :platform => "ruby")
+ pre = create(:version, :rubygem => @rubygem, :number => "1.5.0.pre", :platform => "ruby", :prerelease => true)
+ ming = create(:version, :rubygem => @rubygem, :number => "1.4.2.1", :platform => "x86-mingw32")
+ win = create(:version, :rubygem => @rubygem, :number => "1.4.2.1", :platform => "x86-mswin32")
+ ruby = create(:version, :rubygem => @rubygem, :number => "1.4.2", :platform => "ruby")
+ java = create(:version, :rubygem => @rubygem, :number => "1.4.2", :platform => "java")
+ old = create(:version, :rubygem => @rubygem, :number => "1.4.1", :platform => "ruby")
@rubygem.reorder_versions
@@ -60,8 +60,8 @@ class RubygemTest < ActiveSupport::TestCase
end
should "not return platform gem for latest if the ruby version is old" do
- version3_mswin = FactoryGirl.create(:version, :rubygem => @rubygem, :number => "3.0.0", :platform => "mswin")
- version2_ruby = FactoryGirl.create(:version, :rubygem => @rubygem, :number => "2.0.0", :platform => "ruby")
+ version3_mswin = create(:version, :rubygem => @rubygem, :number => "3.0.0", :platform => "mswin")
+ version2_ruby = create(:version, :rubygem => @rubygem, :number => "2.0.0", :platform => "ruby")
@rubygem.reorder_versions
@@ -74,8 +74,8 @@ class RubygemTest < ActiveSupport::TestCase
end
should "return the ruby version for most_recent if one exists" do
- FactoryGirl.create(:version, :rubygem => @rubygem, :number => "3.0.0", :platform => "mswin", :built_at => 1.year.from_now)
- version3_ruby = FactoryGirl.create(:version, :rubygem => @rubygem, :number => "3.0.0", :platform => "ruby")
+ create(:version, :rubygem => @rubygem, :number => "3.0.0", :platform => "mswin", :built_at => 1.year.from_now)
+ version3_ruby = create(:version, :rubygem => @rubygem, :number => "3.0.0", :platform => "ruby")
@rubygem.reorder_versions
@@ -84,37 +84,37 @@ class RubygemTest < ActiveSupport::TestCase
should "can find when the first built date was" do
Timecop.travel(DateTime.now) do
- FactoryGirl.create(:version, :rubygem => @rubygem, :number => "3.0.0", :built_at => 1.day.ago)
- FactoryGirl.create(:version, :rubygem => @rubygem, :number => "2.0.0", :built_at => 2.days.ago)
- FactoryGirl.create(:version, :rubygem => @rubygem, :number => "1.0.0", :built_at => 3.days.ago)
- FactoryGirl.create(:version, :rubygem => @rubygem, :number => "1.0.0.beta", :built_at => 4.days.ago)
+ create(:version, :rubygem => @rubygem, :number => "3.0.0", :built_at => 1.day.ago)
+ create(:version, :rubygem => @rubygem, :number => "2.0.0", :built_at => 2.days.ago)
+ create(:version, :rubygem => @rubygem, :number => "1.0.0", :built_at => 3.days.ago)
+ create(:version, :rubygem => @rubygem, :number => "1.0.0.beta", :built_at => 4.days.ago)
assert_equal 4.days.ago.to_date, @rubygem.first_built_date.to_date
end
end
should "have a most_recent version if only a platform version exists" do
- version1 = FactoryGirl.create(:version, :rubygem => @rubygem, :number => "1.0.0", :platform => "linux")
+ version1 = create(:version, :rubygem => @rubygem, :number => "1.0.0", :platform => "linux")
assert_equal version1, @rubygem.reload.versions.most_recent
end
should "return the release version for most_recent if one exists" do
- FactoryGirl.create(:version, :rubygem => @rubygem, :number => "2.0.pre", :platform => "ruby")
- version1 = FactoryGirl.create(:version, :rubygem => @rubygem, :number => "1.0.0", :platform => "ruby")
+ create(:version, :rubygem => @rubygem, :number => "2.0.pre", :platform => "ruby")
+ version1 = create(:version, :rubygem => @rubygem, :number => "1.0.0", :platform => "ruby")
assert_equal version1, @rubygem.reload.versions.most_recent
end
should "have a most_recent version if only a prerelease version exists" do
- version1pre = FactoryGirl.create(:version, :rubygem => @rubygem, :number => "1.0.pre", :platform => "ruby")
+ version1pre = create(:version, :rubygem => @rubygem, :number => "1.0.pre", :platform => "ruby")
assert_equal version1pre, @rubygem.reload.versions.most_recent
end
should "return the most_recent indexed version when a more recent yanked version exists" do
- FactoryGirl.create(:version, :rubygem => @rubygem, :number => "0.1.1", :indexed => false)
- indexed_v1 = FactoryGirl.create(:version, :rubygem => @rubygem, :number => "0.1.0", :indexed => true)
+ create(:version, :rubygem => @rubygem, :number => "0.1.1", :indexed => false)
+ indexed_v1 = create(:version, :rubygem => @rubygem, :number => "0.1.0", :indexed => true)
assert_equal indexed_v1.reload, @rubygem.reload.versions.most_recent
end
@@ -122,7 +122,7 @@ class RubygemTest < ActiveSupport::TestCase
context "with a rubygem" do
setup do
- @rubygem = FactoryGirl.build(:rubygem, :linkset => nil)
+ @rubygem = build(:rubygem, :linkset => nil)
end
['1337', 'Snakes!', ['zomg']].each do |bad_name|
@@ -145,7 +145,7 @@ class RubygemTest < ActiveSupport::TestCase
end
should "return version errors in #all_errors" do
- @version = FactoryGirl.build(:version)
+ @version = build(:version)
@specification = gem_specification_from_gem_fixture('test-0.0.0')
@specification.authors = [3]
@@ -171,7 +171,7 @@ class RubygemTest < ActiveSupport::TestCase
context "with a user" do
setup do
- @user = FactoryGirl.create(:user)
+ @user = create(:user)
@rubygem.save
end
@@ -181,7 +181,7 @@ class RubygemTest < ActiveSupport::TestCase
end
should "not be able to assign ownership when owners exist" do
- @new_user = FactoryGirl.create(:user)
+ @new_user = create(:user)
@rubygem.ownerships.create(:user => @new_user)
@rubygem.create_ownership(@user)
assert_equal @rubygem.reload.owners, [@new_user]
@@ -191,11 +191,11 @@ class RubygemTest < ActiveSupport::TestCase
context "with a user" do
setup do