Sha256: 8172018c93e00f29d5e963dbdf577c8198984a206335b7f87fc673587b7ef9eb

Contents?: true

Size: 1.92 KB

Versions: 6

Compression:

Stored size: 1.92 KB

Contents

require File.dirname(__FILE__) + "/../helpers"

class BrowsePublicProjectsTest < Test::Unit::TestCase
  include ::Integrity::Helpers

  test "#pretty_date" do
    pretty_date(Time.now).should == "today"
    pretty_date(Time.new - 86400).should == "yesterday"

    pretty_date(Time.mktime(1995, 12, 01)).should == "on Dec 01st"
    pretty_date(Time.mktime(1995, 12, 21)).should == "on Dec 21st"
    pretty_date(Time.mktime(1995, 12, 31)).should == "on Dec 31st"

    pretty_date(Time.mktime(1995, 12, 22)).should == "on Dec 22nd"
    pretty_date(Time.mktime(1995, 12, 22)).should == "on Dec 22nd"

    pretty_date(Time.mktime(1995, 12, 03)).should == "on Dec 03rd"
    pretty_date(Time.mktime(1995, 12, 23)).should == "on Dec 23rd"

    pretty_date(Time.mktime(1995, 12, 15)).should == "on Dec 15th"
    pretty_date(Time.mktime(1995, 12, 15)).should == "on Dec 15th"
    pretty_date(Time.mktime(1995, 12, 15)).should == "on Dec 15th"
  end

  describe "#push_url_for" do
    before(:each) do
      @project = Project.gen(:integrity)
      Integrity.config[:admin_username] = "admin"
      Integrity.config[:admin_password] = "test"

      stub(self).request {
        OpenStruct.new(:url => "http://integrity.example.org:1234")
      }
    end

    test "with auth disabled" do
      Integrity.config[:use_basic_auth] = false

      push_url_for(@project).should == "http://integrity.example.org:1234/integrity/push"
    end

    test "with auth and hashing enabled" do
      Integrity.config[:use_basic_auth]      = true
      Integrity.config[:hash_admin_password] = true

      push_url_for(@project).should == "http://admin:<password>@integrity.example.org:1234/integrity/push"
    end

    test "with auth enabled and hashing disabled" do
      Integrity.config[:use_basic_auth]      = true
      Integrity.config[:hash_admin_password] = false

      push_url_for(@project).should == "http://admin:test@integrity.example.org:1234/integrity/push"
    end
  end
end

Version data entries

6 entries across 6 versions & 3 rubygems

Version Path
foca-integrity-0.1.9.0 test/unit/helpers_test.rb
foca-integrity-0.1.9.1 test/unit/helpers_test.rb
oliyoung-integrity-0.1.9.0 test/unit/helpers_test.rb
integrity-0.1.9.1 test/unit/helpers_test.rb
integrity-0.1.9.0 test/unit/helpers_test.rb
integrity-0.1.9 test/unit/helpers_test.rb