-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
187aa31
commit 396654d
Showing
14 changed files
with
386 additions
and
91 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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 | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,4 @@ | ||
# frozen_string_literal: true | ||
|
||
source "https://rubygems.org" | ||
|
||
# Specify your gem's dependencies in deep_versionable.gemspec | ||
gemspec | ||
|
||
gem "rake", "~> 13.0" | ||
|
||
gem "rspec", "~> 3.0" | ||
|
||
gem "rubocop", "~> 1.7" |
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,96 @@ | ||
PATH | ||
remote: . | ||
specs: | ||
deep_versionable (0.1.0) | ||
activerecord | ||
|
||
GEM | ||
remote: https://rubygems.org/ | ||
specs: | ||
actionpack (6.1.7.6) | ||
actionview (= 6.1.7.6) | ||
activesupport (= 6.1.7.6) | ||
rack (~> 2.0, >= 2.0.9) | ||
rack-test (>= 0.6.3) | ||
rails-dom-testing (~> 2.0) | ||
rails-html-sanitizer (~> 1.0, >= 1.2.0) | ||
actionview (6.1.7.6) | ||
activesupport (= 6.1.7.6) | ||
builder (~> 3.1) | ||
erubi (~> 1.4) | ||
rails-dom-testing (~> 2.0) | ||
rails-html-sanitizer (~> 1.1, >= 1.2.0) | ||
activemodel (6.1.7.6) | ||
activesupport (= 6.1.7.6) | ||
activerecord (6.1.7.6) | ||
activemodel (= 6.1.7.6) | ||
activesupport (= 6.1.7.6) | ||
activesupport (6.1.7.6) | ||
concurrent-ruby (~> 1.0, >= 1.0.2) | ||
i18n (>= 1.6, < 2) | ||
minitest (>= 5.1) | ||
tzinfo (~> 2.0) | ||
zeitwerk (~> 2.3) | ||
builder (3.2.4) | ||
concurrent-ruby (1.2.2) | ||
crass (1.0.6) | ||
diff-lcs (1.4.4) | ||
erubi (1.12.0) | ||
generator_spec (0.9.4) | ||
activesupport (>= 3.0.0) | ||
railties (>= 3.0.0) | ||
i18n (1.14.1) | ||
concurrent-ruby (~> 1.0) | ||
loofah (2.21.4) | ||
crass (~> 1.0.2) | ||
nokogiri (>= 1.12.0) | ||
method_source (1.0.0) | ||
minitest (5.19.0) | ||
nokogiri (1.15.4-x86_64-darwin) | ||
racc (~> 1.4) | ||
racc (1.7.1) | ||
rack (2.2.8) | ||
rack-test (2.1.0) | ||
rack (>= 1.3) | ||
rails-dom-testing (2.2.0) | ||
activesupport (>= 5.0.0) | ||
minitest | ||
nokogiri (>= 1.6) | ||
rails-html-sanitizer (1.6.0) | ||
loofah (~> 2.21) | ||
nokogiri (~> 1.14) | ||
railties (6.1.7.6) | ||
actionpack (= 6.1.7.6) | ||
activesupport (= 6.1.7.6) | ||
method_source | ||
rake (>= 12.2) | ||
thor (~> 1.0) | ||
rake (13.0.6) | ||
rspec (3.10.0) | ||
rspec-core (~> 3.10.0) | ||
rspec-expectations (~> 3.10.0) | ||
rspec-mocks (~> 3.10.0) | ||
rspec-core (3.10.1) | ||
rspec-support (~> 3.10.0) | ||
rspec-expectations (3.10.1) | ||
diff-lcs (>= 1.2.0, < 2.0) | ||
rspec-support (~> 3.10.0) | ||
rspec-mocks (3.10.2) | ||
diff-lcs (>= 1.2.0, < 2.0) | ||
rspec-support (~> 3.10.0) | ||
rspec-support (3.10.2) | ||
thor (1.3.0) | ||
tzinfo (2.0.6) | ||
concurrent-ruby (~> 1.0) | ||
zeitwerk (2.6.11) | ||
|
||
PLATFORMS | ||
x86_64-darwin-22 | ||
|
||
DEPENDENCIES | ||
deep_versionable! | ||
generator_spec (~> 0.9.4) | ||
rspec | ||
|
||
BUNDLED WITH | ||
2.2.15 |
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 |
---|---|---|
|
@@ -8,17 +8,17 @@ Gem::Specification.new do |spec| | |
spec.authors = ["Daniel Fornarini"] | ||
spec.email = ["[email protected]"] | ||
|
||
spec.summary = "TODO: Write a short summary, because RubyGems requires one." | ||
spec.description = "TODO: Write a longer description or delete this line." | ||
spec.homepage = "TODO: Put your gem's website or public repo URL here." | ||
spec.summary = "Write a short summary, because RubyGems requires one." | ||
# spec.description = "TODO: Write a longer description or delete this line." | ||
# spec.homepage = "TODO: Put your gem's website or public repo URL here." | ||
spec.license = "MIT" | ||
spec.required_ruby_version = Gem::Requirement.new(">= 2.4.0") | ||
|
||
spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'" | ||
# spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'" | ||
|
||
spec.metadata["homepage_uri"] = spec.homepage | ||
spec.metadata["source_code_uri"] = "TODO: Put your gem's public repo URL here." | ||
spec.metadata["changelog_uri"] = "TODO: Put your gem's CHANGELOG.md URL here." | ||
# spec.metadata["homepage_uri"] = spec.homepage | ||
# spec.metadata["source_code_uri"] = "TODO: Put your gem's public repo URL here." | ||
# spec.metadata["changelog_uri"] = "TODO: Put your gem's CHANGELOG.md URL here." | ||
|
||
# Specify which files should be added to the gem when it is released. | ||
# The `git ls-files -z` loads the files in the RubyGem that have been added into git. | ||
|
@@ -34,4 +34,8 @@ Gem::Specification.new do |spec| | |
|
||
# For more information and examples about making a new gem, checkout our | ||
# guide at: https://bundler.io/guides/creating_gem.html | ||
|
||
spec.add_dependency "activerecord" | ||
spec.add_development_dependency "rspec" | ||
spec.add_development_dependency "generator_spec", "~> 0.9.4" | ||
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
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,88 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'rails_helper' | ||
|
||
RSpec.describe Version, type: :model do | ||
it 'should correctly reify a version' do | ||
post = Post.create!( | ||
body: 'Body Post', | ||
user: User.create!( | ||
first_name: 'John', | ||
last_name: 'Doe' | ||
), | ||
comments: [ | ||
Comment.create!( | ||
text: 'Comment 1', | ||
reactions: [ | ||
Reaction.create!( | ||
emoji: Emoji.create!(name: 'Emoji 1'), | ||
), | ||
Reaction.create!( | ||
emoji: Emoji.create!(name: 'Emoji 2'), | ||
) | ||
] | ||
), | ||
Comment.create!( | ||
text: 'Comment 2', | ||
reactions: [ | ||
Reaction.create!( | ||
emoji: Emoji.create!(name: 'Emoji 3'), | ||
), | ||
Reaction.create!( | ||
emoji: Emoji.create!(name: 'Emoji 4'), | ||
) | ||
] | ||
) | ||
] | ||
) | ||
|
||
post.versionize! | ||
|
||
reified_post = post.versions.last.reify | ||
|
||
expect(reified_post).to be_a(Version::Post) | ||
expect(reified_post.id).to eq(1) | ||
expect(reified_post.body).to eq('Body Post') | ||
|
||
expect(reified_post.user).to be_a(Version::User) | ||
expect(reified_post.user.id).to eq(1) | ||
expect(reified_post.user.first_name).to eq('John') | ||
expect(reified_post.user.last_name).to eq('Doe') | ||
|
||
expect(reified_post.comments).to be_a(Array) | ||
expect(reified_post.comments.length).to eq(2) | ||
|
||
expect(reified_post.comments[0]).to be_a(Version::Comment) | ||
expect(reified_post.comments[0].id).to eq(1) | ||
expect(reified_post.comments[0].text).to eq('Comment 1') | ||
expect(reified_post.comments[0].reactions).to be_a(Array) | ||
expect(reified_post.comments[0].reactions.length).to eq(2) | ||
expect(reified_post.comments[0].reactions[0]).to be_a(Version::Reaction) | ||
expect(reified_post.comments[0].reactions[0].id).to eq(1) | ||
expect(reified_post.comments[0].reactions[0].emoji).to be_a(Version::Emoji) | ||
expect(reified_post.comments[0].reactions[0].emoji.id).to eq(1) | ||
expect(reified_post.comments[0].reactions[0].emoji.name).to eq('Emoji 1') | ||
expect(reified_post.comments[0].reactions[1]).to be_a(Version::Reaction) | ||
expect(reified_post.comments[0].reactions[1].id).to eq(2) | ||
expect(reified_post.comments[0].reactions[1].emoji).to be_a(Version::Emoji) | ||
expect(reified_post.comments[0].reactions[1].emoji.id).to eq(2) | ||
expect(reified_post.comments[0].reactions[1].emoji.name).to eq('Emoji 2') | ||
|
||
expect(reified_post.comments[1]).to be_a(Version::Comment) | ||
expect(reified_post.comments[1].id).to eq(2) | ||
expect(reified_post.comments[1].text).to eq('Comment 2') | ||
expect(reified_post.comments[1].likes).to be_a(Array) | ||
expect(reified_post.comments[1].likes.length).to eq(2) | ||
expect(reified_post.comments[1].likes[0]).to be_a(Version::Like) | ||
expect(reified_post.comments[1].likes[0].id).to eq(3) | ||
expect(reified_post.comments[1].likes[0].user).to be_a(Version::User) | ||
expect(reified_post.comments[1].likes[0].user.id).to eq(4) | ||
expect(reified_post.comments[1].likes[0].user.name).to eq('User 2') | ||
expect(reified_post.comments[1].likes[1]).to be_a(Version::Like) | ||
expect(reified_post.comments[1].likes[1].id).to eq(4) | ||
expect(reified_post.comments[1].likes[1].user).to be_a(Version::User) | ||
expect(reified_post.comments[1].likes[1].user.id).to eq(5) | ||
expect(reified_post.comments[1].likes[1].user.name).to eq('User 4') | ||
end | ||
end | ||
|
Oops, something went wrong.