Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature api download archive #5253

Merged
merged 4 commits into from
Oct 10, 2013

Conversation

karlhungus
Copy link
Contributor

Got a hint as to the fix from here ruby-grape/grape#412

@coveralls
Copy link

Coverage Status

Coverage decreased (-14.08%) when pulling 4e2b924fd71486640eede696a069faf21efa053f on karlhungus:feature-api-download-archive into 45efba5 on gitlabhq:master.

@@ -225,4 +225,15 @@
end
end

describe "GET /projects/:id/repository/archive/:sha" do
it "should get the archive" do
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe this test should also test the data given back? Response 200 is a bit to generic i think, you agree?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jvanbaarsen guilty, followed the example as given by the blobs tests above. I'm assuming you mean i take the body and attempt to ungzip it?
my main reason for not unpacking the received file was the time it would add to the already slow unit tests.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@karlhungus Maybe you can test if the data you received is a archive file?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jvanbaarsen this:

    it "should get the archive" do
      get api("/projects/#{project.id}/repository/archive", user)
      response.status.should == 200
      storage_path = Rails.root.join("tmp", "repositories")
      file_path = project.repository.archive_repo(nil, storage_path)
      File.open((file_path + 'compare'),'wb'){|f|f.write(response.body)}
      FileUtils.compare_file(file_path, file_path + 'compare').should be_true
    end

works... seems a bit heavy handed, what do you think?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah i agree, but what about the response.body, what type of data is that?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure what you mean (i suspect i'm being dumb) it's a tar.gz of the tip of the default branch, application/x-gzip...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can check the content_type, but it seems little value (and won't catch the problem that the second commit solved). Eh, i'll do that as well as above, if @randx doesn't like it i'll remove it

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@karlhungus I dont think it worth to test archive_repo method again here. Just check for correct status and content type

@jvanbaarsen
Copy link
Contributor

You can check for the application/x-gzip? That wat you're Sure that the data you getting back is as you expect it to be

@coveralls
Copy link

Coverage Status

Coverage remained the same when pulling a049e4af5315580208a7014823f3da845f5aa250 on karlhungus:feature-api-download-archive into 45efba5 on gitlabhq:master.

@dzaporozhets
Copy link
Contributor

@karlhungus do you need some sort of feedback from me?

@karlhungus
Copy link
Contributor Author

@randx If you are interested in this commit, wondering your opinion on the test @jvanbaarsen and I were talking about.

@dzaporozhets
Copy link
Contributor

@karlhungus ok I'll take a look :)

repo = user_project.repository
ref = params[:sha]
storage_path = Rails.root.join("tmp", "repositories")

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

extra line

@ghost ghost assigned dzaporozhets Oct 8, 2013
@dzaporozhets
Copy link
Contributor

@karlhungus ping me when ready

Izaak Alpert added 4 commits October 10, 2013 09:19
defaults to HEAD

Conflicts:
	spec/requests/api/repositories_spec.rb

Change-Id: Id114aca6c59d75f18e49bf9f33809a04e010bfb6
Conflicts:
	doc/api/repositories.md

Change-Id: I7ebc39b47ff860813d9622ba6776583536e6e384
Change-Id: I2b0752bc2593a944d42dde0ffe0ef9ce408228a5
Change-Id: Id2cae87c8cd383bc6cbcbdecf0f77c161bb82eab
@karlhungus
Copy link
Contributor Author

@randx allright, think this one is good

@coveralls
Copy link

Coverage Status

Coverage remained the same when pulling 72bf6a4 on karlhungus:feature-api-download-archive into e8d1e82 on gitlabhq:master.

dzaporozhets added a commit that referenced this pull request Oct 10, 2013
@dzaporozhets dzaporozhets merged commit 4123c76 into gitlabhq:master Oct 10, 2013
@dzaporozhets
Copy link
Contributor

@karlhungus next time you submit a feature - you can add it to changelog and mention your name. Like this one
By this you save me a bit of work :)

@karlhungus
Copy link
Contributor Author

@randx allright, i'll let @amacarthur know as well :)

@dzaporozhets
Copy link
Contributor

@karlhungus thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

4 participants