-
Notifications
You must be signed in to change notification settings - Fork 119
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* ignore ruby version this will be up to the developer to decide. * add and configure RSpec * add basic specs for the functionality just test that the fields are created. * add testing section to README
- Loading branch information
1 parent
7eb32a3
commit b87a92b
Showing
12 changed files
with
153 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,4 @@ | |
mongoid-paperclip-*.gem | ||
.*swp | ||
.*swo | ||
.ruby-version |
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 | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
--color |
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 | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
source 'https://rubygems.org' | ||
|
||
# Use the gemspec for all dependencies. | ||
gemspec |
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 | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
PATH | ||
remote: . | ||
specs: | ||
mongoid-paperclip (0.0.10) | ||
mongoid | ||
paperclip (>= 2.3.6, != 4.3.0) | ||
|
||
GEM | ||
remote: https://rubygems.org/ | ||
specs: | ||
activemodel (4.2.6) | ||
activesupport (= 4.2.6) | ||
builder (~> 3.1) | ||
activesupport (4.2.6) | ||
i18n (~> 0.7) | ||
json (~> 1.7, >= 1.7.7) | ||
minitest (~> 5.1) | ||
thread_safe (~> 0.3, >= 0.3.4) | ||
tzinfo (~> 1.1) | ||
bson (4.1.1) | ||
builder (3.2.2) | ||
climate_control (0.0.3) | ||
activesupport (>= 3.0) | ||
cocaine (0.5.8) | ||
climate_control (>= 0.0.3, < 1.0) | ||
diff-lcs (1.2.5) | ||
i18n (0.7.0) | ||
json (1.8.3) | ||
mime-types (3.1) | ||
mime-types-data (~> 3.2015) | ||
mime-types-data (3.2016.0521) | ||
mimemagic (0.3.2) | ||
minitest (5.9.0) | ||
mongo (2.2.5) | ||
bson (~> 4.0) | ||
mongoid (5.1.3) | ||
activemodel (~> 4.0) | ||
mongo (~> 2.1) | ||
origin (~> 2.2) | ||
tzinfo (>= 0.3.37) | ||
origin (2.2.0) | ||
paperclip (5.0.0) | ||
activemodel (>= 4.2.0) | ||
activesupport (>= 4.2.0) | ||
cocaine (~> 0.5.5) | ||
mime-types | ||
mimemagic (~> 0.3.0) | ||
rake (11.2.2) | ||
rspec (3.5.0) | ||
rspec-core (~> 3.5.0) | ||
rspec-expectations (~> 3.5.0) | ||
rspec-mocks (~> 3.5.0) | ||
rspec-core (3.5.2) | ||
rspec-support (~> 3.5.0) | ||
rspec-expectations (3.5.0) | ||
diff-lcs (>= 1.2.0, < 2.0) | ||
rspec-support (~> 3.5.0) | ||
rspec-mocks (3.5.0) | ||
diff-lcs (>= 1.2.0, < 2.0) | ||
rspec-support (~> 3.5.0) | ||
rspec-support (3.5.0) | ||
thread_safe (0.3.5) | ||
tzinfo (1.2.2) | ||
thread_safe (~> 0.1) | ||
|
||
PLATFORMS | ||
ruby | ||
|
||
DEPENDENCIES | ||
mongoid-paperclip! | ||
rake | ||
rspec | ||
|
||
BUNDLED WITH | ||
1.12.5 |
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 | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
require 'mongoid_paperclip' |
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 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 | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
test: | ||
clients: | ||
default: | ||
database: mongoid-paperclip | ||
hosts: | ||
- localhost:27017 |
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 | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
require 'spec_helper' | ||
|
||
RSpec.describe Mongoid::Paperclip, type: :unit do | ||
let(:user) { User.create } | ||
|
||
before do | ||
user.update avatar: File.new('spec/support/avatar.png', 'rb') | ||
end | ||
|
||
it "stores file_name" do | ||
expect(user.avatar_file_name).to eq("avatar.png") | ||
end | ||
|
||
it "stores content_type" do | ||
expect(user.avatar_content_type).to eq("image/png") | ||
end | ||
|
||
it "stores file_size" do | ||
expect(user.avatar_file_size).to eq(357) | ||
end | ||
|
||
it "stores updated_at" do | ||
expect(user.avatar_updated_at).to be_present | ||
end | ||
|
||
it "stores fingerprint" do | ||
expect(user.avatar_fingerprint).to eq("2584a801e588b3fcf4aa074efff77e30") | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
require 'rspec' | ||
require 'mongoid' | ||
require 'mongoid-paperclip' | ||
|
||
ENV['MONGOID_ENV'] = 'test' | ||
Mongoid.load!('./spec/config/mongoid.yml') | ||
|
||
RSpec.configure do |config| | ||
config.before(:each) do | ||
Mongoid.purge! | ||
end | ||
end | ||
|
||
class User | ||
include Mongoid::Document | ||
include Mongoid::Paperclip | ||
|
||
has_mongoid_attached_file :avatar | ||
validates_attachment_file_name :avatar, matches: [/image/] | ||
end |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.