forked from Gitlink/forgeplus
Compare commits
5 Commits
6571db8a3c
...
fc3f50a2bf
| Author | SHA1 | Date |
|---|---|---|
|
|
fc3f50a2bf | |
|
|
13263a44e4 | |
|
|
ce5b6a67bf | |
|
|
c9b1e30583 | |
|
|
88b96565d1 |
2
LICENSE
2
LICENSE
|
|
@ -121,4 +121,4 @@ You may obtain a copy of Mulan PSL v2 at:
|
|||
THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
|
||||
EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
|
||||
MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
||||
See the Mulan PSL v2 for more details.
|
||||
See the Mulan PSL v2 for more details.
|
||||
|
|
|
|||
|
|
@ -146,6 +146,7 @@ class AccountsController < ApplicationController
|
|||
@user.password = params[:password]
|
||||
# 现在因为是验证码,所以在注册的时候就可以激活
|
||||
@user.activate
|
||||
@user.profile_completed = true
|
||||
# 必须要用save操作,密码的保存是在users中
|
||||
|
||||
interactor = Gitea::RegisterInteractor.call({username: login, email: email, password: params[:password]})
|
||||
|
|
|
|||
|
|
@ -837,6 +837,12 @@ class ApplicationController < ActionController::Base
|
|||
end
|
||||
|
||||
private
|
||||
def update_last_login_on
|
||||
if current_user.logged?
|
||||
current_user.update_column(:last_login_on, Time.now)
|
||||
end
|
||||
end
|
||||
|
||||
def object_not_found
|
||||
uid_logger("Missing template or cant't find record, responding with 404")
|
||||
render json: {message: "您访问的页面不存在或已被删除", status: 404}
|
||||
|
|
|
|||
|
|
@ -25,9 +25,13 @@ class CompareController < ApplicationController
|
|||
end
|
||||
if @exist_pullrequest.present?
|
||||
return -2, "在这些分支之间的合并请求已存在:<a href='/projects/#{@owner.login}/#{@project.identifier}/pulls/#{@exist_pullrequest.id}/Messagecount'>#{@exist_pullrequest.try(:title)}</a>"
|
||||
else
|
||||
if @compare_result["Commits"].blank? && @compare_result["Diff"].blank?
|
||||
return -2, "分支内容相同,无需创建合并请求"
|
||||
else
|
||||
# if @compare_result["Commits"].blank? && @compare_result["Diff"].blank?
|
||||
# return -2, "分支内容相同,无需创建合并请求"
|
||||
# end
|
||||
puts "``````````", @base, @head
|
||||
if @base == @head
|
||||
return -2, "请选择不同分支"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -6,9 +6,6 @@
|
|||
# type :integer
|
||||
# status :integer
|
||||
# conflicted_files :text(65535)
|
||||
# commits_ahead :integer
|
||||
# commits_behind :integer
|
||||
# changed_protected_files :text(65535)
|
||||
# issue_id :integer
|
||||
# index :integer
|
||||
# head_repo_id :integer
|
||||
|
|
@ -20,6 +17,11 @@
|
|||
# merged_commit_id :string(40)
|
||||
# merger_id :integer
|
||||
# merged_unix :integer
|
||||
# commits_ahead :integer
|
||||
# commits_behind :integer
|
||||
# changed_protected_files :text(65535)
|
||||
# commit_num :integer
|
||||
# changed_files :integer
|
||||
#
|
||||
# Indexes
|
||||
#
|
||||
|
|
|
|||
|
|
@ -6,19 +6,21 @@
|
|||
# repo_id :integer
|
||||
# org_id :integer
|
||||
# url :text(65535)
|
||||
# signature :text(65535)
|
||||
# http_method :string(255)
|
||||
# content_type :integer
|
||||
# secret :text(65535)
|
||||
# events :text(65535)
|
||||
# is_ssl :boolean
|
||||
# is_active :boolean
|
||||
# hook_task_type :integer
|
||||
# meta :text(65535)
|
||||
# last_status :integer
|
||||
# created_unix :integer
|
||||
# updated_unix :integer
|
||||
# is_system_webhook :boolean default("0"), not null
|
||||
# type :string(16)
|
||||
# branch_filter :text(65535)
|
||||
# signature :text(65535)
|
||||
# is_ssl :boolean
|
||||
# hook_task_type :integer
|
||||
#
|
||||
# Indexes
|
||||
#
|
||||
|
|
|
|||
|
|
@ -6,19 +6,19 @@
|
|||
# repo_id :integer
|
||||
# hook_id :integer
|
||||
# uuid :string(255)
|
||||
# type :integer
|
||||
# url :text(65535)
|
||||
# signature :text(65535)
|
||||
# payload_content :text(65535)
|
||||
# http_method :string(255)
|
||||
# content_type :integer
|
||||
# event_type :string(255)
|
||||
# is_ssl :boolean
|
||||
# is_delivered :boolean
|
||||
# delivered :integer
|
||||
# is_succeed :boolean
|
||||
# request_content :text(65535)
|
||||
# response_content :text(65535)
|
||||
# type :string(255)
|
||||
# url :text(65535)
|
||||
# signature :text(65535)
|
||||
# http_method :string(255)
|
||||
# content_type :integer
|
||||
# is_ssl :boolean
|
||||
#
|
||||
# Indexes
|
||||
#
|
||||
|
|
|
|||
|
|
@ -6,6 +6,8 @@
|
|||
# dau :integer
|
||||
# created_at :datetime not null
|
||||
# updated_at :datetime not null
|
||||
# wau :integer
|
||||
# mau :integer
|
||||
#
|
||||
|
||||
class Statistic < ApplicationRecord
|
||||
|
|
|
|||
|
|
@ -0,0 +1,6 @@
|
|||
class AddColumnToStatistics < ActiveRecord::Migration[5.2]
|
||||
def change
|
||||
add_column :statistics, :wau, :integer
|
||||
add_column :statistics, :mau, :integer
|
||||
end
|
||||
end
|
||||
|
|
@ -1,10 +1,15 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe "SponsorTiers", type: :request do
|
||||
|
||||
let(:developer_session) { {www_user_id: 5} }
|
||||
let(:visitor_session) { {www_user_id: 4} }
|
||||
let(:valid_session) { {www_user_id: 6} }
|
||||
|
||||
describe "GET /sponsor_tiers" do
|
||||
it "works! (now write some real specs)" do
|
||||
get sponsor_tiers_path
|
||||
expect(response).to have_http_status(200)
|
||||
it "success" do
|
||||
get '/api/sponsor_tiers.json', params: {login: '123457qqcom'}, as: :json
|
||||
expect(JSON.parse(response.body).length).to eq(1)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -13,24 +13,180 @@ RSpec.describe 'Sponsorships', type: :request do
|
|||
let(:invalid_user_attributes) {
|
||||
{amount: 10, visible: 1, sponsor_id: 4, developer_id: 1}
|
||||
}
|
||||
|
||||
let(:invalid_attributes) {
|
||||
{amunt: 10, visible: 1, developid: 1, sponsoid: 5}
|
||||
}
|
||||
|
||||
let(:developer_session) { {www_user_id: 5} }
|
||||
let(:visitor_session) { {www_user_id: 4} }
|
||||
let(:valid_session) { {www_user_id: 6} }
|
||||
|
||||
describe 'create sponsorship' do
|
||||
context 'success' do
|
||||
it 'works! (now write some real specs)' do
|
||||
it 'create a new sponsorship' do
|
||||
allow_any_instance_of(ActionDispatch::Request).to receive(:session) { valid_session }
|
||||
# expect(response.body).to eq('[{"id":5,"amount":10,"visible":1,"sponsor_id":5,"developer_id":4,"created_at":"2021-06-09T10:02:53.000+08:00","updated_at":"2021-06-09T10:02:53.000+08:00","accumulate":10,"url":"http://www.example.com/api/sponsorships/5.json"},{"id":6,"amount":10,"visible":1,"sponsor_id":5,"developer_id":1,"created_at":"2021-06-09T10:42:32.000+08:00","updated_at":"2021-09-22T14:48:09.000+08:00","accumulate":5,"url":"http://www.example.com/api/sponsorships/6.json"}]')
|
||||
# expect {
|
||||
# post '/api/sponsorships.json', params: {developer_id: 1, single: false, amount: 5}
|
||||
# }.to change(Sponsorship, :count).by(1)
|
||||
expect {
|
||||
post '/api/sponsorships.json', params: {'amount'=>5, 'visible'=>1, single: false, 'developer_id'=>1, 'sponsorship'=>{'amount'=>5, 'visible'=>1, 'developer_id'=>1}}, as: :json
|
||||
}.to change(Sponsorship, :count).by(1)
|
||||
end
|
||||
end
|
||||
|
||||
context 'single success' do
|
||||
it 'create a stopped_sponsorship' do
|
||||
allow_any_instance_of(ActionDispatch::Request).to receive(:session) { valid_session }
|
||||
expect {
|
||||
post '/api/sponsorships.json', params: {'amount'=>5, 'visible'=>1, single: true, 'developer_id'=>1, 'sponsorship'=>{'amount'=>5, 'visible'=>1, 'developer_id'=>1}}, as: :json
|
||||
}.to change(StoppedSponsorship, :count).by(1)
|
||||
end
|
||||
end
|
||||
|
||||
context 'fail to repeat sponsorship' do
|
||||
it 'returns fail' do
|
||||
allow_any_instance_of(ActionDispatch::Request).to receive(:session) { valid_session }
|
||||
post '/api/sponsorships.json', params: {'amount'=>5, 'visible'=>1, single: false, 'developer_id'=>4, 'sponsorship'=>{'amount'=>5, 'visible'=>1, 'developer_id'=>4}}, as: :json
|
||||
expect(JSON.parse(response.body)['message']).to eq('您已经赞助了TA')
|
||||
end
|
||||
end
|
||||
|
||||
context 'balance not enough' do
|
||||
it 'returns fail' do
|
||||
allow_any_instance_of(ActionDispatch::Request).to receive(:session) { valid_session }
|
||||
expect {
|
||||
post '/api/sponsorships.json', params: {'amount'=>500000, 'visible'=>1, single: false, 'developer_id'=>1, 'sponsorship'=>{'amount'=>500000, 'visible'=>1, 'developer_id'=>1}}, as: :json
|
||||
}.to change(Sponsorship, :count).by(0)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe 'index' do
|
||||
context 'success' do
|
||||
it 'returns n records' do
|
||||
get '/api/sponsorships.json'
|
||||
expect(JSON.parse(response.body).length).to eq(Sponsorship.count)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe 'stopped' do
|
||||
context 'success' do
|
||||
it 'returns n records' do
|
||||
get '/api/sponsorships/stopped.json'
|
||||
expect(JSON.parse(response.body).length).to eq(StoppedSponsorship.count)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe 'sponsored' do
|
||||
context 'valid_session' do
|
||||
it 'returns 2 records' do
|
||||
allow_any_instance_of(ActionDispatch::Request).to receive(:session) { valid_session }
|
||||
get '/api/sponsorships/sponsored.json', params: {id: 6}
|
||||
expect(JSON.parse(response.body)['sponsorships'].length).to eq(2)
|
||||
end
|
||||
end
|
||||
|
||||
context 'visitor session' do
|
||||
it 'returns 1 record' do
|
||||
allow_any_instance_of(ActionDispatch::Request).to receive(:session) { visitor_session }
|
||||
get '/api/sponsorships/sponsored.json', params: {id: 6}
|
||||
expect(JSON.parse(response.body)['sponsorships'].length).to eq(1)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe 'sponsoring' do
|
||||
context 'valid_session' do
|
||||
it 'returns 2 records' do
|
||||
allow_any_instance_of(ActionDispatch::Request).to receive(:session) { valid_session }
|
||||
get '/api/sponsorships/sponsoring.json', params: {id: 6}
|
||||
expect(JSON.parse(response.body)['sponsorships'].length).to eq(2)
|
||||
end
|
||||
end
|
||||
|
||||
context 'visitor session' do
|
||||
it 'returns 1 record' do
|
||||
allow_any_instance_of(ActionDispatch::Request).to receive(:session) { visitor_session }
|
||||
get '/api/sponsorships/sponsoring.json', params: {id: 6}
|
||||
expect(JSON.parse(response.body)['sponsorships'].length).to eq(1)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe 'stopped_sponsored' do
|
||||
context 'valid_session' do
|
||||
it 'returns 2 records' do
|
||||
allow_any_instance_of(ActionDispatch::Request).to receive(:session) { valid_session }
|
||||
get '/api/sponsorships/stopped_sponsored.json', params: {id: 6}
|
||||
expect(JSON.parse(response.body)['sponsorships'].length).to eq(2)
|
||||
end
|
||||
end
|
||||
|
||||
context 'visitor session' do
|
||||
it 'returns 1 record' do
|
||||
allow_any_instance_of(ActionDispatch::Request).to receive(:session) { visitor_session }
|
||||
get '/api/sponsorships/stopped_sponsored.json', params: {id: 6}
|
||||
expect(JSON.parse(response.body)['sponsorships'].length).to eq(1)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe 'stopped_sponsoring' do
|
||||
context 'valid_session' do
|
||||
it 'returns 2 records' do
|
||||
allow_any_instance_of(ActionDispatch::Request).to receive(:session) { valid_session }
|
||||
get '/api/sponsorships/stopped_sponsoring.json', params: {id: 6}
|
||||
expect(JSON.parse(response.body)['sponsorships'].length).to eq(2)
|
||||
end
|
||||
end
|
||||
|
||||
context 'visitor session' do
|
||||
it 'returns 1 record' do
|
||||
allow_any_instance_of(ActionDispatch::Request).to receive(:session) { visitor_session }
|
||||
get '/api/sponsorships/stopped_sponsoring.json', params: {id: 6}
|
||||
expect(JSON.parse(response.body)['sponsorships'].length).to eq(1)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe 'update' do
|
||||
context 'as sponsor' do
|
||||
it 'update success' do
|
||||
allow_any_instance_of(ActionDispatch::Request).to receive(:session) { valid_session }
|
||||
put '/api/sponsorships/97.json', params: {amount: 50, sponsorship: {amount: 50}}, as: :json
|
||||
expect(Sponsorship.find(97).amount).to eq(50)
|
||||
expect(response.body).to eq('{"status":1,"message":"修改成功"}')
|
||||
end
|
||||
end
|
||||
|
||||
context 'as others' do
|
||||
it 'fail' do
|
||||
allow_any_instance_of(ActionDispatch::Request).to receive(:session) { developer_session }
|
||||
put '/api/sponsorships/97.json', params: {amount: 50, sponsorship: {amount: 50}}, as: :json
|
||||
expect(Sponsorship.find(97).amount).to eq(10)
|
||||
expect(response.body).to eq('{"status":401,"message":"没有权限"}')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe 'destroy' do
|
||||
context 'as sponsor' do
|
||||
it 'success' do
|
||||
allow_any_instance_of(ActionDispatch::Request).to receive(:session) { valid_session }
|
||||
expect{ delete '/api/sponsorships/100.json'}.to change(StoppedSponsorship, :count).by(1)
|
||||
end
|
||||
end
|
||||
|
||||
context 'as developer' do
|
||||
it 'success' do
|
||||
allow_any_instance_of(ActionDispatch::Request).to receive(:session) { developer_session }
|
||||
expect{ delete '/api/sponsorships/100.json'}.to change(StoppedSponsorship, :count).by(1)
|
||||
end
|
||||
end
|
||||
|
||||
context 'as others' do
|
||||
it 'fail' do
|
||||
allow_any_instance_of(ActionDispatch::Request).to receive(:session) { visitor_session }
|
||||
expect{ delete '/api/sponsorships/100.json'}.to change(StoppedSponsorship, :count).by(0)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ RSpec.describe 'Wallet', type: :request do
|
|||
describe 'GET /wallets/balance.json' do
|
||||
it 'success' do
|
||||
allow_any_instance_of(ActionDispatch::Request).to receive(:session) { valid_session }
|
||||
get '/api/wallets/balance.json', params: { id: 6 }
|
||||
get '/api/wallets/balance.json', params: { id: 6 }, as: :json
|
||||
expect(JSON.parse(response.body)['balance']).to eq(100)
|
||||
end
|
||||
end
|
||||
|
|
@ -18,7 +18,7 @@ RSpec.describe 'Wallet', type: :request do
|
|||
context 'category all' do
|
||||
it 'return 2 records' do
|
||||
allow_any_instance_of(ActionDispatch::Request).to receive(:session) { valid_session }
|
||||
get '/api/wallets/coin_changes.json', params: { id: 6, category: 'all' }
|
||||
get '/api/wallets/coin_changes.json', params: { id: 6, category: 'all' }, as: :json
|
||||
expect(JSON.parse(response.body)['coin_changes'].length).to eq(2)
|
||||
# expect(JSON.parse(response.body)).to eq('')
|
||||
end
|
||||
|
|
@ -27,7 +27,7 @@ RSpec.describe 'Wallet', type: :request do
|
|||
context 'category outcome' do
|
||||
it 'return 1 outcome records' do
|
||||
allow_any_instance_of(ActionDispatch::Request).to receive(:session) { valid_session }
|
||||
get '/api/wallets/coin_changes.json', params: { id: 6, category: 'outcome' }
|
||||
get '/api/wallets/coin_changes.json', params: { id: 6, category: 'outcome' }, as: :json
|
||||
expect(JSON.parse(response.body)['coin_changes'][0]['amount']).to eq(5)
|
||||
expect(JSON.parse(response.body)['coin_changes'].length).to eq(1)
|
||||
end
|
||||
|
|
@ -36,7 +36,7 @@ RSpec.describe 'Wallet', type: :request do
|
|||
context 'category outcome' do
|
||||
it 'return 1 income records' do
|
||||
allow_any_instance_of(ActionDispatch::Request).to receive(:session) { valid_session }
|
||||
get '/api/wallets/coin_changes.json', params: { id: 6, category: 'income' }
|
||||
get '/api/wallets/coin_changes.json', params: { id: 6, category: 'income' }, as: :json
|
||||
expect(JSON.parse(response.body)['coin_changes'][0]['amount']).to eq(10)
|
||||
expect(JSON.parse(response.body)['coin_changes'].length).to eq(1)
|
||||
end
|
||||
|
|
|
|||
Loading…
Reference in New Issue