diff --git a/.travis.yml b/.travis.yml index 680a3f9..d7e2a7e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,9 +4,6 @@ addons: services: - postgresql before_install: - # Setup chromedriver for LuckyFlow - - sudo apt-get install chromium-chromedriver - # Setup assets - yarn install - yarn prod diff --git a/README.md b/README.md index 2b2427c..520cc34 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,8 @@ Microgit is meant to be a self-hosting open source that will be an alternative to gitlab. See this as a crystal version of gitea but with own design. +This repository has been updated to require Crystal 1.16.3. + ## What it can do now: * Git pull/push/fetch * See tree of files diff --git a/shard.lock b/shard.lock index 8ba9d9f..0611f8e 100644 --- a/shard.lock +++ b/shard.lock @@ -1,146 +1,134 @@ -version: 1.0 +version: 2.0 shards: apatite: - github: watzon/apatite - commit: 9ed28220eb7136eecc05c70cb16b7a41a6d0e958 + git: https://github.com/watzon/apatite.git + version: 0.1.0+git.commit.9ed28220eb7136eecc05c70cb16b7a41a6d0e958 authentic: - github: luckyframework/authentic + git: https://github.com/luckyframework/authentic.git version: 0.5.4 avram: - github: luckyframework/avram + git: https://github.com/luckyframework/avram.git version: 0.14.0 - avram_scoped_id: - github: microgit-com/avram_scoped_id - commit: d5853177e55fabc04c9456f5b45f073e3f5a54d9 - blank: - github: kostya/blank + git: https://github.com/kostya/blank.git version: 0.1.0 cadmium_classifier: - github: cadmiumcr/classifier - commit: 22609f050564fb90595bdbdfdf4007e67861c5c4 + git: https://github.com/cadmiumcr/classifier.git + version: 0.1.0+git.commit.22609f050564fb90595bdbdfdf4007e67861c5c4 cadmium_tokenizer: - github: cadmiumcr/tokenizer - commit: e7f8733e4d8ead9a811b6f41d0b5fa621ba03033 + git: https://github.com/cadmiumcr/tokenizer.git + version: 0.1.0+git.commit.e7f8733e4d8ead9a811b6f41d0b5fa621ba03033 carbon: - github: luckyframework/carbon + git: https://github.com/luckyframework/carbon.git version: 0.1.1 cry: - github: paulcsmith/cry + git: https://github.com/paulcsmith/cry.git version: 0.4.2 db: - github: crystal-lang/crystal-db + git: https://github.com/crystal-lang/crystal-db.git version: 0.9.0 dexter: - github: luckyframework/dexter + git: https://github.com/luckyframework/dexter.git version: 0.2.0 dotenv: - github: gdotdesign/cr-dotenv + git: https://github.com/gdotdesign/cr-dotenv.git version: 0.3.0 exception_page: - github: crystal-loot/exception_page + git: https://github.com/crystal-loot/exception_page.git version: 0.1.4 git: - github: microgit-com/libgit2.cr - commit: 7069411d3357628a6294af97f88e9c718e87f8e9 + git: https://github.com/microgit-com/libgit2.cr.git + version: 0.1.0+git.commit.7069411d3357628a6294af97f88e9c718e87f8e9 git_diff_parser: - github: microgit-com/git_diff_parser - commit: e9e7db8e14367680a8478cfcb569f6ff6c33e531 + git: https://github.com/microgit-com/git_diff_parser.git + version: 0.1.0+git.commit.e9e7db8e14367680a8478cfcb569f6ff6c33e531 habitat: - github: luckyframework/habitat + git: https://github.com/luckyframework/habitat.git version: 0.4.3 jwt: - github: crystal-community/jwt + git: https://github.com/crystal-community/jwt.git version: 1.2.0 kilt: - github: jeromegn/kilt + git: https://github.com/jeromegn/kilt.git version: 0.6.0 linguist: - github: microgit-com/linguist.cr + git: https://github.com/microgit-com/linguist.cr.git version: 0.2.2 lucky: - github: luckyframework/lucky + git: https://github.com/luckyframework/lucky.git version: 0.21.1 lucky_can: - github: confact/lucky_can - commit: 2004fe0e4d02a43ca3f7b4728c28b1c501285a9c + git: https://github.com/confact/lucky_can.git + version: 0.1.0+git.commit.2004fe0e4d02a43ca3f7b4728c28b1c501285a9c lucky_cli: - github: luckyframework/lucky_cli + git: https://github.com/luckyframework/lucky_cli.git version: 0.21.0 lucky_encrypted: - github: microgit-com/lucky_encrypted - commit: 7f8f8ae16b4801d9237cc75044f915d1ea67f323 - - lucky_flow: - github: luckyframework/lucky_flow - version: 0.6.3 + git: https://github.com/microgit-com/lucky_encrypted.git + version: 0.1.0+git.commit.7f8f8ae16b4801d9237cc75044f915d1ea67f323 lucky_router: - github: luckyframework/lucky_router + git: https://github.com/luckyframework/lucky_router.git version: 0.2.2 markd: - github: icyleaf/markd + git: https://github.com/icyleaf/markd.git version: 0.2.0 mosquito: - github: robacarp/mosquito + git: https://github.com/robacarp/mosquito.git version: 0.7.0 openssl_ext: - github: stakach/openssl_ext + git: https://github.com/stakach/openssl_ext.git version: 1.2.0 pg: - github: will/crystal-pg + git: https://github.com/will/crystal-pg.git version: 0.21.0 pool: - github: ysbaddaden/pool + git: https://github.com/ysbaddaden/pool.git version: 0.2.3 redis: - github: stefanwille/crystal-redis + git: https://github.com/stefanwille/crystal-redis.git version: 2.6.0 - selenium: - github: ysbaddaden/selenium-webdriver-crystal - commit: bda2fd406c1a118251c5a2883f1e1f3af242116e - shell-table: - github: luckyframework/shell-table.cr - commit: 078a04ea58ead5203bb435a3b5fff448ddabaeea + git: https://github.com/luckyframework/shell-table.cr.git + version: 0.9.2+git.commit.078a04ea58ead5203bb435a3b5fff448ddabaeea sluggr: - github: microgit-com/sluggr - commit: 789ba497be050135465e8ef12b9b969514c5d2fd + git: https://github.com/microgit-com/sluggr.git + version: 0.1.0+git.commit.789ba497be050135465e8ef12b9b969514c5d2fd teeplate: - github: luckyframework/teeplate + git: https://github.com/luckyframework/teeplate.git version: 0.8.1 wordsmith: - github: luckyframework/wordsmith + git: https://github.com/luckyframework/wordsmith.git version: 0.2.0 diff --git a/shard.yml b/shard.yml index 66204a0..bd63540 100644 --- a/shard.yml +++ b/shard.yml @@ -8,7 +8,7 @@ targets: microgit: main: src/microgit.cr -crystal: 0.34.0 +crystal: 1.16.3 dependencies: lucky: @@ -23,9 +23,6 @@ dependencies: dotenv: github: gdotdesign/cr-dotenv version: 0.3.0 - lucky_flow: - github: luckyframework/lucky_flow - version: ~> 0.6.3 jwt: github: crystal-community/jwt version: ~> 1.2.0 @@ -48,7 +45,5 @@ dependencies: version: ~> 2.6 lucky_can: github: confact/lucky_can - avram_scoped_id: - github: microgit-com/avram_scoped_id mosquito: github: robacarp/mosquito diff --git a/spec/flows/.keep b/spec/flows/.keep deleted file mode 100644 index e69de29..0000000 diff --git a/spec/flows/authentication_spec.cr b/spec/flows/authentication_spec.cr deleted file mode 100644 index a7da55b..0000000 --- a/spec/flows/authentication_spec.cr +++ /dev/null @@ -1,31 +0,0 @@ -require "../spec_helper" - -describe "Authentication flow" do - it "works" do - flow = AuthenticationFlow.new("test@example.com") - - flow.sign_up "password" - flow.should_be_signed_in - flow.sign_out - flow.sign_in "wrong-password" - flow.should_have_password_error - flow.sign_in "password" - flow.should_be_signed_in - end - - # This is to show you how to sign in as a user during tests. - # Use the `visit` method's `as` option in your tests to sign in as that user. - # - # Feel free to delete this once you have other tests using the 'as' option. - it "allows sign in through backdoor when testing" do - user = UserBox.create - flow = BaseFlow.new - - flow.visit Me::Show, as: user - should_be_signed_in(flow) - end -end - -private def should_be_signed_in(flow) - flow.el("@sign-out-button").should be_on_page -end diff --git a/spec/flows/reset_password_spec.cr b/spec/flows/reset_password_spec.cr deleted file mode 100644 index dd024ca..0000000 --- a/spec/flows/reset_password_spec.cr +++ /dev/null @@ -1,18 +0,0 @@ -require "../spec_helper" - -describe "Reset password flow" do - it "works" do - user = UserBox.create - flow = ResetPasswordFlow.new(user) - - flow.request_password_reset - flow.should_have_sent_reset_email - flow.reset_password "new-password" - flow.should_be_signed_in - flow.sign_out - flow.sign_in "wrong-password" - flow.should_have_password_error - flow.sign_in "new-password" - flow.should_be_signed_in - end -end diff --git a/spec/setup/configure_lucky_flow.cr b/spec/setup/configure_lucky_flow.cr deleted file mode 100644 index c3c8446..0000000 --- a/spec/setup/configure_lucky_flow.cr +++ /dev/null @@ -1,5 +0,0 @@ -LuckyFlow.configure do |settings| - settings.stop_retrying_after = 200.milliseconds - settings.base_uri = Lucky::RouteHelper.settings.base_uri -end -Spec.before_each { LuckyFlow::Server::INSTANCE.reset } diff --git a/spec/setup/start_app_server.cr b/spec/setup/start_app_server.cr index ff0bfee..3a64c70 100644 --- a/spec/setup/start_app_server.cr +++ b/spec/setup/start_app_server.cr @@ -5,6 +5,5 @@ spawn do end Spec.after_suite do - LuckyFlow.shutdown app_server.close end diff --git a/spec/spec_helper.cr b/spec/spec_helper.cr index 9d6ca61..2fc9157 100644 --- a/spec/spec_helper.cr +++ b/spec/spec_helper.cr @@ -1,21 +1,17 @@ ENV["LUCKY_ENV"] = "test" ENV["PORT"] = "5001" require "spec" -require "lucky_flow" require "../src/app" -require "./support/flows/base_flow" require "./support/**" require "../db/migrations/**" # Add/modify files in spec/setup to start/configure programs or run hooks # -# By default there are scripts for setting up and cleaning the database, -# configuring LuckyFlow, starting the app server, etc. +# By default there are scripts for setting up and cleaning the database require "./setup/**" include Carbon::Expectations include Lucky::RequestExpectations -include LuckyFlow::Expectations Avram::Migrator::Runner.new.ensure_migrated! Avram::SchemaEnforcer.ensure_correct_column_mappings! diff --git a/spec/support/flows/authentication_flow.cr b/spec/support/flows/authentication_flow.cr deleted file mode 100644 index fd2e30d..0000000 --- a/spec/support/flows/authentication_flow.cr +++ /dev/null @@ -1,40 +0,0 @@ -class AuthenticationFlow < BaseFlow - private getter email - - def initialize(@email : String) - end - - def sign_up(password) - visit SignUps::New - fill_form SignUpUser, - email: email, - password: password, - password_confirmation: password - click "@sign-up-button" - end - - def sign_out - visit Me::Show - sign_out_button.click - end - - def sign_in(password) - visit SignIns::New - fill_form SignInUser, - email: email, - password: password - click "@sign-in-button" - end - - def should_be_signed_in - sign_out_button.should be_on_page - end - - def should_have_password_error - el("body", text: "Password is wrong").should be_on_page - end - - private def sign_out_button - el("@sign-out-button") - end -end diff --git a/spec/support/flows/base_flow.cr b/spec/support/flows/base_flow.cr deleted file mode 100644 index 93709b2..0000000 --- a/spec/support/flows/base_flow.cr +++ /dev/null @@ -1,3 +0,0 @@ -# Add methods that all or most Flows need to share -class BaseFlow < LuckyFlow -end diff --git a/spec/support/flows/reset_password_flow.cr b/spec/support/flows/reset_password_flow.cr deleted file mode 100644 index 6173a7d..0000000 --- a/spec/support/flows/reset_password_flow.cr +++ /dev/null @@ -1,42 +0,0 @@ -class ResetPasswordFlow < BaseFlow - private getter user, authentication_flow - delegate sign_in, sign_out, should_have_password_error, should_be_signed_in, - to: authentication_flow - delegate email, to: user - - def initialize(@user : User) - @authentication_flow = AuthenticationFlow.new(user.email) - end - - def request_password_reset - with_fake_token do - visit PasswordResetRequests::New - fill_form RequestPasswordReset, - email: email - click "@request-password-reset-button" - end - end - - def should_have_sent_reset_email - with_fake_token do - user = UserQuery.new.email(email).first - PasswordResetRequestEmail.new(user).should be_delivered - end - end - - def reset_password(password) - user = UserQuery.new.email(email).first - token = Authentic.generate_password_reset_token(user) - visit PasswordResets::New.with(user.id, token) - fill_form ResetPassword, - password: password, - password_confirmation: password - click "@update-password-button" - end - - private def with_fake_token - PasswordResetRequestEmail.temp_config(stubbed_token: "fake") do - yield - end - end -end diff --git a/src/services/avram_scoped_id.cr b/src/services/avram_scoped_id.cr new file mode 100644 index 0000000..5b3f361 --- /dev/null +++ b/src/services/avram_scoped_id.cr @@ -0,0 +1,14 @@ +module AvramScopedId + extend self + + def set(column : Avram::Attribute(Int64 | Nil), query : Avram::Queryable) : Nil + return unless column.value.nil? + id = next_scoped_id(query) + column.value = id.to_i64 + end + + private def next_scoped_id(query : Avram::Queryable) + current = query.scoped_id.select_max || 0 + current + 1 + end +end diff --git a/src/shards.cr b/src/shards.cr index 4102e59..2d5debe 100644 --- a/src/shards.cr +++ b/src/shards.cr @@ -4,7 +4,6 @@ Dotenv.load # Require your shards here require "avram" -require "avram_scoped_id" require "lucky" require "carbon" require "authentic"