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

Fixing default import template doesn't extract columns from the latest uploaded file. #2446

Merged
merged 2 commits into from
Nov 2, 2016

Conversation

justin-lau
Copy link
Contributor

This MR fixes the issue described below.

Expected behavior

When the user decided he wants to replace the previously uploaded CSV file with another one, the updated columns should be extracted from the latest uploaded file.

Actual behavior

The columns are always extracted from the first uploaded file, regardless of subsequent changes to the file.

Reproduce steps

On the default CVS import template:

  1. Upload a file.
  2. Upload another totally different file. Should see that the columns are still from the first file.
October build

Master at 2659ae7

@justin-lau
Copy link
Contributor Author

I have written a test case for this, but I couldn't get the database working, without failing some of the existing tests.

public function testGetImportFilePath() {
    $model = new ExampleImportModel;
    $sessionKey = uniqid('session_key', true);

    $file1 = File::create([
        'data' => base_path().'/tests/fixtures/backend/models/ImportModel/file_1.txt'
    ]);

    $file2 = File::create([
        'data' => base_path().'/tests/fixtures/backend/models/ImportModel/file_2.txt'
    ]);

    $model->import_file()->add($file1, $sessionKey);
    $model->import_file()->add($file2, $sessionKey);

    $this->assertEquals(
        $file2->getLocalPath(), $model->getImportFilePath($sessionKey),
        'ImportModel::getImportFilePath() should return the last uploaded file.'
    );
}

daftspunk added a commit that referenced this pull request Nov 2, 2016
@daftspunk daftspunk merged commit 348dd85 into octobercms:develop Nov 2, 2016
@daftspunk
Copy link
Member

Thanks for taking the time to look in to this.

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

Successfully merging this pull request may close these issues.

2 participants