Skip to content
This repository was archived by the owner on Nov 9, 2017. It is now read-only.

Introduce the Dummy. #70

Merged
merged 9 commits into from
Jul 27, 2017
Merged

Introduce the Dummy. #70

merged 9 commits into from
Jul 27, 2017

Conversation

dixpac
Copy link
Contributor

@dixpac dixpac commented Jul 23, 2017

First step:

  • Convert controller tests to integration tests
  • Move storage configurations to dummy
  • Remove unnecessary requires

r? @dhh
We could slim down a bit this dummy, to remove rails components that are not used at the moment, ex: ActionCable ?

require "yaml"
SERVICE_CONFIGURATIONS = begin
YAML.load_file(File.expand_path("../service/configurations.yml", __FILE__)).deep_symbolize_keys
YAML.load_file(File.expand_path("../dummy/config/storage_services.yml", __FILE__)).deep_symbolize_keys
Copy link
Contributor Author

@dixpac dixpac Jul 23, 2017

Choose a reason for hiding this comment

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

I've moved the configurations inside the dummy, otherwise dummy app will fail on the boot. Also, because of this current Travis tests will fail

@dhh
Copy link
Member

dhh commented Jul 24, 2017

I'd welcome slimming this down. There are a ton of files that aren't relevant. But if you could otherwise bring in line with master, we can merge. Definitely would like to switch to integration tests.

@dixpac dixpac force-pushed the welcome_you_dummy branch from 872b3bf to e0cd338 Compare July 25, 2017 11:52
assert_equal "inline; filename=\"#{@blob.filename}\"", @response.headers["Content-Disposition"]
get rails_disk_blob_url(
filename: "hello.txt",
content_type: @blob.content_type,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Here I'd to pas content-length in order for tests to pass. @dhh I've noticed that you changed the approach Here.

Not sure if your intention was to pass content_type of to figure him out automatically ?

Copy link
Member

Choose a reason for hiding this comment

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

Plan is to pass it in to the services, since they don't store it, and the blob has it.

@@ -35,6 +35,7 @@ class ActiveStorage::BlobTest < ActiveSupport::TestCase

private
def expected_url_for(blob, disposition: :inline)
"/rails/active_storage/disk/#{ActiveStorage.verifier.generate(blob.key, expires_in: 5.minutes, purpose: :blob_key)}/#{blob.filename}?disposition=#{disposition}&content_type=#{blob.content_type}"
query_string = { content_type: blob.content_type, disposition: disposition }.to_param
Copy link
Contributor Author

@dixpac dixpac Jul 25, 2017

Choose a reason for hiding this comment

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

Rails encodes the url so I'd to encode the query_string in order to match it sucessfully

@@ -6,7 +6,7 @@ class ActiveStorage::Service::DiskServiceTest < ActiveSupport::TestCase
include ActiveStorage::Service::SharedServiceTests

test "url generation" do
assert_match /rails\/active_storage\/disk\/.*\/avatar\.png\?disposition=inline/,
assert_match /rails\/active_storage\/disk\/.*\/avatar\.png\?.+disposition=inline/,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed a regex a bit because of the url encoding

@dixpac
Copy link
Contributor Author

dixpac commented Jul 25, 2017

@dhh I rebase it from the latest. Commit is a bit big(sorry) so I've added few comments on what I've changed from the first PR.

In the next commits/days I will try to slim this down

@dixpac
Copy link
Contributor Author

dixpac commented Jul 26, 2017

@dhh I slimmed this quiet a bit (maybe too much) by removing all rails components we are not using at the moment.

There is one more approach I've tried and that is to slim all the way to the smallest app possible, take a look commit and here small app
(this has just a few files)

What approach do you think is better ?

assert_equal "text/plain", @response.headers["Content-Type"]
end

test "sending blob as attachment" do
get :show, params: { filename: @blob.filename, encoded_key: ActiveStorage.verifier.generate(@blob.key, expires_in: 5.minutes, purpose: :blob_key), disposition: :attachment }
assert_equal "attachment; filename=\"#{@blob.filename}\"", @response.headers["Content-Disposition"]
get rails_disk_blob_url(
Copy link
Member

Choose a reason for hiding this comment

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

Reminds me that now this should be rails_disk_service_url since the DiskController no longer deals with blobs, but only with keys.

@dhh
Copy link
Member

dhh commented Jul 26, 2017

I think it's good with the smallest possible app. We're basically just setting all this stuff up to be able to use the engine initialization and integration tests properly.

@dhh
Copy link
Member

dhh commented Jul 26, 2017

(Needs some rebasing after George merged the direct upload feature for the disk controller).

@dixpac dixpac force-pushed the welcome_you_dummy branch 4 times, most recently from b96f372 to 51c14ab Compare July 26, 2017 17:00
@dixpac
Copy link
Contributor Author

dixpac commented Jul 26, 2017

@dhh I've rebased and added small dummy app

@kaspth
Copy link
Contributor

kaspth commented Jul 26, 2017

Won't we just need to add back Action View and Sprockets when the direct upload JS arrives and has to be integration/system tested?

@dixpac
Copy link
Contributor Author

dixpac commented Jul 26, 2017

@kaspth yes we would! That was my initial approach just to remove action cable and action mailer and leave other components in there (for the future). But, there were was concerned with the size of the dummy so I just created it as small as "possible", to cover current use.

The full dummy app would be most flexible/easy for the future use of testing.

@dhh
Copy link
Member

dhh commented Jul 26, 2017 via email

@dixpac
Copy link
Contributor Author

dixpac commented Jul 26, 2017 via email

@dhh
Copy link
Member

dhh commented Jul 26, 2017

There are a couple of conflicts against master, btw.

@dixpac dixpac force-pushed the welcome_you_dummy branch from 28b1d3d to fa20b41 Compare July 27, 2017 08:18
@dixpac
Copy link
Contributor Author

dixpac commented Jul 27, 2017

I've add back ActionView, Sprockets.... Now the dummy is larger because there is not a lot we can remove. I've removed ActionCable, ActionMailer and few config files.

IMO it is not worth removing more, because we are going off the rails 😃 🚂

@dhh
Copy link
Member

dhh commented Jul 27, 2017

The build is currently failing. Can you have a look?

@dixpac dixpac force-pushed the welcome_you_dummy branch from fa20b41 to d92b9f7 Compare July 27, 2017 20:08
@dixpac
Copy link
Contributor Author

dixpac commented Jul 27, 2017

@dhh oh, sorry I fixed it :)

@dhh dhh merged commit e64e3f1 into rails:master Jul 27, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants