From 0ddecbf0b226a2da545c0a324f0e5fe46c7a209a Mon Sep 17 00:00:00 2001 From: Seth Call Date: Tue, 12 Feb 2013 23:39:53 -0600 Subject: [PATCH] * adding test file to satisfy carrierwave-based model --- .gitignore | 3 +++ app/controllers/artifacts_controller.rb | 2 +- spec/factories.rb | 4 +++- spec/fixtures/files/jkclient.exe | 2 ++ spec/requests/artifacts_api_spec.rb | 2 +- 5 files changed, 10 insertions(+), 3 deletions(-) create mode 100644 spec/fixtures/files/jkclient.exe diff --git a/.gitignore b/.gitignore index 63cbab4e8..8ac4e2e21 100644 --- a/.gitignore +++ b/.gitignore @@ -23,6 +23,9 @@ doc/ .idea *.iml + +artifacts + Gemfile.lock .sass-cache log/development.log.age diff --git a/app/controllers/artifacts_controller.rb b/app/controllers/artifacts_controller.rb index 5230cb9cc..11ec4f149 100644 --- a/app/controllers/artifacts_controller.rb +++ b/app/controllers/artifacts_controller.rb @@ -29,7 +29,7 @@ class ArtifactsController < ApiController if @artifact.nil? render :json => {}, :status => :ok else - render :json => { "version" => @artifact.version, "uri" => @artifact.uri }, :status => :ok + render :json => { "version" => @artifact.version, "uri" => @artifact.uri.path }, :status => :ok end end diff --git a/spec/factories.rb b/spec/factories.rb index 575fe1852..1c74856eb 100644 --- a/spec/factories.rb +++ b/spec/factories.rb @@ -1,3 +1,5 @@ +include ActionDispatch::TestProcess # added for artifact_update http://stackoverflow.com/questions/5990835/factory-with-carrierwave-upload-field + FactoryGirl.define do factory :user, :class => JamRuby::User do sequence(:email) { |n| "person_#{n}@example.com"} @@ -80,7 +82,7 @@ FactoryGirl.define do factory :artifact_update, :class => JamRuby::ArtifactUpdate do sequence(:version) { |n| "0.1.#{n}" } - uri { "http://somewhere/jkclient.msi" } + uri { fixture_file_upload("#{Rails.root.to_s}/spec/fixtures/files/jkclient.exe", "application/x-msdownload") } product { "JamClient/Win32" } environment { "public" } sha1 { "blurp" } diff --git a/spec/fixtures/files/jkclient.exe b/spec/fixtures/files/jkclient.exe new file mode 100644 index 000000000..b076f565f --- /dev/null +++ b/spec/fixtures/files/jkclient.exe @@ -0,0 +1,2 @@ +Some serious binary stuff is in here. +010101010 beep boop 01010101 \ No newline at end of file diff --git a/spec/requests/artifacts_api_spec.rb b/spec/requests/artifacts_api_spec.rb index cc003ed73..1c75f1d0a 100644 --- a/spec/requests/artifacts_api_spec.rb +++ b/spec/requests/artifacts_api_spec.rb @@ -14,7 +14,7 @@ describe "Artifact API ", :type => :api do it "matches an artifact" do get '/api/versioncheck.json', { :os=>'Win32', :product=>'JamClient'} last_response.status.should eql(200) - JSON.parse(last_response.body).should eql({ "version" => @artifact.version, "uri" => @artifact.uri}) + JSON.parse(last_response.body).should eql({ "version" => @artifact.version, "uri" => @artifact.uri.path}) end it "matches no artifact" do