forked from igorman/data-engineering
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
data_file as an activemodel so we can have easy sweet validations
- Loading branch information
Showing
9 changed files
with
59 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -1,2 +1,12 @@ | |||
module DataFilesHelper | module DataFilesHelper | ||
def example_input_file_link | |||
'https://raw.github.com/lschallenges/data-engineering/master/example_input.tab' | |||
end | |||
|
|||
def data_file_label_content_with_link | |||
raw( | |||
"Please upload a tab-delimited file, like " + | |||
"<a href='#{example_input_file_link}'>this</a>." | |||
) | |||
end | |||
end | end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,9 @@ | |||
- if object.errors.any? | |||
#error_explanation | |||
.alert.alert-error | |||
The form contains | |||
= pluralize(object.errors.count, "error") | |||
\. | |||
%ul | |||
- object.errors.full_messages.each do |msg| | |||
%li= msg |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,5 @@ | |||
require 'spec_helper' | |||
|
|||
describe DataFile do | |||
it_should_behave_like "ActiveModel" | |||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,19 @@ | |||
# From https://gist.github.com/639089 | |||
|
|||
shared_examples_for "ActiveModel" do | |||
require 'test/unit/assertions' | |||
require 'active_model/lint' | |||
include Test::Unit::Assertions | |||
include ActiveModel::Lint::Tests | |||
|
|||
# to_s is to support ruby-1.9 | |||
ActiveModel::Lint::Tests.public_instance_methods.map{|m| m.to_s}.grep(/^test/).each do |m| | |||
example m.gsub('_',' ') do | |||
send m | |||
end | |||
end | |||
|
|||
def model | |||
subject | |||
end | |||
end |