Skip to content

Commit

Permalink
Add specs for buddy editor
Browse files Browse the repository at this point in the history
  • Loading branch information
xuanxu committed Mar 14, 2024
1 parent 9e203c1 commit d20aeb1
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
10 changes: 10 additions & 0 deletions spec/models/editor_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,16 @@
end

describe "#associations" do
it "belongs to a user" do
association = Editor.reflect_on_association(:user)
expect(association.macro).to eq(:belongs_to)
end

it "has one buddy editor" do
association = Editor.reflect_on_association(:buddy_editor)
expect(association.macro).to eq(:has_one)
end

it "has many votes" do
association = Editor.reflect_on_association(:votes)
expect(association.macro).to eq(:has_many)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require "rails_helper"

feature "Editor list" do
let(:user_editor) { create(:user, editor: create(:editor, first_name: 'Lorena', description: 'Science testing editor')) }
feature "Editors management" do
let(:user_editor) { create(:user, editor: create(:editor, first_name: 'Lorena', last_name: 'Edits', login: "@letester")) }
let(:admin_editor) { create(:admin_user, editor: create(:board_editor)) }

scenario "Is not public" do
Expand Down Expand Up @@ -44,18 +44,24 @@
expect(page).to have_content('Computing, Test systems')
expect(page).to have_content('Software testing editor')
expect(page).to have_content('topic')
expect(page).to have_content('Buddy: None')
click_link "List"
expect(current_path).to eq(editors_path)
end

scenario "change editor info" do
user_editor
allow(Repository).to receive(:editors).and_return(["@tester", "@mctester"])
click_link "Edit", href: edit_editor_path(Editor.find_by(login: 'tester'))
fill_in :editor_category_list, with: "Fancy"
select "Lorena Edits (@letester)", from: :editor_buddy_id

click_on "Update Editor"
click_link "List"
expect(current_path).to eq(editors_path)
expect(page).to have_content('Fancy')
click_link "tester"
expect(page).to have_content('Buddy: Lorena Edits (@letester)')
end

scenario "Pending editors are not listed" do
Expand Down

0 comments on commit d20aeb1

Please sign in to comment.