mirror of
https://gitlink.org.cn/Gitlink/forgeplus.git
synced 2026-05-02 19:30:48 +08:00
init project
This commit is contained in:
18
spec/requests/accounts_spec.rb
Normal file
18
spec/requests/accounts_spec.rb
Normal file
@@ -0,0 +1,18 @@
|
||||
require "rails_helper"
|
||||
|
||||
|
||||
RSpec.describe "帐户", type: :request do
|
||||
|
||||
|
||||
it "成功登录" do
|
||||
ecpost login_accounts_url, {login: 'guange', password: '123456'}
|
||||
expect(JSON.parse(response.body)["login"]).to eq('guange')
|
||||
end
|
||||
|
||||
it "登录失败" do
|
||||
ecpost login_accounts_url, {login: 'guange', password: 'wrong password'}
|
||||
expect(JSON.parse(response.body)["status"]).to eq(-1)
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
10
spec/requests/courses_spec.rb
Normal file
10
spec/requests/courses_spec.rb
Normal file
@@ -0,0 +1,10 @@
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe "Courses", type: :request do
|
||||
describe "GET /courses" do
|
||||
it "works! (now write some real specs)" do
|
||||
get courses_path
|
||||
expect(response).to have_http_status(200)
|
||||
end
|
||||
end
|
||||
end
|
||||
10
spec/requests/edu_settings_spec.rb
Normal file
10
spec/requests/edu_settings_spec.rb
Normal file
@@ -0,0 +1,10 @@
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe "EduSettings", type: :request do
|
||||
describe "GET /edu_settings" do
|
||||
it "works! (now write some real specs)" do
|
||||
get edu_settings_path
|
||||
expect(response).to have_http_status(200)
|
||||
end
|
||||
end
|
||||
end
|
||||
49
spec/requests/git_service_spec.rb
Normal file
49
spec/requests/git_service_spec.rb
Normal file
@@ -0,0 +1,49 @@
|
||||
require "rails_helper"
|
||||
|
||||
|
||||
RSpec.describe "git服务" do
|
||||
|
||||
let(:repo_path){'educoder/i4nzvb7x.git'}
|
||||
|
||||
it "add_repository" do
|
||||
data = GitService.add_repository(repo_path: 'educoder/112233.git')
|
||||
expect data["url_to_repo"].size > 0
|
||||
end
|
||||
|
||||
it "fork_repository" do
|
||||
data = GitService.fork_repository(repo_path: 'educoder/112233.git', fork_repository_path: 'educoder/44444.git')
|
||||
puts data
|
||||
end
|
||||
|
||||
it "delete_repository" do
|
||||
data = GitService.delete_repository(repo_path: 'educoder/44444.git')
|
||||
puts data
|
||||
end
|
||||
|
||||
it "file tree" do
|
||||
data = GitService.file_tree(repo_path: repo_path, path: '')
|
||||
expect data.size > 0
|
||||
end
|
||||
|
||||
it "file_content" do
|
||||
data = GitService.file_content(repo_path: repo_path, path: 'step1/linearList_1.cpp')
|
||||
puts data
|
||||
expect data["content"].size > 0
|
||||
end
|
||||
|
||||
it "commits" do
|
||||
data = GitService.commits(repo_path: repo_path)
|
||||
expect data.size > 0
|
||||
end
|
||||
|
||||
it 'update_file' do
|
||||
data = GitService.update_file(repo_path: repo_path,
|
||||
file_path: 'step1/step1.c',
|
||||
message: 'commit by test',
|
||||
content: 'afdjadsjfj1111',
|
||||
author_name: 'guange',
|
||||
author_email: '8863824@gmil.com')
|
||||
expect data.nil?
|
||||
end
|
||||
|
||||
end
|
||||
10
spec/requests/memos_spec.rb
Normal file
10
spec/requests/memos_spec.rb
Normal file
@@ -0,0 +1,10 @@
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe "Memos", type: :request do
|
||||
describe "GET /memos" do
|
||||
it "works! (now write some real specs)" do
|
||||
get memos_path
|
||||
expect(response).to have_http_status(200)
|
||||
end
|
||||
end
|
||||
end
|
||||
85
spec/requests/shixuns_spec.rb
Normal file
85
spec/requests/shixuns_spec.rb
Normal file
@@ -0,0 +1,85 @@
|
||||
require "rails_helper"
|
||||
|
||||
|
||||
RSpec.describe "实训页面测试", type: :request do
|
||||
|
||||
context "实训首页" do
|
||||
it "默认参数" do
|
||||
ecget shixuns_url
|
||||
expect(JSON.parse(response.body).size).to be > 0
|
||||
end
|
||||
|
||||
|
||||
it "分类选择" do
|
||||
ecget shixuns_url, {tag_level: 1, tag_id: 1}
|
||||
expect(JSON.parse(response.body).size).to be > 0
|
||||
end
|
||||
|
||||
it "搜索关键字" do
|
||||
keyword = "abc"
|
||||
ecget shixuns_url, {keyword: keyword}
|
||||
|
||||
shixuns = JSON.parse(response.body)
|
||||
expect(shixuns.size).to be > 0
|
||||
end
|
||||
|
||||
it "筛选 状态" do
|
||||
ecget shixuns_url, {status: 2}
|
||||
shixuns = JSON.parse(response.body)
|
||||
expect(shixuns.size).to be > 0
|
||||
end
|
||||
|
||||
it "筛选 难度" do
|
||||
ecget shixuns_url, {diff: 1}
|
||||
expect(JSON.parse(response.body).size).to be > 0
|
||||
end
|
||||
|
||||
it "是否隐藏我的实训" do
|
||||
ecget shixuns_url, {hidemy: true}
|
||||
expect(JSON.parse(response.body).size).to be > 0
|
||||
end
|
||||
|
||||
it "排序参数" do
|
||||
ecget shixuns_url, {order_by: "hot"}
|
||||
expect(JSON.parse(response.body)[0]["id"]).to eq(70)
|
||||
end
|
||||
|
||||
it "分页参数" do
|
||||
ecget shixuns_url, {page: 1, limit: 5}
|
||||
expect(JSON.parse(response.body).size).to eq(5)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
it "获取顶部菜单" do
|
||||
ecget menus_shixuns_url
|
||||
expect(JSON.parse(response.body).size).to be > 0
|
||||
end
|
||||
|
||||
|
||||
it "实训详情" do
|
||||
ecget shixun_url(identifier: 'WQ9ROKFX')
|
||||
expect(JSON.parse(response.body)["identifier"]).to eq('WQ9ROKFX')
|
||||
end
|
||||
|
||||
|
||||
it "排行榜" do
|
||||
ecget ranking_list_shixun_url(identifier: 'nf9ja46l')
|
||||
expect(JSON.parse(response.body).size).to be > 0
|
||||
end
|
||||
|
||||
it "评论" do
|
||||
ecget discusses_shixun_url(identifier: 'nf9ja46l')
|
||||
expect(JSON.parse(response.body).size).to be > 0
|
||||
end
|
||||
|
||||
it "任务" do
|
||||
ecget tasks_shixun_url(identifier: 'nf9ja46l')
|
||||
expect(JSON.parse(response.body).size).to be > 0
|
||||
end
|
||||
|
||||
it "合作者" do
|
||||
ecget collaborators_shixun_url(identifier: 'WQ9ROKFX')
|
||||
expect(JSON.parse(response.body).size).to be > 0
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user